[英]Which to log X-B3-SpanId or SpanId? X-B3-TraceId or TraceId? (Spring sleuth)
Spring 的偵探增加了 MDC X-B3-SpanId 和 SpanId。 (與 TraceId 相同)
{X-B3-SpanId=0000000000000001, X-B3-TraceId=0000000000000002, X-Span-Export=false, spanExportable=false, spanId=0000000000000001, traceId=0000000000000002}
“X-B3-”前綴值與非前綴值相同。
如果其中之一是多余的,我更願意將其刪除。 (為了減少我的日志的冗長)
X-B3-SpanId 和 SpanId 之間有什么區別嗎? (X-B3-TraceId 和 Traceid)
有充分的理由同時記錄兩者嗎?
spring 文檔中的圖表https://cloud.spring.io/spring-cloud-sleuth/2.1.x/single/spring-cloud-sleuth.html#_propagation顯示“X-B3-”前綴的東西只存在於請求頭中用於傳輸,但如果我在沒有任何這些標頭的情況下發出請求,我的日志的 MDC 仍然包含“X-B3-”前綴值。
使用的依賴項:
只是簡單地添加了對 gradle.build 的依賴 - 沒有關於偵探的定制/配置。
*MDC = log4j2 的映射診斷上下文https://logging.apache.org/log4j/2.x/manual/thread-context.html
查看類 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"
所以你可以使用你想要的任何兩個,但要注意他們認為 X-B3* 變量是遺留的
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.