opentracing-contrib / java-spring-jaeger

Apache License 2.0
255 stars 95 forks source link

spring boot version 3.0.0 not working with jaeger #146

Open prasad5252 opened 1 year ago

prasad5252 commented 1 year ago

i am using jaeger with spring boot version 3.0.0 and java version 17 but unable to discover any services that registered with jaeger UI, is there version issue ? jaeger doen't support spring boot 3.0.0 ?

onyn commented 1 year ago

Spring boot 3.0 removes support of spring.factories.

As temporary workaround you may create plain text file META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports and put io.opentracing.contrib.java.spring.jaeger.starter.JaegerAutoConfiguration into it.

tweetysat commented 1 year ago

I'm using spring boot 3.0.0 and

    <dependency>
        <groupId>io.opentracing.contrib</groupId>
        <artifactId>opentracing-spring-jaeger-web-starter</artifactId>
        <version>3.3.1</version>
    </dependency>

As @onyn suggested I tried adding that file in my project but it is not working.

The only way I found to have something happening is to add

@Component
public class JaegerConfiguration {

    @Bean
    public static JaegerTracer jaegerTracer(
            @Value("${spring.application.name}") String serviceName
    ) {
        return new Configuration(serviceName)
                .withSampler(new io.jaegertracing.Configuration.SamplerConfiguration().withType(ConstSampler.TYPE).withParam(1))
                .withReporter(new io.jaegertracing.Configuration.ReporterConfiguration().withLogSpans(true))
                .getTracer();
    }

}

Now I can see

2023-02-01T11:59:30.120+01:00  INFO 12392 --- [  restartedMain] io.jaegertracing.Configuration           : Initialized tracer=JaegerTracer(version=Java-1.3.2, serviceName=mailbox-dispatcher, reporter=CompositeReporter(reporters=[RemoteReporter(sender=UdpSender(host=localhost, port=6831), closeEnqueueTimeout=1000), LoggingReporter(logger=Logger[io.jaegertracing.internal.reporters.LoggingReporter])]), sampler=ConstSampler(decision=true, tags={sampler.type=const, sampler.param=true}), tags={hostname=xxx, jaeger.version=Java-1.3.2, ip=xxx}, zipkinSharedRpcSpan=false, expandExceptionLogs=false, useTraceId128Bit=false)

BUT .... I don't konw how to use a http-sender in place of a udp-sender and change the url.

I tried adding

opentracing:
  jaeger:
    enabled: true
    http-sender:
      url: http://myurl:14268/api/traces

But it always tells me reporter=CompositeReporter(reporters=[RemoteReporter(sender=UdpSender(host=localhost, port=6831)

akshayrana30 commented 1 year ago

Can also use this in one of the config classes.

@ImportAutoConfiguration(io.opentracing.contrib.java.spring.jaeger.starter.JaegerAutoConfiguration.class)
kayeanni commented 1 year ago

I am facing the same problem, were you able to make it work?

onyn commented 1 year ago

@kayeanni, switch from jaeger to micrometer tracing. This is best solution in long term.

See also https://github.com/opentracing-contrib/java-spring-jaeger/pull/148#issuecomment-1548497689