标签: spring-cloud-sleuth

侦探日志traceId未传播到另一个服务

我尝试在我的微服务中添加分布式跟踪(在Azure的Kubernetes下)。

我在父pom.xml中添加了依赖项:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.1.RELEASE</version>
    <relativePath/>
</parent>
<dependencies>
    {...}
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-sleuth-core</artifactId>
        <version>1.1.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-sleuth-zipkin</artifactId>
        <version>1.1.3.RELEASE</version>
    </dependency>
</dependencies>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>CAMDEN.SR4</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        {...}
    </dependencies>
</dependencyManagement>
Run Code Online (Sandbox Code Playgroud)

我使用1.4.1和CAMDEN.SR4,因为fabric8 kubeflix不支持较新的版本。我强迫1.1.3.RELEASE尝试最新的侦探版本,以查看它是否是较早版本的侦探中的错误。

我使用logback-spring.xml的此配置:

<configuration>
    <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
    <springProperty scope="context" name="springAppName" source="spring.application.name"/>
    <jmxConfigurator/>
    <property name="CONSOLE_LOG_PATTERN"
          value="%d{yyyy-MM-dd HH:mm:ss.SSS} [${springAppName},%X{X-B3-TraceId:-},%X{X-B3-SpanId:-},%X{X-Span-Export:-}] [%thread] %-5level %logger{35} - %msg%n"/>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>${CONSOLE_LOG_PATTERN}</pattern>
        </encoder>
    </appender>
    <root level="DEBUG">
        <appender-ref ref="STDOUT"/>
    </root>
    <logger name="org.springframework" level="ERROR"/>
    <logger name="com.netflix" level="ERROR"/>
    <logger name="io.fabric8" level="ERROR"/>
    <logger name="org.apache" level="ERROR"/>
</configuration>
Run Code Online (Sandbox Code Playgroud)

这是我的application.yml: …

java spring zipkin spring-cloud-sleuth

2
推荐指数
1
解决办法
2574
查看次数

使用 Spring Cloud Sleuth 将跟踪数据发送到 OpenZIpkin

更新:我已将代码推送到我的存储库中,以便人们可以查看那里以了解可能出了什么问题。

编辑:我几乎可以肯定是客户端代码没有将任何统计信息发布到服务器,但是下面的指南都没有解释应该如何启用它:是否有我缺少的配置设置?

我一直在关注OpenZipkinSpring Sleuth的快速入门:我有一个来自docker-zipkin的正在运行的 Zipkin 服务器,使用docker-composeCassandra 作为后端:

$ d ps
CONTAINER ID        IMAGE                                COMMAND                  CREATED             STATUS              PORTS                                                                               NAMES
5ca0f0b29900        openzipkin/zipkin:1.12.1             "/bin/sh -c 'test -n "   14 minutes ago      Up 8 minutes        0.0.0.0:9410-9411->9410-9411/tcp                                                    zipkin
7b243a0b61e3        openzipkin/zipkin-dependencies       "crond -f"               14 minutes ago      Up 8 minutes                                                                                            dependencies
e2e047fb3851        openzipkin/zipkin-cassandra:1.12.1   "/bin/sh -c /usr/loca"   14 minutes ago      Up 8 minutes        7000-7001/tcp, 0.0.0.0:3306->3306/tcp, 7199/tcp, 0.0.0.0:9042->9042/tcp, 9160/tcp   cassandra
Run Code Online (Sandbox Code Playgroud)

我已经创建并运行了Spring Sleuth 示例应用程序,它似乎已正确配置以跟踪调用: …

spring zipkin spring-cloud-sleuth

1
推荐指数
1
解决办法
5214
查看次数

Sleuth 不显示跟踪 ID 和跨度 ID

我正在尝试运行 Spring Boot 应用程序并在 Sleuth 的支持下跟踪其执行情况。日志显示服务名称,但没有显示跟踪 ID 或跨度 ID。我得到的只是 [myservice,,,]。

我错过了什么?

以下是日志中的一些行。

2017-04-30 14:41:38.750 INFO [myservice,,,] 7 --- [main] scaAnnotationConfigApplicationContext:刷新 org.springframework.context.annotation.AnnotationConfigApplicationContext@5e57643e:启动日期 [4 月 30 日星期日:184:44]格林威治标准时间 2017];上下文层次结构的根

2017-04-30 14:41:39.264 INFO [myservice,,,] 7 --- [main] faAutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' 注释被发现并支持自动装配

...

谢谢

spring-boot spring-cloud-sleuth

1
推荐指数
1
解决办法
3673
查看次数

Spring sleuth 中的 WebClient 检测

我想知道侦探是否支持反应式 WebClient 检测。

我没有从文档中找到它:

检测 Spring 应用程序的常见入口和出口点(servlet 过滤器、异步端点、休息模板、计划操作、消息通道、Zuul 过滤器和 Feign 客户端)。

我的情况:

我可以在 WebFilter 或我的其余资源中使用 WebClient 来生成 Mono。

而且我要:

  • 自动创建为根跨度的子跨度的子跨度
  • 通过标头传播的跟踪信息

如果目前不支持检测,我是否应该从上下文中手动获取跨度并像这样自己完成:

反应式 WebClient 上的 OpenTracing 检测

谢谢

莱昂

spring-cloud-sleuth

1
推荐指数
1
解决办法
1737
查看次数

如何获取log4j2中的trace id和span id,格式为[traceId, spanId]?

如何在 log4j2 中获取跟踪 id 和 span id,而不是在 [traceId, spanId ] 中?

预期输出:[APPNAME,5a59b2372d9a3814,5a59b2372d9a3814]

实际输出: [logLevel=ERROR] -- 2021-01-21 11:30:32,489 +0530 -- http-nio-8080-exec-1 com.springboot.test.aspect.MyAspect -- asnId= - message="记录密钥:”,traceId=f19556b82d98bf86,executionTimeSeconds=23

我的 log4j2 :尝试添加下面的注释属性,但在日志中没有看到跟踪 ID


        <Property name="LOG_PATTERN">[logLevel=%-5p] -- %d %d{Z} -- %t %c -- asnId=%X{ASN} - %m%n</Property>
        <property name="log.level">${bundle:DEV:logLevel}</property>
         <!--  <property name="rolling.file.encoder.pattern"
              value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ} %-5level : loggerName=&quot;%logger{36}&quot; threadName=&quot;%thread&quot;  appName=&quot;${springAppName:-}&quot; trace=&quot;%X{X-B3-TraceId:-}&quot; span=&quot;%X{X-B3-SpanId:-}&quot; spanName=&quot;%X{X-Span-Name:-}&quot; parent=&quot;%X{X-B3-ParentSpanId:-}&quot; exportable=&quot;%X{X-Span-Export:-}&quot; pid=&quot;${PID:-}&quot; txnId=&quot;%X{txnId}&quot; %msg%n"/> -->
         <!--   <property name="PATTERN" value="%h %l %u [%date{dd/MMM/yyyy:HH:mm:ss.SSS}] &quot;%r&quot; %s %b &quot; &quot;%i{User-Agent}&quot; [trace=%responseHeader{X-B3-TraceId},span=%i{X-B3-SpanId}] %D"/> -->
    </Properties>
Run Code Online (Sandbox Code Playgroud)

方面类:

但是,在我的 Aspect …

java spring trace spring-boot spring-cloud-sleuth

1
推荐指数
1
解决办法
9612
查看次数

使用 sping cloud sleuth 时如何处理构建错误?

我正在开发一个使用 java 消息服务(JMS)的项目,并且它使用 activemq 连接工厂实现。现在我想用它spring-cloud-starter-sleuth来检测应用程序以进行跟踪。但我无法做到这一点,因为我在启动应用程序时遇到以下异常 -

org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.activemq.pool.PooledConnectionFactory]: Factory method 'pooledConnectionFactory' threw exception; nested exception is java.lang.IllegalStateException: @Bean method JmsConfiguration.senderActiveMQConnectionFactory called as bean reference for type [org.apache.activemq.ActiveMQConnectionFactory] but overridden by non-compatible bean instance of type [org.springframework.cloud.sleuth.instrument.messaging.LazyTopicConnectionFactory]. Overriding bean of same name declared in: class path resource [com/demo/appconfig/JmsConfiguration.class]
Run Code Online (Sandbox Code Playgroud)

以下是我使用的连接工厂 bean:

// ***** sender configuration
    @Bean
    public ActiveMQConnectionFactory senderActiveMQConnectionFactory() {
        ActiveMQConnectionFactory activeMQConnectionFactory =
                new ActiveMQConnectionFactory();
        activeMQConnectionFactory.setBrokerURL(brokerUrl);
        activeMQConnectionFactory.setUseAsyncSend(useAsyncSend);
        return activeMQConnectionFactory;
    }  

 @Bean
    public PooledConnectionFactory pooledConnectionFactory() {
        return new …
Run Code Online (Sandbox Code Playgroud)

spring spring-jms zipkin spring-boot spring-cloud-sleuth

1
推荐指数
1
解决办法
1046
查看次数