tracing-actix-web icon indicating copy to clipboard operation
tracing-actix-web copied to clipboard

Empty trace_id when misconfiguring the opentelemetry version

Open luca-iachini opened this issue 11 months ago • 0 comments

Hi, thanks for the tracing-actix-web crate.

I ran into an issue that I wanted to share. It involves a misconfiguration between the feature flag enabling opentelemetry in tracing-actix-web and the opentelemetry dependency in my project. The project compiled fine, and the application ran without errors, but the trace_id was always empty.

The issue seems to arise from global::set_text_map_propagator(TraceContextPropagator::new()) configuring the propagator for the main application but not for the internal dependency used by tracing-actix-web. It is easy to reproduce this issue by modifying one of the examples in this crate to use a different opentelemetry version than the one specified by the feature flag enabled for tracing-actix-web. In that case, tracing-actix-web uses the NoopTextMapPropagator instead of the one configured in the application.

Because there are no warnings or compile-time errors, it took me a while to figure this out. It would be great if there were a way to detect or prevent this kind of misconfiguration at compile time. Alternatively, adding a note in the documentation would help users who are encountering this problem.

luca-iachini avatar Nov 30 '24 18:11 luca-iachini