fix(ddtrace/tracer): check DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED once, use a global bool#4548
Conversation
5693fd9 to
c0b5220
Compare
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 4bb0128 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
Codecov Report❌ Patch coverage is
Additional details and impacted files
🚀 New features to boost your workflow:
|
BenchmarksBenchmark execution time: 2026-03-25 09:58:14 Comparing candidate commit 4bb0128 in PR branch Found 3 performance improvements and 0 performance regressions! Performance is the same for 213 metrics, 8 unstable metrics.
|
|
|
||
| // traceID128BitEnabled caches DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED | ||
| // at init time so that newSpanContext avoids calling BoolEnv on every span. | ||
| var traceID128BitEnabled = sharedinternal.BoolEnv("DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED", true) |
There was a problem hiding this comment.
This is okay for now, however, this will be problematic when we try to parallelize the test runs (which is our goal).
We should avoid adding global state like this if it is possibel.
There was a problem hiding this comment.
I know, but checking an environment variable is the same 😁 We need to find a better way to have this kind of configs accessible from any code path in the span lifecycle.
|
|
||
| // traceID128BitEnabled caches DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED | ||
| // at init time so that newSpanContext avoids calling BoolEnv on every span. | ||
| var traceID128BitEnabled = sharedinternal.BoolEnv("DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED", true) |
There was a problem hiding this comment.
If a customer changes this at runtime (os.Setenv("DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED", "false")) and then restart its tracer the value won't get updated right ?
I don't think that's ideal, as we are doing this kind of env var modification customer must be doing it as well.
There was a problem hiding this comment.
@genesor I can move the initialization to the newConfig method. WDYT? This guarantees that restarting the tracer gets the updated value.
There was a problem hiding this comment.
Yes, that would be a great middle ground.
I also agree with you that we need a way to get configs from anywhere in the codebase, linked or not with a tracer instance.
cc @mtoffl01
There was a problem hiding this comment.
Done in 94d83a3. The next commit is to update tests to manipulate the global state in the right moment.
…D once, use a global boolean
…r tracer restart to pick new values on `newConfig`
979fd6a to
58561c1
Compare
…t in tests newConfig now stores traceID128BitEnabled from the env var on every tracer start, so Swap calls before startTestTracer/newTracer were immediately overwritten by the default (true). Move Swap to after tracer creation so the atomic is set correctly before spans are started. Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…ED` once, use a global `bool` (#4548) Stop checking environment variable `DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED` on span start. Checks it once, use a global `bool`. It'd be better to load it on `newConfig` and make the value available, but this one happens in `newSpanContext`, which modification will cause a lot of changes in multiple files, including tests. Complete #1905 work using the current benchmarking platform. - [x] Changed code has unit tests for its functionality at or near 100% coverage. - [x] There is a benchmark for any new code, or changes to existing code. - [x] New code is free of linting errors. You can check this by running `make lint` locally. - [x] New code doesn't break existing tests. You can check this by running `make test` locally. - [x] Add an appropriate team label so this PR gets put in the right place for the release notes. Unsure? Have a question? Request a review! Co-authored-by: kakkoyun <[email protected]> Co-authored-by: kemal.akkoyun <[email protected]>
What does this PR do?
Stop checking environment variable
DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLEDon span start. Checks it once, use a globalbool.It'd be better to load it on
newConfigand make the value available, but this one happens innewSpanContext, which modification will cause a lot of changes in multiple files, including tests.Motivation
Complete #1905 work using the current benchmarking platform.
Reviewer's Checklist
make lintlocally.make testlocally.Unsure? Have a question? Request a review!