【问题标题】:Tracing Spring Boot Micro services with Jaeger deployed on AKS使用部署在 AKS 上的 Jaeger 跟踪 Spring Boot 微服务
【发布时间】:2018-11-06 13:20:44
【问题描述】:

我在 Azure Kubernetes 集群中的监控命名空间中设置了 Jaeger,并部署了我的容器,该容器在监控域中使用 jaeger 客户端库进行了检测。该服务已启动并正在运行,当我在浏览器中指定 :/actuator 时,我可以使用执行器查看跟踪。但是 Jaeger UI 的服务下拉列表中没有填充相同的微服务。

以下是我正在使用的文件。

DemoOpentracingApplication.java

        @SpringBootApplication
        public class DemoOpentracingApplication {
            @Bean
            public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {

                return restTemplateBuilder.build();
            }

            @Bean
            public io.opentracing.Tracer jaegerTracer() {
                return new Configuration("spribng-boot", new Configuration.SamplerConfiguration(ProbabilisticSampler.TYPE, 1),
                        new Configuration.ReporterConfiguration()).getTracer();
            }

            public static void main(String[] args) {
                SpringApplication.run(DemoOpentracingApplication.class, args);
            }
        }


    HelloController.java

    @RestController
    public class HelloController {

        @Autowired
        private RestTemplate restTemplate;


        //private final Counter totalRequests= Counter.build().name("requests_total").help("Total Number of Requests").register();

        @Timed(
                value= "prometheus.hello.request",
                histogram=true,
                percentiles= {0.95,0.99},
                extraTags= {"version","1.0"}
                )
        @RequestMapping("/hello")
        public String hello() {

            return ("Hello From OPenTracing Controller");
        }

        @Timed(
                value= "prometheus.chain.request",
                histogram=true,
                percentiles= {0.95,0.99},
                extraTags= {"version","1.0"}
                )
        @RequestMapping("/chaining")
        public String chaining() {
            ResponseEntity<String> response = restTemplate.getForEntity("http://localhost:8080/hello",String.class);
            return "Chaining+" + response.getBody();
        }
    }


POM.xml
.....
<dependency>
            <groupId>io.opentracing.contrib</groupId>
            <artifactId>opentracing-spring-web-autoconfigure</artifactId>
            <version>0.0.4</version>
        </dependency>
....

为什么检测服务没有填充到 Kubernetes 的 Jaeger UI 中?

【问题讨论】:

    标签: azure-aks opentracing jaeger distributed-tracing


    【解决方案1】:

    您可以通过将选项JAEGER_REPORTER_LOG_SPANS设置为true来打开客户端的调试(或使用ReporterConfiguration中的相关选项,因为您似乎就是这样使用它的)。

    https://www.jaegertracing.io/docs/1.8/client-features/

    确认正在生成跟踪并将其发送到代理后,将代理中的日志级别设置为debug

    docker run -p... jaegertracing/jaeger-agent:1.8 --log-level=debug

    如果您在日志中没有看到任何表明代理收到跨度(或跨度批次)的信息,那么您可能需要使用代理的地址(JAEGER_AGENT_HOSTJAEGER_AGENT_PORT,或相关Configuration 对象中的选项)。

    您提到您在 Azure AKS 中进行部署,因此,我猜想代理在 localhost 不可用,这是客户端发送跨度的默认位置。通常,在这种情况下,代理会被部署为边车:

    https://github.com/jaegertracing/jaeger-kubernetes#deploying-the-agent-as-sidecar

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-17
      • 2021-04-28
      • 1970-01-01
      • 2022-11-07
      • 1970-01-01
      相关资源
      最近更新 更多