Tracing & Open Telemetry Examples
Are there any example servers that implement Tracing & Open Telemetry? I couldn't find any in the examples repo, and wondering if there are any OSS example usage of this?
There is no example, basically you just need to initialize the tracer and pass it to the OpenTelemetry extension, it will work.
Do we need to do something special to link the spans with the traceparent HTTP header?
I'm using axum.
I wonder if extensions/opentelemetry.rs would need to do something like:
https://github.com/tokio-rs/tracing/blob/1e09e50e8d15580b5929adbade9c782a6833e4a0/examples/examples/opentelemetry-remote-context.rs#L32-L40
Is it possible to access the HTTP request headers in extensions/opentelemetry.rs?
EDIT: maybe it should try to work with the integrations. like with axum_tracing_opentelemetry.
EDIT: it's also confusing that when using both tracing_subscriber and the opentelemetry extension, the spans are sent twice.
For the traceparent HTTP header you just need to create you own Propagator with opentelemetry, with this Propagator you need to implement the TextMapPropagator trait to play with the Extractor and Injector. It's not something linked to async-graphql. Just using the tracing extension is enough to have the span
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
I've been recently messing around with opentelemetry, still a WIP as i've moved onto other things while I do more research but I did manage to get the output sent to my terminal:
let tracer = stdout::new_pipeline().install_simple();
let opentelemetry_extension = OpenTelemetry::new(tracer);
// ...graphql schema
.extension(opentelemetry_extension)
In Cargo.toml
async-graphql = { version = "4.0.12", features = ["opentelemetry"] }
opentelemetry = "0.17.0"
The issue I opened to learn more about it https://github.com/async-graphql/async-graphql/issues/1031
There are also some examples of what @Miaxos suggested out in the wild if you dig deep enough, I can't remember exactly where I found them though sorry!
I think the documentation within async-graphql for this topic could be improved though - @kennetpostigo I'd be happy to work with you to do that and maybe add an example too if it makes sense.
I added a basic stdout pipeline example https://github.com/async-graphql/examples/pull/59 and will be adding a jaeger one soon