dd-trace-go icon indicating copy to clipboard operation
dd-trace-go copied to clipboard

ddtrace/tracer: encode/decode reparent ID from tracestate

Open bouwkast opened this issue 1 year ago • 2 comments

What does this PR do?

Encodes and decodes a reparenting ID that we will store in the tracestate of tracecontext headers. When injecting into the tracecontext this will add p sub-key with the value of the spanContext.spanID as a 16-character hex string. When extracting from tracecontext if the p sub-key exists we'll add that value as the _dd.parent_id meta tag. If there isn't a p sub-key the value will be treated as 0 where the backend will treat that as being a possible root of the trace.

System tests PR to unskip the parametric tests (passed locally) https://github.com/DataDog/system-tests/pull/2189

Motivation

Goal here is to improve the user experience for distributed traces where there may be spans not sent to Datadog from W3C tracers. The backend will use the existence of the _dd.parent_id tag and its value to reparent spans as needed within a trace (if the parent span is missing).

Reviewer's Checklist

  • [ ] Changed code has unit tests for its functionality at or near 100% coverage.
  • [ ] System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • [ ] There is a benchmark for any new code, or changes to existing code.
  • [ ] If this interacts with the agent in a new way, a system test has been added.
  • [ ] Add an appropriate team label so this PR gets put in the right place for the release notes.
  • [ ] Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.

For Datadog employees:

  • [ ] If this PR touches code that handles credentials of any kind, such as Datadog API keys, I've requested a review from @DataDog/security-design-and-guidance.
  • [ ] This PR doesn't touch any of that.

Unsure? Have a question? Request a review!

bouwkast avatar Feb 27 '24 14:02 bouwkast

Benchmarks

Benchmark execution time: 2024-04-26 08:50:17

Comparing candidate commit 0a2d0863dce0a1c74921c64c057dbd922935d5a6 in PR branch steven/encode-reparent-id with baseline commit 4620904c0a037373d365883236a68061d5cb2efa in branch main.

Found 3 performance improvements and 1 performance regressions! Performance is the same for 39 metrics, 1 unstable metrics.

scenario:BenchmarkExtractW3C-24

  • 🟥 allocated_mem [+32 bytes; +32 bytes] or [+3.077%; +3.077%]

scenario:BenchmarkInjectW3C-24

  • 🟩 allocated_mem [-193 bytes; -174 bytes] or [-4.799%; -4.325%]
  • 🟩 allocations [-16; -14] or [-6.549%; -5.894%]
  • 🟩 execution_time [-1.936µs; -1.704µs] or [-6.007%; -5.287%]

pr-commenter[bot] avatar Feb 28 '24 19:02 pr-commenter[bot]

LGTM

dianashevchenko avatar Mar 01 '24 12:03 dianashevchenko

This PR is stale because it has been open 20 days with no activity. Remove stale label or comment or this will be closed in 10 days.

github-actions[bot] avatar Apr 11 '24 01:04 github-actions[bot]