Allow reusing registered global OpenTelemetry#46230
Conversation
There was a problem hiding this comment.
Not sure reuse it by default or a boolean configuration property should be introduced.
|
I don't think this is a sane goal. It is already complicated for Spring Boot users to figure out the available options. We have tried to clarify things in #41227 (even if the reverse is not true) but if I understand correctly, this change will cause duplicate metrics and will disrupt OTel Java agent users. |
I think it's necessary to introduce a flag to allow users reuse it. EDIT: I've updated the PR to introduce configuration key |
Spring Boot instrumentation will be included when applications are running with OpenTelemetry Java Agent. Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
|
Adding a flag doesn't really address Brian's point. We don't want users to be able to opt into having duplicate metrics. I'm going to close this one as the downsides outweigh any potential benefit. If we've misunderstood the implications of the change then please let us know and we can take another look. |
FYI, I'm using OpenTelemetry Java Agent instrument traces only, and didn't configure |
|
Another option, we could reuse global registered OpenTelemetry only for to @Bean
@ConditionalOnMissingBean
Tracer otelTracer(OpenTelemetry openTelemetry, Optional<OtlpTracingConnectionDetails> otlpTracingConnectionDetails) {
OpenTelemetry otel = openTelemetry;
if (GlobalOpenTelemetry.get() != OpenTelemetry.noop() && otlpTracingConnectionDetails.isEmpty()) {
otel = GlobalOpenTelemetry.get();
}
return otel.getTracer("org.springframework.boot", SpringBootVersion.getVersion());
} |
Spring Boot instrumentation will be included when applications are running with OpenTelemetry Java Agent.