Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[shipping] - add span attributes #260

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@ 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))
4 changes: 3 additions & 1 deletion docs/manual_span_attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,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