spring-cloud starter如何添加标签或行李?
How to add tags or baggage with spring-cloud starter?
我正在尝试向 OpenTracing 跟踪添加标签或行李。我正在通过@Beans 创建跟踪器,但在使用 cloud-starter 附带的自动配置时无法弄清楚如何引用活动范围。
使用这个依赖项
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-cloud-starter</artifactId>
<version>0.2.4</version>
我试过了
tracer.activeSpan().setBaggageItem("baggage", "baggage");
还有这个
scope.span().setBaggageItem("baggage", "baggage");
两者都会导致 NPE。即使尝试记录 span 或 tracer 对象也会给我一个 NPE,所以我似乎不需要正确的模式来与之交互。
跟踪器的设置方法如下。
@Bean
public io.opentracing.Tracer jaegerTracer() {
SamplerConfiguration samplerConfig = SamplerConfiguration.fromEnv().withType("const").withParam(1);
SenderConfiguration senderConfig = SenderConfiguration.fromEnv().withEndpoint("http://jaeger:14268/api/traces");
ReporterConfiguration reporterConfig = ReporterConfiguration.fromEnv().withLogSpans(true).withSender(senderConfig);
Configuration config = new Configuration("eclipse-hawkular").withSampler(samplerConfig).withReporter(reporterConfig);
return config.getTracer();
}
更多信息...
查看定义跨度装饰器的 opentracing-spring-web-contrib code,这是我从中获取默认跨度和关联标签的地方。但是如果执行 restTemplate 是什么触发启动活动跨度的拦截,如何添加自定义 tag/baggage?我想我不应该直接与 spanDecorator 交互。
还有更多信息...
还尝试在使用opentracing-contrib-okhttp时添加行李。跟踪效果很好,但在使用基于拦截器的自动跟踪器时无法弄清楚如何添加 bagged。
现在可以用这条单线添加行李。
TracerResolver.resolveTracer().activeSpan().setBaggageItem("baggage", "adding baggage");
在此过程中也开始使用 Spring 2.0。9.RELEASE 和 OpenTracing 的单一依赖项,它使用 0.32 版本的 Jaeger 跟踪器。
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-jaeger-cloud-starter</artifactId>
<version>1.0.3</version>
</dependency>
我正在尝试向 OpenTracing 跟踪添加标签或行李。我正在通过@Beans 创建跟踪器,但在使用 cloud-starter 附带的自动配置时无法弄清楚如何引用活动范围。
使用这个依赖项
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-cloud-starter</artifactId>
<version>0.2.4</version>
我试过了
tracer.activeSpan().setBaggageItem("baggage", "baggage");
还有这个
scope.span().setBaggageItem("baggage", "baggage");
两者都会导致 NPE。即使尝试记录 span 或 tracer 对象也会给我一个 NPE,所以我似乎不需要正确的模式来与之交互。
跟踪器的设置方法如下。
@Bean
public io.opentracing.Tracer jaegerTracer() {
SamplerConfiguration samplerConfig = SamplerConfiguration.fromEnv().withType("const").withParam(1);
SenderConfiguration senderConfig = SenderConfiguration.fromEnv().withEndpoint("http://jaeger:14268/api/traces");
ReporterConfiguration reporterConfig = ReporterConfiguration.fromEnv().withLogSpans(true).withSender(senderConfig);
Configuration config = new Configuration("eclipse-hawkular").withSampler(samplerConfig).withReporter(reporterConfig);
return config.getTracer();
}
更多信息...
查看定义跨度装饰器的 opentracing-spring-web-contrib code,这是我从中获取默认跨度和关联标签的地方。但是如果执行 restTemplate 是什么触发启动活动跨度的拦截,如何添加自定义 tag/baggage?我想我不应该直接与 spanDecorator 交互。
还有更多信息...
还尝试在使用opentracing-contrib-okhttp时添加行李。跟踪效果很好,但在使用基于拦截器的自动跟踪器时无法弄清楚如何添加 bagged。
现在可以用这条单线添加行李。
TracerResolver.resolveTracer().activeSpan().setBaggageItem("baggage", "adding baggage");
在此过程中也开始使用 Spring 2.0。9.RELEASE 和 OpenTracing 的单一依赖项,它使用 0.32 版本的 Jaeger 跟踪器。
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-jaeger-cloud-starter</artifactId>
<version>1.0.3</version>
</dependency>