[英]Which to log X-B3-SpanId or SpanId? X-B3-TraceId or TraceId? (Spring sleuth)
Spring's sleuth adds to MDC X-B3-SpanId and SpanId. Spring 的侦探增加了 MDC X-B3-SpanId 和 SpanId。 (same for TraceId)
(与 TraceId 相同)
{X-B3-SpanId=0000000000000001, X-B3-TraceId=0000000000000002, X-Span-Export=false, spanExportable=false, spanId=0000000000000001, traceId=0000000000000002}
"X-B3-" prefixed values are identical to non-prefixed. “X-B3-”前缀值与非前缀值相同。
If one of them is redundant, I prefer to remove it.如果其中之一是多余的,我更愿意将其删除。 (to reduce verboseness of my logs)
(为了减少我的日志的冗长)
Is there any difference between X-B3-SpanId and SpanId? X-B3-SpanId 和 SpanId 之间有什么区别吗? (X-B3-TraceId and Traceid)
(X-B3-TraceId 和 Traceid)
Is there good reason to log both?有充分的理由同时记录两者吗?
Diagram in spring docs https://cloud.spring.io/spring-cloud-sleuth/2.1.x/single/spring-cloud-sleuth.html#_propagation show that "X-B3-" prefixed thing lives only in request header for transport, but if I make request without any of those headers, my log's MDC still contains "X-B3-" prefixed values. spring 文档中的图表https://cloud.spring.io/spring-cloud-sleuth/2.1.x/single/spring-cloud-sleuth.html#_propagation显示“X-B3-”前缀的东西只存在于请求头中用于传输,但如果我在没有任何这些标头的情况下发出请求,我的日志的 MDC 仍然包含“X-B3-”前缀值。
Used dependencies:使用的依赖项:
Just plain addition of dependency to gradle.build - no customizations/configurations regarding sleuth.只是简单地添加了对 gradle.build 的依赖 - 没有关于侦探的定制/配置。
*MDC = log4j2's Mapped Diagnostic Contexhttps://logging.apache.org/log4j/2.x/manual/thread-context.html *MDC = log4j2 的映射诊断上下文https://logging.apache.org/log4j/2.x/manual/thread-context.html
Looking at the class Slf4jScopeDecorator is clear that the two values are exactly the same and they maintain the X-B3* prefixed values only for backward compatibility:查看类 Slf4jScopeDecorator 很明显,这两个值完全相同,它们维护 X-B3* 前缀值只是为了向后兼容:
* Adds {@linkplain MDC} properties "traceId", "parentId", "spanId" and "spanExportable"
* when a {@link brave.Tracer#currentSpan() span is current}. These can be used in log
* correlation. Supports backward compatibility of MDC entries by adding legacy "X-B3"
* entries to MDC context "X-B3-TraceId", "X-B3-ParentSpanId", "X-B3-SpanId" and
* "X-B3-Sampled"
https://github.com/spring-cloud/spring-cloud-sleuth/blob/master/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/log/Slf4jScopeDecorator.java https://github.com/spring-cloud/spring-cloud-sleuth/blob/master/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/log/Slf4jScopeDecorator.java
So you can use whatever of the two you want but be aware that they consider X-B3* variables legacy所以你可以使用你想要的任何两个,但要注意他们认为 X-B3* 变量是遗留的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.