How to start trace with custom trace-id and parent-id?
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- java, kafka
调研方向
从示例中所示的 Java 入口点开始—GlobalTracer.get()、buildSpan(...).asChildOf() 和 CustomSpanContext—并比较存储的 Kafka header 如何在 outbox 容器中被使用。确定是否存在任何受支持的 API,能够接受 trace-id 和 parent-id,同时保留分布式追踪。当来自 publishFromOutbox 的 span 出现在现有 trace 中并带有关联的日志时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Library Name
micronaut
Library Version(s)
dd-trace:1.50.1
Describe the feature you'd like
Hi,
We are storing outbox events for Kafka in the database with current span context headers:
headers={
x-datadog-parent-id=1425649086485655485,
x-datadog-sampling-priority=1,
tracestate=dd=s:1;
o:rum;
p:13c8ec4a6e566fbd,
x-datadog-origin=rum,
traceparent=00-000000000000000024fefac4c68ae928-13c8ec4a6e566fbd-01,
x-datadog-trace-id=2665843752501438760
}
and when these outbox events are picked (by a different container), we want to trace that operation but attach those spans to an already existing trace so that we can have support for:
- distributed tracing
- distributed logs
Is your feature request related to a problem?
No response
Describe alternatives you've considered
This is what we tried
void publishFromOutbox(final Outbox outboxEvent) {
final var tracer = GlobalTracer.get();
final Span span = tracer.buildSpan(JOBS)
.withTag(DDTags.RESOURCE_NAME, OUTBOX_SCHEDULER_PUBLISH)
.ignoreActiveSpan()
.asChildOf(new CustomSpanContext(
outboxEvent.headers().get(X_DATADOG_TRACE_ID), outboxEvent.headers().get(X_DATADOG_PARENT_ID)))
.start();
tracer.activateSpan(span);
publish(outboxEvent);
tracer.activeSpan().finish();
}
but we can see this doesn't work. Trace is not created or attached to any existing trace.
How can we accomplish starting trace with custom trace-id and parent-id? For PHP services we are using this handy method that you provide
/**
* Apply the distributed tracing information on the current and future spans. That API can be called if there is no
* other currently active span.
*
* The distributed tracing context can be reset by calling 'set_distributed_tracing_context("0", "0")'
*
* @param string $traceId The unique integer (128-bit unsigned) ID of the trace containing this span
* @param string $parentId The span integer ID of the parent span
* @param string|null $origin The distributed tracing origin
* @param array|string|null $propagated_tags If provided, propagated tags from the root span will be cleared and
* replaced by the given tags and applied to existing spans
* @return bool 'true' if the distributed tracing context was properly set, else 'false' if an error occurred
*/
function set_distributed_tracing_context(
string $traceId,
string $parentId,
?string $origin = null,
array|string|null $propagated_tags = null
): bool {}
Additional context
No response
- 主要语言
- Java
- 星标
- 737
- 派生
- 361
- 平均合并
- 3 天 20 小时
- 30 天内合并 PR
- 173
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
DataDog/dd-trace-java 的其他 Issue
-
type: feature request
难度 1/5 1-3 小时 新手友好度 70/100
DataDog/dd-trace-java#10245 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 62/100
DataDog/dd-trace-java#12608 ·
-
type: bug report
难度 4/5 3-5 天 新手友好度 35/100
DataDog/dd-trace-java#12597 ·
-
难度 4/5 3-5 天 新手友好度 35/100
DataDog/dd-trace-java#12540 · 4 条评论 · 已指派 1 人 ·
-
难度 3/5 1-2 天 新手友好度 25/100
DataDog/dd-trace-java#12480 ·
查看 DataDog/dd-trace-java 的全部 Issue
相似的 Issue
-
area/plugin
难度 2/5 1-3 小时 新手友好度 75/100
kestra-io/plugin-kestra#190 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
integra-team-red/meet-map#249 ·
-
[Studio][Bug] Cancelled create-user dialog keeps the password and admin switch for the next attempt 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
apache/rocketmq-dashboard#5064 ·