How to start trace with custom trace-id and parent-id?
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- java, kafka
- Domain
- distributed-systems, observability-sre
Research direction
Start with the Java entry points shown in the example—GlobalTracer.get(), buildSpan(...).asChildOf(), and CustomSpanContext—and compare how the stored Kafka headers are consumed in the outbox container. Determine what supported API, if any, accepts the trace-id and parent-id while preserving distributed tracing. Done means a span from publishFromOutbox appears in the existing trace with correlated logs.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- Java
- Stars
- 737
- Forks
- 361
- Avg merge
- 3d 20h
- Merged PRs (30d)
- 173
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from DataDog/dd-trace-java
-
type: feature request
Difficulty 1/5 1-3 hours Newbie friendliness 70/100
DataDog/dd-trace-java#10245 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 62/100
DataDog/dd-trace-java#12608 ·
-
type: bug report
Difficulty 4/5 3-5 days Newbie friendliness 35/100
DataDog/dd-trace-java#12597 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
DataDog/dd-trace-java#12540 · 3 comments · 1 assignee ·
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
DataDog/dd-trace-java#12480 ·
All issues in DataDog/dd-trace-java
Similar issues
-
bug untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
opensearch-project/ml-commons#5094 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
emitter:client:csharp feature
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
affects/8.10 affects/8.9 component/clients kind/bug likelihood/mid severity/mid
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Two open-case totals on one screen: the Programs tile says 15,858 and the nav badge says 15,868 Openbug frontend maui-pilot
Difficulty 2/5 1-3 hours Newbie friendliness 72/100