在春季引导应用程序(目前只有一个)中,我通过添加依赖项opentracing-spring-jaeger-web-starter和下面的bean来包含jaeger
@Bean
public static JaegerTracer getTracer() {
io.jaegertracing.Configuration.SamplerConfiguration samplerConfig =
io.jaegertracing.Configuration.SamplerConfiguration.fromEnv().withType("const").withParam(1);
io.jaegertracing.Configuration.ReporterConfiguration reporterConfig =
io.jaegertracing.Configuration.ReporterConfiguration.fromEnv().withLogSpans(true);
io.jaegertracing.Configuration config = new io.jaegertracing.Configuration("fooService").withSampler(samplerConfig).withReporter(reporterConfig);
return config.getTracer();
}
@PostConstruct
public void setProperty() {
System.setProperty("JAEGER_REPORTER_LOG_SPANS", "true");
}在码头docker run -d --name jaeger -p 16686:16686 -p 6831:6831/udp jaegertracing/all-in-one:1.9启动Jaeger之后,我得到了痕迹。
现在,我发现了另一个依赖项,并阅读了不同的教程,这使我不知如何才能正确地使用Jaeger进行spring引导。
我将使用哪个依赖项?
https://github.com/opentracing-contrib/java-spring-cloud
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-cloud-starter</artifactId>
</dependency>https://github.com/signalfx/tracing-examples/tree/master/jaeger-java-spring-boot-web
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-jaeger-web-starter</artifactId>
</dependency>跟踪Jaeger文档可能
<dependency>
<groupId>io.jaegertracing</groupId>
<artifactId>jaeger-client</artifactId>
<version>$jaegerVersion</version>
</dependency>就够了!?
在尝试Jaeger之前,我使用了Zipkin,这在Spring中非常容易集成,因为有一个侦探入门。日志在单独的字段中包含跟踪和span,因此可以在Kibana搜索它们。贾格做不。
可以定制吗?如果是的话?
是否有可能使用Jaeger和勇敢的仪器。例如,该项目将spring-cloud-starter-sleuth作为依赖项包括在内。与已经存在的bean有一些冲突。杰格能被勇敢地利用吗?
发布于 2020-11-26 21:49:03
在回答有关依赖关系的问题时,依赖项部分(https://github.com/opentracing-contrib/java-spring-jaeger)将在这里解释:
开放- Spring - Jaeger - web -初学者是一种方便的入门器,它既包括开放-Spring-Jaeger-启动器和开放-Spring- Web -启动器-这意味着通过包含它,简单的Web Spring启动微服务包括所有必要的依赖项来检测Web请求/响应并向Jaeger发送跟踪。 开放-弹簧
顺便说一句:
与:
发布于 2020-11-13 09:22:51
此链接(https://objectpartners.com/2019/04/25/distributed-tracing-with-apache-kafka-and-jaeger/)提供了如何启用jaeger跟踪的详细信息。
启用jaeger spring引导应用程序的最简单方法是添加依赖项和所需的属性。
依赖关系:
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-jaeger-web-starter</artifactId>
<version>3.2.0</version>
</dependency>示例属性
opentracing.jaeger.udp-sender.host=localhost
opentracing.jaeger.udp-sender.port=6831
opentracing.jaeger.const-sampler.decision=true
opentracing.jaeger.enabled=true
opentracing.jaeger.log-spans=true
opentracing.jaeger.service-name=ms-name发布于 2021-05-31 07:06:09
为了配置Jaeger,我们需要在每个服务中(在pom.xml中)添加Jaeger客户端的依赖性。
Jaeger客户端依赖性:
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-jaeger-web-starter</artifactId>
<version>3.2.0</version>
</dependency>在添加依赖项之后,我们需要在每个服务上添加Jaeger客户端配置。
@Configuration
public class JaegerConfig {
@Bean
public JaegerTracer jaegerTracer() {
return new io.jaegertracing.Configuration("jaeger-client")
.withSampler(new io.jaegertracing.Configuration.SamplerConfiguration().withType(ConstSampler.TYPE)
.withParam(1))
.withReporter(new io.jaegertracing.Configuration.ReporterConfiguration().withLogSpans(true))
.getTracer();
}
}我们也可以根据我们在Jaeger中使用的抽样策略来改变配置。你可以参考官方医生的取样策略。1:https://www.jaegertracing.io/docs/1.22/sampling/
安装后,Jaeger运行
docker run -d --名称jaeger -p 16686:16686 -p 6831:6831/udp标枪追踪/全合一:1.9
在端口16686上运行Jaeger。
https://stackoverflow.com/questions/63407052
复制相似问题