Skip to content

Commit bcd7172

Browse files
swcollardDaleSeo
authored andcommitted
fix: Include the cargo feature and TraceContextPropagator to send otel headers downstream (#307)
* Fix sending OTLP trace headers downstream to GQL API * Changeset
1 parent 708a0c2 commit bcd7172

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### fix: Include the cargo feature and TraceContextPropagator to send otel headers downstream - @swcollard PR #307
2+
3+
Inside the reqwest middleware, if the global text_map_propagator is not set, it will no op and not send the traceparent and tracestate headers to the Router. Adding this is needed to correlate traces from the mcp server to the router or other downstream APIs

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/apollo-mcp-server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ opentelemetry-stdout = "0.30.0"
3939
opentelemetry_sdk = "0.30.0"
4040
regex = "1.11.1"
4141
reqwest-middleware = "0.4.2"
42-
reqwest-tracing = "0.5.8"
42+
reqwest-tracing = { version = "0.5.8", features = ["opentelemetry_0_30"] }
4343
reqwest.workspace = true
4444
rmcp = { version = "0.6", features = [
4545
"server",

crates/apollo-mcp-server/src/runtime/trace.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use opentelemetry::{KeyValue, global, trace::TracerProvider as _};
22
use opentelemetry_sdk::{
33
Resource,
44
metrics::{MeterProviderBuilder, PeriodicReader, SdkMeterProvider},
5+
propagation::TraceContextPropagator,
56
trace::{RandomIdGenerator, SdkTracerProvider},
67
};
78

@@ -65,6 +66,8 @@ fn init_tracer_provider() -> Result<SdkTracerProvider, anyhow::Error> {
6566
.with_batch_exporter(exporter)
6667
.build();
6768

69+
// Set the global propagator (usually early in main())
70+
global::set_text_map_propagator(TraceContextPropagator::new());
6871
global::set_tracer_provider(trace_provider.clone());
6972

7073
Ok(trace_provider)

0 commit comments

Comments
 (0)