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

feat(ddtrace/tracer): introduce ExtractCtx to support propagated context

Open darccio opened this issue 5 months ago • 1 comments

What does this PR do?

Adds ExtractCtx to simplify the creation of child spans from propagated contexts.

Some notes:

  • All the functions are unexported except for ExtractCtx to reduce the increase on public API.
  • We are still relying in the deprecated ChildOf internally, which expects a SpanContext, so instead of reusing the existing ActiveSpanKey we create a new one for ActiveSpanContextKey (which it doesn't have precedence over ActiveSpanKey value).

Motivation

Fixes #3793

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.
  • [ ] New code is free of linting errors. You can check this by running ./scripts/lint.sh locally.
  • [ ] 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.

Unsure? Have a question? Request a review!

darccio avatar Aug 12 '25 10:08 darccio

Benchmarks

Benchmark execution time: 2025-08-13 09:29:15

Comparing candidate commit 831161b785a318b5e133b40f776dd6f76818ce0b in PR branch dario.castane/langplat-727/extract-ctx with baseline commit 4d47dd60c2c81734d85ba67d74d643a77e86d29e in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 24 metrics, 0 unstable metrics.

pr-commenter[bot] avatar Aug 12 '25 10:08 pr-commenter[bot]