-
Notifications
You must be signed in to change notification settings - Fork 47
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
Ability to exclude some endpoints from being traced #148
Comments
Are you using Spring Boot? Then you should file an issue there to allow opting in for URLs or opting out of them. In case you're not using Spring Boot you can create a |
Yeah we are using spring boot. I will open an issue there. But meanwhile, I think I found a (hacky) workaround. Since our sole use case is for the actuator endpoints, which don't send any HTTP requests, I created my own public class FilteredZipkinExporter extends CompositeSpanExporter {
public FilteredZipkinExporter(ZipkinSpanExporter zipkinSpanExporter) {
super(List.of(zipkinSpanExporter), null, null, null);
}
@Override
public CompletableResultCode export(Collection<SpanData> spans) {
Set<String> actuatorTraceIds = spans.stream()
.filter(span -> span.getName().contains("actuator"))
.map(SpanData::getTraceId)
.collect(toSet());
List<SpanData> nonActuatorSpans = spans.stream()
.filter(span -> !actuatorTraceIds.contains(span.getTraceId()))
.collect(toList());
return super.export(nonActuatorSpans);
}
} I take But this is not enough. Since @Configuration
public class ZipkinSpanExporterPostProcessor implements BeanPostProcessor {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if(bean instanceof ZipkinSpanExporter zipkinSpanExporter) {
return new FilteredZipkinExporter(zipkinSpanExporter);
}
return bean;
}
} Then only my I know this is hacky but I tried your solution, but that gets the spans one by one, so I can filter out the spans that are actually related to actuator, but all the other spans that are related with this trace gets pushed to zipkin. But thanks to your pointers, I managed to hack a solution 🙂 |
Since you are using Boot, the instrumentation there is using the Observation API. @Bean
public ObservationPredicate actuatorServerContextPredicate() {
return (name, context) -> {
if (name.equals("http.server.requests") && context instanceof ServerRequestObservationContext serverContext) {
return !serverContext.getCarrier().getRequestURI().startsWith("/actuator");
}
else {
return true;
}
};
}
@Bean
public ObservationPredicate actuatorClientContextPredicate() {
return (name, context) -> {
if (name.equals("http.client.requests") && context instanceof FeignContext feignContext) {
return !feignContext.getCarrier().url().endsWith("/actuator/health");
}
else {
return true;
}
};
} |
As far as I can tell, the details here should answer your question, let me close the issue. |
Hello,
I've basically scoured the internet and the source codes, but couldn't find a way to exclude some URL patterns from being traced.
We use Otel bridge and zipkin exporter to get the trace data. Our use case is that there are a lot of traces regarding actuator, for both health and prometheus endpoints.
My question is that is there a way to exclude some URLs trace data being pushed to zipkin?
Thank you.
The text was updated successfully, but these errors were encountered: