Hy
I am using springboot 3 with the new micrometer observation. Is there a way to prevent generating a trace_id/span_id for some paths like /actuator/prometheus? Observation add a trace id for each call to /actuator/*.
Thank you
I supplied one answer using ObservationPredicate, which filters out tracing and metrics.
Here is another answer using SpanExportingPredicate, which only filters out traces, and leaves metrics in place.
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.server.observation.ServerRequestObservationContext;
@Configuration
public class TracingConfig {
@Bean
SpanExportingPredicate noActuator() {
return span -> span.getTags().get("uri") == null || !span.getTags().get("uri").startsWith("/actuator");
}
@Bean
SpanExportingPredicate noSwagger() {
return span -> span.getTags().get("uri") == null || !span.getTags().get("uri").startsWith("/swagger");
}
@Bean
SpanExportingPredicate noApiDocs() {
return span -> span.getTags().get("uri") == null || !span.getTags().get("uri").startsWith("/v3/api-docs");
}
}