-
Notifications
You must be signed in to change notification settings - Fork 41.3k
Allow reusing registered global OpenTelemetry #46230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* @since 3.2.0 | ||
*/ | ||
@AutoConfiguration | ||
@ConditionalOnClass(OpenTelemetrySdk.class) | ||
@EnableConfigurationProperties(OpenTelemetryProperties.class) | ||
public class OpenTelemetryAutoConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnMissingBean(OpenTelemetry.class) | ||
@Conditional(OnRegisteredGlobalOpenTelemetryCondition.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
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 Lines 142 to 146 in 5db3cac
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.