Java 无法使用spring引导应用程序从Jaeger UI跟踪服务
无法在Jaeger UI(localhost:16686/search)上跟踪springboot应用程序的服务。在这里,我可以成功运行应用程序,但无法在jaeger ui中获取服务(defalut one jaeger查询除外) 我用docker cmd启动jaeger服务Java 无法使用spring引导应用程序从Jaeger UI跟踪服务,java,spring,spring-boot,rest,jaeger,Java,Spring,Spring Boot,Rest,Jaeger,无法在Jaeger UI(localhost:16686/search)上跟踪springboot应用程序的服务。在这里,我可以成功运行应用程序,但无法在jaeger ui中获取服务(defalut one jaeger查询除外) 我用docker cmd启动jaeger服务 docker run --rm -it --network=host jaegertracing/all-in-one 在上打开Jaeger UI } import org.springframework.beans.f
docker run --rm -it --network=host jaegertracing/all-in-one
在上打开Jaeger UI
}
import org.springframework.beans.factory.annotation.Autowired;
导入org.springframework.http.ResponseEntity;
导入org.springframework.web.bind.annotation.RequestMapping;
导入org.springframework.web.bind.annotation.RestController;
导入org.springframework.web.client.rest模板;
@RestController
公共类Hello控制器{
@自动连线
私有RestTemplate RestTemplate;
@请求映射(“/hello”)
公共字符串hello(){
返回“来自Spring Boot的你好!”;
}
@请求映射(“/chaining”)
公共字符串链接(){
ResponseEntity response=restTemplate.getForEntity(“http://localhost:8082/hello“,String.class);
返回“Chaining+”+response.getBody();
}
}
4.0.0
org.springframework.boot
带有演示的Github存储库:。
请帮助我解决此问题。问题在于,您的Jaeger收集器无法从docker网络主机外部访问,正如您在docker命令中指定的那样。只有当您的spring引导应用程序也部署在主机网络上时,这才有效。
尝试按如下方式运行Jaeger:
docker run -d --name jaeger \
-e COLLECTOR_ZIPKIN_HTTP_PORT=9411 \
-p 5775:5775/udp \
-p 6831:6831/udp \
-p 6832:6832/udp \
-p 5778:5778 \
-p 16686:16686 \
-p 14268:14268 \
-p 14250:14250 \
-p 9411:9411 \
jaegertracing/all-in-one:1.17
它应该会触发。问题在于,您在docker命令中指定的Jaeger收集器无法从外部docker网络主机访问。只有当您的spring引导应用程序也部署在主机网络上时,这才有效。
尝试按如下方式运行Jaeger:
docker run -d --name jaeger \
-e COLLECTOR_ZIPKIN_HTTP_PORT=9411 \
-p 5775:5775/udp \
-p 6831:6831/udp \
-p 6832:6832/udp \
-p 5778:5778 \
-p 16686:16686 \
-p 14268:14268 \
-p 14250:14250 \
-p 9411:9411 \
jaegertracing/all-in-one:1.17
它应该触发
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo_opentracing1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo_opentracing1</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-web-autoconfigure</artifactId>
<version>0.0.4</version>
</dependency>
<dependency>
<groupId>com.uber.jaeger</groupId>
<artifactId>jaeger-core</artifactId>
<version>0.18.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
docker run -d --name jaeger \
-e COLLECTOR_ZIPKIN_HTTP_PORT=9411 \
-p 5775:5775/udp \
-p 6831:6831/udp \
-p 6832:6832/udp \
-p 5778:5778 \
-p 16686:16686 \
-p 14268:14268 \
-p 14250:14250 \
-p 9411:9411 \
jaegertracing/all-in-one:1.17