Skip to content

Commit

Permalink
[shipping] - add span attributes (open-telemetry#260)
Browse files Browse the repository at this point in the history
* set span attributes

* shipping span attributes
  • Loading branch information
puckpuck authored Aug 5, 2022
1 parent e6dcf0d commit 553f984
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,7 @@ significant modifications will be credited to OpenTelemetry Authors.
([#255](https://github.com/open-telemetry/opentelemetry-demo/pull/255))
* Added spanmetrics processor to otelcol
([#212](https://github.com/open-telemetry/opentelemetry-demo/pull/212))
* Added span attributes to shipping service
([#260](https://github.com/open-telemetry/opentelemetry-demo/pull/260))
* Added span attributes to currency service
([#265](https://github.com/open-telemetry/opentelemetry-demo/pull/265))
4 changes: 3 additions & 1 deletion docs/manual_span_attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,6 @@ This document contains the list of manual Span Attributes used throughout the de

## ShippingService

* None yet
* `app.shipipng.cost.total`
* `app.shipping.items.count`
* `app.shipping.tracking.id`
2 changes: 1 addition & 1 deletion src/shippingservice/src/shipping_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl ShippingService for ShippingServer {
.start_with_context("ship-order", &parent_cx);

let tid = create_tracking_id();
span.add_event("Tracking ID issued", vec![KeyValue::new(tid.clone(), true)]);
span.set_attribute(KeyValue::new("app.shipping.tracking.id", tid.clone()));
info!("Tracking ID Created: {}", tid);

Ok(Response::new(ShipOrderResponse { tracking_id: tid }))
Expand Down
3 changes: 2 additions & 1 deletion src/shippingservice/src/shipping_service/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ pub fn create_quote_from_count(count: u32) -> Quote {
};
get_active_span(|span| {
let q = create_quote_from_float(f);
span.add_event("Quote Issued", vec![KeyValue::new(format!("{}", q), true)]);
span.set_attribute(KeyValue::new("app.shipping.items.count", count as i64));
span.set_attribute(KeyValue::new("app.shipping.cost.total", format!("{}", q)));
q
})
}
Expand Down

0 comments on commit 553f984

Please sign in to comment.