OpenTelemetry & SpringBoot #4654
-
Hi all, I'm trying to add OpenTelemetry in some microservices based on SpringBoot. The docs says that; SdkTracerProvider sdkTracerProvider = SdkTracerProvider.builder()
.addSpanProcessor(BatchSpanProcessor.builder(OtlpGrpcSpanExporter.builder().build()).build())
.build();
SdkMeterProvider sdkMeterProvider = SdkMeterProvider.builder()
.registerMetricReader(PeriodicMetricReader.builder(OtlpGrpcMetricExporter.builder().build()).build())
.build();
OpenTelemetry openTelemetry = OpenTelemetrySdk.builder()
.setTracerProvider(sdkTracerProvider)
.setMeterProvider(sdkMeterProvider)
.setPropagators(ContextPropagators.create(W3CTraceContextPropagator.getInstance()))
.buildAndRegisterGlobal(); I have two questions about this approach:
@Configuration
public class OpenTelemetryConfig {
@Bean
public OpenTelemetry buildOpenTelemetry() {
OpenTelemetry openTelemetry = GlobalOpenTelemetry.get();
return openTelemetry;
}
} Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hey @ziomill ,
You'll get a no-op implementation, which is most likely not what you want at all.
There are a couple of ways you could implement that:
|
Beta Was this translation helpful? Give feedback.
Hey @ziomill ,
You'll get a no-op implementation, which is most likely not what you want at all.
GlobalOpenTelemetry
is pretty much only for the javaagent coop, you shouldn't use it in manually instrumented application code (well, it's generally a good idea to avoid glo…