使用Jaeger跟踪Java应用程序时出错

时间:2019-10-16 05:36:38

标签: opentracing jaeger

我有一个简单的Java应用程序,我想用Jaeger测试跟踪,但是遇到错误。

maven依赖-

        <dependency>
            <groupId>io.opentracing</groupId>
            <artifactId>opentracing-api</artifactId>
            <version>0.32.0</version>
        </dependency>
        <dependency>
            <groupId>io.jaegertracing</groupId>
            <artifactId>jaeger-client</artifactId>
            <version>1.0.0</version>
        </dependency>

jaeger多合一-

docker run -d --name jaeger \
    -e COLLECTOR_ZIPKIN_HTTP_PORT=9411 \
    -p 5775:5775/udp \
    -p 6831:6831/udp \
    -p 5778:5778 \
    -p 16686:16686 \
    -p 14268:14268 \
    -p 9411:9411 \
    jaegertracing/all-in-one:1.6

这是代码-

    public static void main(final String[] args) {

        System.setProperty(Configuration.JAEGER_SAMPLER_TYPE, ConstSampler.TYPE);
        System.setProperty(Configuration.JAEGER_SAMPLER_PARAM, "1");
        System.setProperty(Configuration.JAEGER_SERVICE_NAME, "test-1");

        Span span = Configuration.fromEnv().getTracer().buildSpan("test-hello").start();
        span.setTag("test-Tag", "test-value");

        span.log("test log");

        span.finish();

    }

我遇到错误-

INFO: Initialized tracer=JaegerTracer(version=Java-1.0.0, serviceName=test-1, reporter=RemoteReporter(sender=UdpSender(), closeEnqueueTimeout=1000), sampler=ConstSampler(decision=true, tags={sampler.type=const, sampler.param=true}), tags={hostname=ADURAI-mac, jaeger.version=Java-1.0.0, ip=192.168.1.3}, zipkinSharedRpcSpan=false, expandExceptionLogs=false, useTraceId128Bit=false)
Exception in thread "main" java.lang.AbstractMethodError: io.opentracing.util.ThreadLocalScopeManager.activeSpan()Lio/opentracing/Span;
    at io.jaegertracing.internal.JaegerTracer$SpanBuilder.start(JaegerTracer.java:440)
    at io.adurai.kafka.producer.Main.main(Main.java:44)

感谢任何帮助!

1 个答案:

答案 0 :(得分:1)

这是由于对直升机停机坪的依赖。

https://helidon.io/docs/latest/#/guides/03_quickstart-mp

我还必须将opentracing-api版本升级到0.33.0