Closed lrwh closed 1 year ago
本地采用对应版本的代码尝试,结果如下
无法复现问题。
初步推断,可能是跟客户框架有关,具体还需要进一步研究。
通过 mvn dependency:tree
得到客户的项目依赖情况
[INFO] Building admin-api 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:3.1.2:tree (default-cli) @ admin-api ---
[INFO] com.dianliantech.agriculture.admin:admin-api:jar:1.0.0
[INFO] +- com.dianliantech.agriculture:service:jar:1.0.0:compile
[INFO] +- com.lowagie:itext:jar:2.1.7:compile
[INFO] | +- bouncycastle:bcmail-jdk14:jar:138:compile
[INFO] | +- bouncycastle:bcprov-jdk14:jar:138:compile
[INFO] | \- org.bouncycastle:bctsp-jdk14:jar:1.38:compile
[INFO] | +- org.bouncycastle:bcprov-jdk14:jar:1.38:compile
[INFO] | \- org.bouncycastle:bcmail-jdk14:jar:1.38:compile
[INFO] +- org.apache.lucene:lucene-core:jar:8.8.2:compile
[INFO] +- org.apache.lucene:lucene-queryparser:jar:8.8.2:compile
[INFO] | +- org.apache.lucene:lucene-queries:jar:8.8.2:compile
[INFO] | \- org.apache.lucene:lucene-sandbox:jar:8.8.2:compile
[INFO] +- org.apache.lucene:lucene-analyzers-common:jar:8.8.2:compile
[INFO] +- org.apache.lucene:lucene-highlighter:jar:8.8.2:compile
[INFO] | \- org.apache.lucene:lucene-memory:jar:8.8.2:compile
[INFO] +- org.apache.lucene:lucene-analyzers-smartcn:jar:8.8.2:compile
[INFO] +- de.codecentric:spring-boot-admin-starter-client:jar:2.4.1:compile
[INFO] | \- de.codecentric:spring-boot-admin-client:jar:2.4.1:compile
[INFO] +- org.springframework.boot:spring-boot-starter-security:jar:2.4.4:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.4.4:compile
[INFO] | | +- org.springframework.boot:spring-boot:jar:2.4.4:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:2.4.4:compile
[INFO] | | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.13.3:compile
[INFO] | | | | \- org.apache.logging.log4j:log4j-api:jar:2.13.3:compile
[INFO] | | | \- org.slf4j:jul-to-slf4j:jar:1.7.5:compile
[INFO] | | \- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
[INFO] | +- org.springframework:spring-aop:jar:5.3.5:compile
[INFO] | | \- org.springframework:spring-beans:jar:5.3.5:compile
[INFO] | +- org.springframework.security:spring-security-config:jar:5.4.5:compile
[INFO] | | \- org.springframework.security:spring-security-core:jar:5.4.5:compile
[INFO] | \- org.springframework.security:spring-security-web:jar:5.4.5:compile
[INFO] | \- org.springframework:spring-expression:jar:5.3.5:compile
[INFO] +- org.jolokia:jolokia-core:jar:1.6.2:compile
[INFO] | \- com.googlecode.json-simple:json-simple:jar:1.1.1:compile
[INFO] +- io.micrometer:micrometer-registry-prometheus:jar:1.6.6:compile
[INFO] | +- io.micrometer:micrometer-core:jar:1.6.6:compile
[INFO] | | +- org.hdrhistogram:HdrHistogram:jar:2.1.12:compile
[INFO] | | \- org.latencyutils:LatencyUtils:jar:2.0.3:runtime
[INFO] | \- io.prometheus:simpleclient_common:jar:0.9.0:compile
[INFO] | \- io.prometheus:simpleclient:jar:0.9.0:compile
[INFO] +- commons-fileupload:commons-fileupload:jar:1.3.1:compile
[INFO] | \- commons-io:commons-io:jar:2.2:compile
[INFO] +- com.google.zxing:core:jar:3.2.0:compile
[INFO] +- com.google.zxing:javase:jar:3.2.0:compile
[INFO] +- net.sf.barcode4j:barcode4j:jar:2.1:compile
[INFO] | +- avalon-framework:avalon-framework-impl:jar:4.2.0:compile
[INFO] | +- commons-cli:commons-cli:jar:1.0:compile
[INFO] | \- org.apache.ant:ant:jar:1.7.1:compile
[INFO] | \- org.apache.ant:ant-launcher:jar:1.7.1:compile
[INFO] +- net.sourceforge.barbecue:barbecue:jar:1.5-beta1:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.5.7:compile
[INFO] | \- org.apache.httpcomponents:httpcore:jar:4.4.14:compile
[INFO] +- org.springframework.boot:spring-boot-configuration-processor:jar:2.4.4:compile (optional)
[INFO] +- org.springframework.boot:spring-boot-starter-data-redis:jar:2.4.4:compile
[INFO] | \- org.springframework.data:spring-data-redis:jar:2.4.6:compile
[INFO] | +- org.springframework.data:spring-data-keyvalue:jar:2.4.6:compile
[INFO] | | \- org.springframework.data:spring-data-commons:jar:2.4.6:compile
[INFO] | +- org.springframework:spring-tx:jar:5.3.5:compile
[INFO] | \- org.springframework:spring-oxm:jar:5.3.5:compile
[INFO] +- redis.clients:jedis:jar:3.3.0:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.5:compile
[INFO] +- org.apache.commons:commons-pool2:jar:2.9.0:compile
[INFO] +- org.redisson:redisson:jar:3.10.1:compile
[INFO] | +- io.netty:netty-common:jar:4.1.60.Final:compile
[INFO] | +- io.netty:netty-codec:jar:4.1.60.Final:compile
[INFO] | +- io.netty:netty-buffer:jar:4.1.60.Final:compile
[INFO] | +- io.netty:netty-transport:jar:4.1.60.Final:compile
[INFO] | | \- io.netty:netty-resolver:jar:4.1.60.Final:compile
[INFO] | +- io.netty:netty-resolver-dns:jar:4.1.60.Final:compile
[INFO] | | \- io.netty:netty-codec-dns:jar:4.1.60.Final:compile
[INFO] | +- io.netty:netty-handler:jar:4.1.60.Final:compile
[INFO] | +- javax.cache:cache-api:jar:1.1.1:compile
[INFO] | +- io.projectreactor:reactor-core:jar:3.4.4:compile
[INFO] | | \- org.reactivestreams:reactive-streams:jar:1.0.3:compile
[INFO] | +- io.reactivex.rxjava2:rxjava:jar:2.2.21:compile
[INFO] | +- de.ruedigermoeller:fst:jar:2.56:compile
[INFO] | | \- org.javassist:javassist:jar:3.21.0-GA:compile
[INFO] | +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.11.4:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.11.4:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.11.4:compile
[INFO] | +- net.bytebuddy:byte-buddy:jar:1.10.22:compile
[INFO] | \- org.jodd:jodd-bean:jar:3.7.1:compile
[INFO] | \- org.jodd:jodd-core:jar:3.7.1:compile
[INFO] +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.4.4:compile
[INFO] | +- com.zaxxer:HikariCP:jar:3.4.5:compile
[INFO] | \- org.springframework:spring-jdbc:jar:5.3.5:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.4.4:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-json:jar:2.4.4:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.11.4:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.11.4:compile
[INFO] | | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.11.4:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.4.4:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.44:compile
[INFO] | | +- org.glassfish:jakarta.el:jar:3.0.3:compile
[INFO] | | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.44:compile
[INFO] | +- org.springframework:spring-web:jar:5.3.5:compile
[INFO] | \- org.springframework:spring-webmvc:jar:5.3.5:compile
[INFO] +- org.springframework.boot:spring-boot-starter-aop:jar:2.4.4:compile
[INFO] | \- org.aspectj:aspectjweaver:jar:1.9.6:compile
[INFO] +- com.baomidou:mybatis-plus-boot-starter:jar:3.4.0:compile
[INFO] | +- com.baomidou:mybatis-plus:jar:3.4.0:compile
[INFO] | \- org.springframework.boot:spring-boot-autoconfigure:jar:2.4.4:compile
[INFO] +- mysql:mysql-connector-java:jar:8.0.21:compile
[INFO] +- com.alibaba:druid-spring-boot-starter:jar:1.2.1:compile
[INFO] | \- com.alibaba:druid:jar:1.2.1:compile
[INFO] +- org.apache.shiro:shiro-spring:jar:1.7.0:compile
[INFO] | +- org.apache.shiro:shiro-core:jar:1.7.0:compile
[INFO] | | +- org.apache.shiro:shiro-lang:jar:1.7.0:compile
[INFO] | | +- org.apache.shiro:shiro-cache:jar:1.7.0:compile
[INFO] | | +- org.apache.shiro:shiro-crypto-hash:jar:1.7.0:compile
[INFO] | | | \- org.apache.shiro:shiro-crypto-core:jar:1.7.0:compile
[INFO] | | +- org.apache.shiro:shiro-crypto-cipher:jar:1.7.0:compile
[INFO] | | +- org.apache.shiro:shiro-config-core:jar:1.7.0:compile
[INFO] | | +- org.apache.shiro:shiro-config-ogdl:jar:1.7.0:compile
[INFO] | | \- org.apache.shiro:shiro-event:jar:1.7.0:compile
[INFO] | \- org.apache.shiro:shiro-web:jar:1.7.0:compile
[INFO] | \- org.owasp.encoder:encoder:jar:1.2.2:compile
[INFO] +- io.jsonwebtoken:jjwt:jar:0.9.1:compile
[INFO] +- commons-lang:commons-lang:jar:2.6:compile
[INFO] +- com.alibaba:fastjson:jar:1.2.76:compile
[INFO] +- io.springfox:springfox-swagger2:jar:2.9.2:compile
[INFO] | +- io.springfox:springfox-spi:jar:2.9.2:compile
[INFO] | | \- io.springfox:springfox-core:jar:2.9.2:compile
[INFO] | +- io.springfox:springfox-schema:jar:2.9.2:compile
[INFO] | +- io.springfox:springfox-swagger-common:jar:2.9.2:compile
[INFO] | +- io.springfox:springfox-spring-web:jar:2.9.2:compile
[INFO] | +- com.google.guava:guava:jar:20.0:compile
[INFO] | +- com.fasterxml:classmate:jar:1.5.1:compile
[INFO] | +- org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile
[INFO] | +- org.springframework.plugin:spring-plugin-metadata:jar:1.2.0.RELEASE:compile
[INFO] | \- org.mapstruct:mapstruct:jar:1.2.0.Final:compile
[INFO] +- io.swagger:swagger-annotations:jar:1.5.21:compile
[INFO] +- io.swagger:swagger-models:jar:1.5.21:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.11.4:compile
[INFO] +- com.github.xiaoymin:swagger-bootstrap-ui:jar:1.9.3:compile
[INFO] +- org.projectlombok:lombok:jar:1.18.18:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.4.4:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:2.4.4:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.4.4:test
[INFO] | +- com.jayway.jsonpath:json-path:jar:2.4.0:test
[INFO] | | \- net.minidev:json-smart:jar:2.3:test
[INFO] | | \- net.minidev:accessors-smart:jar:1.2:test
[INFO] | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:compile
[INFO] | | \- jakarta.activation:jakarta.activation-api:jar:1.2.2:compile
[INFO] | +- org.assertj:assertj-core:jar:3.18.1:test
[INFO] | +- org.hamcrest:hamcrest:jar:2.2:test
[INFO] | +- org.junit.jupiter:junit-jupiter:jar:5.7.1:test
[INFO] | | +- org.junit.jupiter:junit-jupiter-api:jar:5.7.1:test
[INFO] | | | +- org.apiguardian:apiguardian-api:jar:1.1.0:test
[INFO] | | | +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] | | | \- org.junit.platform:junit-platform-commons:jar:1.7.1:test
[INFO] | | +- org.junit.jupiter:junit-jupiter-params:jar:5.7.1:test
[INFO] | | \- org.junit.jupiter:junit-jupiter-engine:jar:5.7.1:test
[INFO] | | \- org.junit.platform:junit-platform-engine:jar:1.7.1:test
[INFO] | +- org.mockito:mockito-junit-jupiter:jar:3.6.28:test
[INFO] | +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO] | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] | +- org.springframework:spring-core:jar:5.3.5:compile
[INFO] | | \- org.springframework:spring-jcl:jar:5.3.5:compile
[INFO] | +- org.springframework:spring-test:jar:5.3.5:test
[INFO] | \- org.xmlunit:xmlunit-core:jar:2.7.0:test
[INFO] +- org.springframework.boot:spring-boot-starter-mail:jar:2.4.4:compile
[INFO] | +- org.springframework:spring-context-support:jar:5.3.5:compile
[INFO] | \- com.sun.mail:jakarta.mail:jar:1.6.6:compile
[INFO] | \- com.sun.activation:jakarta.activation:jar:1.2.2:compile
[INFO] +- net.sf.json-lib:json-lib:jar:jdk15:2.4:compile
[INFO] | +- commons-beanutils:commons-beanutils:jar:1.8.0:compile
[INFO] | +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] | +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] | \- net.sf.ezmorph:ezmorph:jar:1.0.6:compile
[INFO] +- com.baomidou:mybatis-plus-generator:jar:3.4.0:compile
[INFO] | \- com.baomidou:mybatis-plus-extension:jar:3.4.0:compile
[INFO] | +- com.baomidou:mybatis-plus-core:jar:3.4.0:compile
[INFO] | | +- com.baomidou:mybatis-plus-annotation:jar:3.4.0:compile
[INFO] | | +- com.github.jsqlparser:jsqlparser:jar:3.2:compile
[INFO] | | \- org.mybatis:mybatis:jar:3.5.5:compile
[INFO] | \- org.mybatis:mybatis-spring:jar:2.0.5:compile
[INFO] +- org.springframework.boot:spring-boot-starter-freemarker:jar:2.3.0.RELEASE:compile
[INFO] | \- org.freemarker:freemarker:jar:2.3.31:compile
[INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:2.4.4:compile
[INFO] | \- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:2.4.4:compile
[INFO] | \- org.springframework.boot:spring-boot-actuator:jar:2.4.4:compile
[INFO] +- com.github.tobato:fastdfs-client:jar:1.27.2:compile
[INFO] | +- org.slf4j:jcl-over-slf4j:jar:1.7.5:compile
[INFO] | +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] | | \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] | +- org.apache.commons:commons-lang3:jar:3.11:compile
[INFO] | +- org.hibernate.validator:hibernate-validator:jar:6.1.7.Final:compile
[INFO] | | +- jakarta.validation:jakarta.validation-api:jar:2.0.2:compile
[INFO] | | \- org.jboss.logging:jboss-logging:jar:3.4.1.Final:compile
[INFO] | +- org.springframework:spring-context:jar:5.3.5:compile
[INFO] | \- net.coobird:thumbnailator:jar:0.4.8:compile
[INFO] +- cn.hutool:hutool-all:jar:5.5.7:compile
[INFO] +- org.testng:testng:jar:7.3.0:test
[INFO] | +- com.beust:jcommander:jar:1.78:test
[INFO] | +- junit:junit:jar:4.12:test
[INFO] | | \- org.hamcrest:hamcrest-core:jar:2.2:test
[INFO] | +- com.google.inject:guice:jar:no_aop:4.2.2:test
[INFO] | | +- javax.inject:javax.inject:jar:1:compile
[INFO] | | \- aopalliance:aopalliance:jar:1.0:test
[INFO] | \- org.yaml:snakeyaml:jar:1.27:compile
[INFO] +- cn.afterturn:easypoi-spring-boot-starter:jar:4.3.0:compile
[INFO] | \- cn.afterturn:easypoi-web:jar:4.3.0:compile
[INFO] | \- cn.afterturn:easypoi-base:jar:4.3.0:compile
[INFO] | +- ognl:ognl:jar:3.2.6:compile
[INFO] | +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] | \- cn.afterturn:easypoi-annotation:jar:4.3.0:compile
[INFO] +- com.github.ulisesbocchio:jasypt-spring-boot-starter:jar:2.1.2:compile
[INFO] | \- com.github.ulisesbocchio:jasypt-spring-boot:jar:2.1.2:compile
[INFO] | \- org.jasypt:jasypt:jar:1.9.3:compile
[INFO] +- net.sf.jasperreports:jasperreports:jar:6.16.0:compile
[INFO] | +- commons-digester:commons-digester:jar:2.1:compile
[INFO] | +- org.apache.commons:commons-collections4:jar:4.2:compile
[INFO] | +- org.jfree:jcommon:jar:1.0.23:compile
[INFO] | +- org.jfree:jfreechart:jar:1.0.19:compile
[INFO] | +- org.eclipse.jdt:ecj:jar:3.21.0:compile
[INFO] | \- org.codehaus.castor:castor-xml:jar:1.4.1:compile
[INFO] | \- org.codehaus.castor:castor-core:jar:1.4.1:compile
[INFO] +- net.sf.jasperreports:jasperreports-fonts:jar:6.16.0:compile
[INFO] +- com.alibaba:easyexcel:jar:2.1.1:compile
[INFO] | +- cglib:cglib:jar:3.1:compile
[INFO] | | \- org.ow2.asm:asm:jar:4.2:compile
[INFO] | \- org.ehcache:ehcache:jar:3.9.2:compile
[INFO] | \- org.glassfish.jaxb:jaxb-runtime:jar:2.3.3:compile
[INFO] | +- org.glassfish.jaxb:txw2:jar:2.3.3:compile
[INFO] | \- com.sun.istack:istack-commons-runtime:jar:3.0.11:compile
[INFO] +- org.apache.poi:poi-ooxml:jar:4.1.1:compile
[INFO] | +- org.apache.poi:poi-ooxml-schemas:jar:4.1.1:compile
[INFO] | | \- org.apache.xmlbeans:xmlbeans:jar:3.1.0:compile
[INFO] | +- org.apache.commons:commons-compress:jar:1.19:compile
[INFO] | \- com.github.virtuald:curvesapi:jar:1.06:compile
[INFO] +- org.apache.poi:poi:jar:4.1.1:compile
[INFO] | \- org.apache.commons:commons-math3:jar:3.6.1:compile
[INFO] +- org.mockito:mockito-core:jar:4.4.0:compile
[INFO] | +- net.bytebuddy:byte-buddy-agent:jar:1.10.22:compile
[INFO] | \- org.objenesis:objenesis:jar:3.2:compile
[INFO] +- commons-codec:commons-codec:jar:1.9:compile
[INFO] +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] +- com.alibaba:transmittable-thread-local:jar:2.12.1:compile
[INFO] \- com.github.penggle:kaptcha:jar:2.3.2:compile
[INFO] +- javax.servlet:javax.servlet-api:jar:4.0.1:compile
[INFO] \- com.jhlabs:filters:jar:2.0.235-1:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
经查验,LogbackLoggerInstrumentation 在客户那里不生效,导致无法进行store操作。
推荐客户使用 otel agent,并调整日志 parttern后,有traceId输出
经推断:排除客户使用框架问题,LogbackLoggerInstrumentation 探针有问题。具体情况还需进一步排查。
比对了otel 和 ddtrace 对 logback 的探针源码,处理逻辑基本一致,可排除 logback 探针问题,目前仍需进一步排查。
通过引入 ddtrace-api 仍然表现为logback mdc 未生效,而通过手动 insert trace_id 后,日志可以输出 trace_id 信息
对于问题,尚未查出具体导致问题的原因,但是已找到解决方案:
if (context != null) {
correlationValues.put(
CorrelationIdentifier.getTraceIdKey(), context.getTraceId().toString());
correlationValues.put(
CorrelationIdentifier.getSpanIdKey(), DDSpanId.toString(context.getSpanId()));
}else{
AgentSpan span = activeSpan();
if (span!=null){
correlationValues.put(
CorrelationIdentifier.getTraceIdKey(), span.getTraceId().toString());
correlationValues.put(
CorrelationIdentifier.getSpanIdKey(), DDSpanId.toString(span.getSpanId()));
}
}
新增了 else 部分,如果能获取到当前的span的信息,应以当前为主。
目前客户环境测试通过。
环境:spirngboot2.4.4
部分用户在使用 agent 时,日志无法输出 traceId 。尝试了很多版本,结果都一样。
logback-spring.xml 部分配置如下: