import io.jaegertracing.Configuration;
import io.jaegertracing.Configuration.ReporterConfiguration;
import io.jaegertracing.Configuration.SamplerConfiguration;
import io.jaegertracing.internal.JaegerTracer;
import io.jaegertracing.internal.samplers.ConstSampler;
import io.opentracing.Span;
import io.opentracing.util.GlobalTracer;
...
SamplerConfiguration samplerConfig = SamplerConfiguration.fromEnv()
.withType(ConstSampler.TYPE)
.withParam(1);
ReporterConfiguration reporterConfig = ReporterConfiguration.fromEnv()
.withLogSpans(true);
Configuration config = new Configuration("helloWorld")
.withSampler(samplerConfig)
.withReporter(reporterConfig);
GlobalTracer.register(config.getTracer());
...
Span parent = GlobalTracer.get().buildSpan("hello").start();
try (Scope scope = GlobalTracer.get().scopeManager()
.activate(parent)) {
Span child = GlobalTracer.get().buildSpan("world")
.asChildOf(parent).start();
try (Scope scope = GlobalTracer.get().scopeManager()
.activate(child)) {
}
}
本页内容是否解决了您的问题?