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

Trace Span logs not appended to the loggers #318

Open
rajesh-giriyappa opened this issue Feb 7, 2021 · 2 comments
Open

Trace Span logs not appended to the loggers #318

rajesh-giriyappa opened this issue Feb 7, 2021 · 2 comments

Comments

@rajesh-giriyappa
Copy link

HI,

Trace Logs are not appended in the logger file below is my configurations

opentracing.spring.web.client.enabled=true
opentracing.spring.cloud.log.enable=true
opentracing.zipkin.enabled=true
opentracing.zipkin.http-sender.url=http://localhost:9411
opentracing.zipkin.counting-sampler.rate=1.0

@bean
public io.opentracing.Tracer globalTracer(){

    zipkin2.reporter.okhttp3.OkHttpSender okHttpSender = zipkin2.reporter.okhttp3.OkHttpSender.newBuilder()
            .encoding(Encoding.JSON)
            .endpoint("http://localhost:9411/api/v2/spans")
            .build();

    //zipkin2.reporter.brave.AsyncZipkinSpanHandler handler = zipkin2.reporter.brave.AsyncZipkinSpanHandler.create(okHttpSender);
    AsyncReporter<Span> reporter = AsyncReporter.builder(okHttpSender).build();

    brave.Tracing braveTracer = Tracing.newBuilder()
            .localServiceName(serviceName)
            .spanReporter(reporter)
            .addSpanHandler(new Log4jSpanHandler())
            .traceId128Bit(true)
            .sampler(Sampler.ALWAYS_SAMPLE)
            .build();
    return BraveTracer.create(braveTracer);
}

Above is my configurations the Spans are getting reported into Zipkin but those are not appended in the SLF4J Logs

Please could you let me know what setting need to be done to span logs append working...

Regards,
Rajesh Giriyappa

@rafis
Copy link

rafis commented Jan 23, 2023

By default JaegerTracer created with ThreadLocalScopeManager, but Logback seems require MDCScopeManager to work. You can change that with customizer:

@Configuration
public class JaegerTracerConfig {

    @Bean
    public TracerBuilderCustomizer scopeManagerCustomizer() {
        return builder -> builder.withScopeManager(new MDCScopeManager.Builder().build());
    }
}

I don't know how this will affect Spring Cloud tracing through...

@rafis
Copy link

rafis commented Jan 24, 2023

@rajesh-giriyappa please try my solution

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

No branches or pull requests

2 participants