micrometer-metrics / tracing

Provides tracing abstractions over tracers and tracing system reporters.
https://micrometer.io
Apache License 2.0
252 stars 46 forks source link

Context not propagated in a reactive programming, OpenTelemetry context is not available #826

Closed tadlakha9 closed 2 months ago

tadlakha9 commented 3 months ago

We are facing an issue with spring boot 3.3.1, TraceContext is not propagated while calling one microservice with another via retrofit.

java.lang.NullPointerException: Cannot invoke "io.micrometer.tracing.Span.context()" because the return value of "io.micrometer.tracing.Tracer.currentSpan()" is null

Our Observation

When we call an api in microservice 1, tracer.currentSpan().context() is available after calling another microservice via retrofit, TraceContext would not get propagated and a new context with new traceId would get started.

Complete flow working fine with bridge brave but facing issue with bridge otel.

Sample projects

https://github.com/tadlakha9/micro1 https://github.com/tadlakha9/micro2

tadlakha9 commented 3 months ago

I don't understand how the installation of above files would solve my issue, as i mentioned its working fine while using the bridge brave but not with bridge otel

shakuzen commented 3 months ago

@tadlakha9 I believe GitHub is having a problem with spam bots posting links to download and install potentially malicious software on issues across GitHub. It looks like the comments and users have been removed by GitHub now.

shakuzen commented 3 months ago

I took a quick look at your sample project. It looks like there's a lot of extra config that you probably don't need if you're using Spring Boot's auto-config and Micrometer. For Retrofit instrumentation, you can pass an OkHttpClient that is instrumented to the Retrofit builder - see where we do that in our tests here. You can see some documentation about OkHttpClient instrumentation here. Try updating the sample projects to minimally do that without the other config and let us know if that works.

github-actions[bot] commented 2 months ago

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

tadlakha9 commented 2 months ago

The issue is on my side, which was corrected now, thanks for you support.