Skip to content

notheotherben/tracing-opentelemetry-traceid-repro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Tracing OpenTelemetry TraceID Propagation Bug Repro

This repository contains a minimal reproduction of a bug in the Rust tracing-opentelemetry library which results in the Trace ID of the root span not matching that of child spans in scenarios where span.set_parent is called with an empty propagation context.

Scenarios

Scenario 1: Span.set_parent is not used

In this scenario, trace-id propagates correctly to child spans as one would expect.

{"resourceSpans":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"unknown_service"}}]},"scopeSpans":[{"scope":{"name":"example","version":"v0.0.0"},"spans":[{"traceId":"df5fcb76820f1ad41451e92d50b2e2ed","spanId":"ef0be40910e48d4f","parentSpanId":"3e612535b936b97d","name":"Child 1","kind":1,"startTimeUnixNano":1692028940520007100,"endTimeUnixNano":1692028940520029300,"attributes":[{"key":"idle_ns","value":{"intValue":32800}},{"key":"thread.id","value":{"intValue":1}},{"key":"thread.name","value":{"stringValue":"main"}},{"key":"code.namespace","value":{"stringValue":"tracing_opentelemetry_traceid_repro"}},{"key":"code.filepath","value":{"stringValue":"src\\main.rs"}},{"key":"code.lineno","value":{"intValue":75}},{"key":"busy_ns","value":{"intValue":2500}}],"droppedAttributesCount":0,"droppedEventsCount":0,"droppedLinksCount":0,"status":{}}]}]}]}
{"resourceSpans":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"unknown_service"}}]},"scopeSpans":[{"scope":{"name":"example","version":"v0.0.0"},"spans":[{"traceId":"df5fcb76820f1ad41451e92d50b2e2ed","spanId":"3e612535b936b97d","parentSpanId":"","name":"Root Span","kind":1,"startTimeUnixNano":1692028940519776800,"endTimeUnixNano":1692028940520148200,"attributes":[{"key":"code.lineno","value":{"intValue":65}},{"key":"code.filepath","value":{"stringValue":"src\\main.rs"}},{"key":"idle_ns","value":{"intValue":229400}},{"key":"carrier","value":{"stringValue":"None"}},{"key":"busy_ns","value":{"intValue":152800}},{"key":"thread.name","value":{"stringValue":"main"}},{"key":"code.namespace","value":{"stringValue":"tracing_opentelemetry_traceid_repro"}},{"key":"thread.id","value":{"intValue":1}}],"droppedAttributesCount":0,"droppedEventsCount":0,"droppedLinksCount":0,"status":{}}]}]}]}

Scenario 2: Span.set_parent is used with an empty propagation context

In this scenario, trace-id does not propagate correctly to child spans (the root span will end up with a different trace-id than the child spans).

NOTE: Look at the traceId field for each of the recorded spans below. Notice how the trace-id of the root span does not match that of the child spans.

{"resourceSpans":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"unknown_service"}}]},"scopeSpans":[{"scope":{"name":"example","version":"v0.0.0"},"spans":[{"traceId":"8b7feb23272552f3b2a125d967e5c436","spanId":"98d691af8e12d835","parentSpanId":"2e0a46b8d22f1692","name":"Child 1","kind":1,"startTimeUnixNano":1692028941521124900,"endTimeUnixNano":1692028941521143800,"attributes":[{"key":"thread.name","value":{"stringValue":"main"}},{"key":"code.namespace","value":{"stringValue":"tracing_opentelemetry_traceid_repro"}},{"key":"code.filepath","value":{"stringValue":"src\\main.rs"}},{"key":"thread.id","value":{"intValue":1}},{"key":"idle_ns","value":{"intValue":19200}},{"key":"busy_ns","value":{"intValue":3000}},{"key":"code.lineno","value":{"intValue":75}}],"droppedAttributesCount":0,"droppedEventsCount":0,"droppedLinksCount":0,"status":{}}]}]}]}
{"resourceSpans":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"unknown_service"}}]},"scopeSpans":[{"scope":{"name":"example","version":"v0.0.0"},"spans":[{"traceId":"716d65bde3098e2e1d66538d38833d1d","spanId":"2e0a46b8d22f1692","parentSpanId":"","name":"Root Span","kind":1,"startTimeUnixNano":1692028941521056800,"endTimeUnixNano":1692028941521191900,"attributes":[{"key":"code.filepath","value":{"stringValue":"src\\main.rs"}},{"key":"carrier","value":{"stringValue":"Some({})"}},{"key":"code.namespace","value":{"stringValue":"tracing_opentelemetry_traceid_repro"}},{"key":"busy_ns","value":{"intValue":73400}},{"key":"thread.name","value":{"stringValue":"main"}},{"key":"idle_ns","value":{"intValue":60300}},{"key":"thread.id","value":{"intValue":1}},{"key":"code.lineno","value":{"intValue":65}}],"droppedAttributesCount":0,"droppedEventsCount":0,"droppedLinksCount":0,"status":{}}]}]}]}

Scenario 3: Span.set_parent is used with a non-empty propagation context

In this scenario, trace-id does propagate correctly and is set to the ID passed to Span.set_parent.

{"resourceSpans":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"unknown_service"}}]},"scopeSpans":[{"scope":{"name":"example","version":"v0.0.0"},"spans":[{"traceId":"d92b48609ff5c2a7952d45bd6c6a2802","spanId":"f369995dfc1884a7","parentSpanId":"3e24af45e7402b4e","name":"Child 1","kind":1,"startTimeUnixNano":1692028942522065200,"endTimeUnixNano":1692028942522082000,"attributes":[{"key":"code.namespace","value":{"stringValue":"tracing_opentelemetry_traceid_repro"}},{"key":"code.lineno","value":{"intValue":75}},{"key":"busy_ns","value":{"intValue":2700}},{"key":"idle_ns","value":{"intValue":16300}},{"key":"thread.name","value":{"stringValue":"main"}},{"key":"code.filepath","value":{"stringValue":"src\\main.rs"}},{"key":"thread.id","value":{"intValue":1}}],"droppedAttributesCount":0,"droppedEventsCount":0,"droppedLinksCount":0,"status":{}}]}]}]}
{"resourceSpans":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"unknown_service"}}]},"scopeSpans":[{"scope":{"name":"example","version":"v0.0.0"},"spans":[{"traceId":"d92b48609ff5c2a7952d45bd6c6a2802","spanId":"3e24af45e7402b4e","parentSpanId":"a2b6ccc696a3a41f","name":"Root Span","kind":1,"startTimeUnixNano":1692028942521983400,"endTimeUnixNano":1692028942522129100,"attributes":[{"key":"thread.name","value":{"stringValue":"main"}},{"key":"code.filepath","value":{"stringValue":"src\\main.rs"}},{"key":"carrier","value":{"stringValue":"Some({\"traceparent\": \"00-d92b48609ff5c2a7952d45bd6c6a2802-a2b6ccc696a3a41f-01\"})"}},{"key":"code.lineno","value":{"intValue":65}},{"key":"thread.id","value":{"intValue":1}},{"key":"code.namespace","value":{"stringValue":"tracing_opentelemetry_traceid_repro"}},{"key":"busy_ns","value":{"intValue":67900}},{"key":"idle_ns","value":{"intValue":76300}}],"droppedAttributesCount":0,"droppedEventsCount":0,"droppedLinksCount":0,"status":{}}]}]}]}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages