连接Java日志和跟踪TraceID和Span ID的值为零

发布于 2025-02-09 08:55:03 字数 762 浏览 1 评论 0原文

我正在遵循DataDog文档中的连接Java日志和跟踪: “ noreferrer”> htttps:/ = slf4jandlogback

我在端点中添加了下一个代码:

import org.slf4j.MDC;
import datadog.trace.api.CorrelationIdentifier;

// There must be spans started and active before this block.
try {
    MDC.put("dd.trace_id", CorrelationIdentifier.getTraceId());
    MDC.put("dd.span_id", CorrelationIdentifier.getSpanId());

// Log something

} finally {
    MDC.remove("dd.trace_id");
    MDC.remove("dd.span_id");
}

在控制台中,我可以看到下一个日志:dd.trace_id':“ 0”,“ dd.span_id”:“ 0”}

我不确定为什么我没有得到正确的trace_id和span_id,为什么这些值是零的

I am following the Connecting Java logs and Traces from the Datadog docs:
https://docs.datadoghq.com/tracing/connect_logs_and_traces/java/?tab=slf4jandlogback

I added the next code to my endpoint:

import org.slf4j.MDC;
import datadog.trace.api.CorrelationIdentifier;

// There must be spans started and active before this block.
try {
    MDC.put("dd.trace_id", CorrelationIdentifier.getTraceId());
    MDC.put("dd.span_id", CorrelationIdentifier.getSpanId());

// Log something

} finally {
    MDC.remove("dd.trace_id");
    MDC.remove("dd.span_id");
}

In the console I can see the next logs: dd.trace_id":"0","dd.span_id":"0"}

I am not pretty sure why I am not getting a correct trace_id and span_id and why these values are Zero.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文