-
Notifications
You must be signed in to change notification settings - Fork 858
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
document how to use micrometer tracing with spring starter #11039
Comments
Here's how to do it: Dependencies:
Enable support for management:
observations:
annotations:
enabled: true Use @Service
public class DemoService {
@NewSpan
public String sayHello() {
return "hello LGTM";
}
} I didn't test any more advanced features of micrometer tracing - so it's possible there are some rough edges. Config to suppress double spans: @Bean
public DefaultTracingObservationHandler defaultTracingObservationHandler(Tracer tracer) {
return new DefaultTracingObservationHandler(tracer) {
@Override
public void onStop(Observation.Context context) {
// no-op
}
@Override
public void onStart(Observation.Context context) {
// no-op
}
};
}
@Bean
public PropagatingReceiverTracingObservationHandler<?> propagatingReceiverTracingObservationHandler(Tracer tracer,
Propagator propagator) {
return new PropagatingReceiverTracingObservationHandler<>(tracer, propagator) {
@Override
public void onError(ReceiverContext context) {
// no-op
}
@Override
public void onStop(ReceiverContext context) {
// no-op
}
};
}
@Bean
public PropagatingSenderTracingObservationHandler<?> propagatingSenderTracingObservationHandler(Tracer tracer,
Propagator propagator) {
return new PropagatingSenderTracingObservationHandler<>(tracer, propagator) {
@Override
public void onError(SenderContext context) {
// no-op
}
@Override
public void onStop(SenderContext context) {
// no-op
}
};
} before (with double spans): after: |
@jeanbisutti should we document this? should we include the "suppress double spans" code in the starter? |
I don't believe supporting in the past the spring folks have suggested they may donate the bridge to opentelemetry-java-contrib repository, in which case we could document it there |
@zeitlinger @trask We could discuss during the Java SIG and potentially close this issue |
that's what we agreed to |
It should work by adding
runtimeOnly "io.micrometer:micrometer-tracing-bridge-otel"
to the dependencies.Not sure if this should be included in the starter by default.
The text was updated successfully, but these errors were encountered: