Skip to content
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

SpanHandler end callback returned false still flushed to Zipkin / Jaeger #1339

Open
DarthJonathan opened this issue Aug 5, 2022 · 1 comment
Labels

Comments

@DarthJonathan
Copy link

Describe the Bug

I just realized either I'm implementing it wrongly or not because in the example of SpanHandler

tracingBuilder.addSpanHandler(new SpanHandler() { @OverRide public boolean end(TraceContext context, MutableSpan span, Cause cause) { return !"comment".equals(span.name()); } });

If returned false it should not be reported in Zipkin / Jaeger right.

does not work, not dropping the span and when I debug I saw
spanHandler.end(last.handlerContext, last.span, Cause.FINISHED);

It is not being handled just flushed, was there any changes in the library and this documentation is outdated? Thanks

Steps to Reproduce

Steps to reproduce the behavior:

Create a bean of SpanHandler or implement TracingCustomizer for TracingFactoryBean.

Make the end callback returned false.

Check in Zipkin / Jaeger collector if the span still being collected.

Expected Behaviour

Suggest what you think correct behaviour should be. Note, it may be solved differently depending on the problem.

Based on the example the span should be dropped / abandoned.

@RossZhang-cpu
Copy link

Hi Jonathan, It seems work fine during my test, Not sure if is the different implemtation so I post here for reference.
public class CustomSpanHandler extends SpanHandler {
@OverRide
public boolean end(TraceContext context, MutableSpan span, Cause cause) {
return !"comment".equals(span.name());
}
}

@bean
Tracing tracing(@value("${brave.localServiceName:${spring.application.name}}") String serviceName,
SpanHandler zipkinSpanHandler){
return Tracing.newBuilder()
.currentTraceContext(ThreadLocalCurrentTraceContext.create())
.localServiceName(serviceName)
.addSpanHandler(zipkinSpanHandler)
.build();
}

After that I checked in Zipkin UI site, this span don't display there. If anything wrong, please corret it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants