Skip to content

Commit

Permalink
[shippingservice] add resource data (open-telemetry#504)
Browse files Browse the repository at this point in the history
* Add resource data to shipping service

* add changelog

* Update shippingservice docs

* Cargo update and formatting
  • Loading branch information
julianocosta89 committed Nov 7, 2022
1 parent b62b29b commit 09ae3e0
Show file tree
Hide file tree
Showing 6 changed files with 247 additions and 224 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ significant modifications will be credited to OpenTelemetry Authors.
([#455](https://github.com/open-telemetry/opentelemetry-demo/pull/455))
* Update cartservice Dockerfile to support ARM64
([#439](https://github.com/open-telemetry/opentelemetry-demo/pull/439))
* Update shippingservice to add resource data to spans
([#504](https://github.com/open-telemetry/opentelemetry-demo/pull/504))
* Add Envoy as reverse proxy for all user-facing services
([#508](https://github.com/open-telemetry/opentelemetry-demo/pull/508))
* Envoy: Grafana, Load Generator, Jaeger exposed.
Expand Down
7 changes: 7 additions & 0 deletions docs/services/shippingservice.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ The OpenTelemetry SDK is initialized from `main`.
```rust
fn init_tracer() -> Result<sdktrace::Tracer, TraceError> {
global::set_text_map_propagator(TraceContextPropagator::new());
let os_resource = OsResourceDetector.detect(Duration::from_secs(0));
let process_resource = ProcessResourceDetector.detect(Duration::from_secs(0));
let sdk_resource = SdkProvidedResourceDetector.detect(Duration::from_secs(0));
opentelemetry_otlp::new_pipeline()
.tracing()
.with_exporter(
Expand All @@ -38,6 +41,10 @@ fn init_tracer() -> Result<sdktrace::Tracer, TraceError> {
)), // TODO: assume this ^ is true from config when opentelemetry crate > v0.17.0
// https://github.com/open-telemetry/opentelemetry-rust/pull/806 includes the environment variable.
)
.with_trace_config(
sdktrace::config()
.with_resource(os_resource.merge(&process_resource).merge(&sdk_resource)),
)
.install_batch(opentelemetry::runtime::Tokio)
}
```
Expand Down
Loading

0 comments on commit 09ae3e0

Please sign in to comment.