Skip to content

refactor: remove global tracer variable from core#19083

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 9 commits into
mainfrom
emmett.butler/no-core-tracer
Jul 17, 2026
Merged

refactor: remove global tracer variable from core#19083
gh-worker-dd-mergequeue-cf854d[bot] merged 9 commits into
mainfrom
emmett.butler/no-core-tracer

Conversation

@emmettbutler

@emmettbutler emmettbutler commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

This change replaces core.tracer with a tracer instance stored on the root ExecutionContext object, increasing the separation of concerns between tracing and core. With this change, tracing becomes a user of the core API rather than being a part of it.

This change also increases a missed microbenchmark by a small amount to account for slightly increased execution time during span creation as a result of the ExecutionContext.get_item call added here.

@emmettbutler
emmettbutler requested review from a team as code owners July 15, 2026 17:03
@emmettbutler
emmettbutler marked this pull request as draft July 15, 2026 17:03
@datadog-official

datadog-official Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 95e2b2e | Docs | Datadog PR Page | Give us feedback!

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Jul 15, 2026

Copy link
Copy Markdown

Circular import analysis

⚠️ Existing circular imports

There are 61 circular imports that already exist on the base branch and have not been changed by this PR.

Show existing cycles (showing 5 of 61 shortest)
ddtrace.internal.datastreams -> ddtrace.internal.datastreams.kafka -> ddtrace.internal.datastreams
ddtrace.internal.datastreams -> ddtrace.internal.datastreams.kombu -> ddtrace.internal.datastreams
ddtrace.internal.datastreams -> ddtrace.internal.datastreams.aiokafka -> ddtrace.internal.datastreams
ddtrace._trace.span -> ddtrace.internal.core -> ddtrace._trace.span
ddtrace.internal.datastreams -> ddtrace.internal.datastreams.botocore -> ddtrace.internal.datastreams

To see all cycles, download the cycles-base.json and cycles-pr.json artifacts from this CI job and run:

uv run --script scripts/import-analysis/cycles.py compare cycles-base.json cycles-pr.json

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codeowners resolved as

.gitlab/benchmarks/bp-runner.microbenchmarks.fail-on-breach.template.yml  @DataDog/python-guild @DataDog/apm-core-python

@emmettbutler emmettbutler added the changelog/no-changelog A changelog entry is not required for this PR. label Jul 15, 2026
@emmettbutler
emmettbutler marked this pull request as ready for review July 15, 2026 17:32

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 486b77c939

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread ddtrace/internal/core/__init__.py
Comment thread ddtrace/contrib/internal/trace_utils.py

@brettlangdon brettlangdon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, my main concern would have been the performance overhead, but the span property and get_root_span shouldn't be called too much?

@emmettbutler
emmettbutler requested a review from mabdinur July 16, 2026 14:21
@pr-commenter

pr-commenter Bot commented Jul 16, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-07-16 21:40:52

Comparing candidate commit 95e2b2e in PR branch emmett.butler/no-core-tracer with baseline commit cffe63f in branch main.

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

scenario:iastaspects-index_aspect

  • 🟥 execution_time [+15.594µs; +19.127µs] or [+11.678%; +14.323%]

scenario:iastaspectsospath-ospathbasename_aspect

  • 🟥 execution_time [+107.991µs; +114.998µs] or [+24.873%; +26.487%]

scenario:span-start

  • 🟥 execution_time [+1.426ms; +1.608ms] or [+9.126%; +10.294%]

scenario:telemetryaddmetric-1-count-metric-1-times

  • 🟥 execution_time [+222.895ns; +263.255ns] or [+10.871%; +12.839%]

@emmettbutler

Copy link
Copy Markdown
Collaborator Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 16, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-16 15:32:00 UTC ℹ️ Start processing command /merge


2026-07-16 15:32:18 UTC ℹ️ MergeQueue: waiting for PR to be ready

This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals. View in MergeQueue UI.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2026-07-16 19:33:07 UTC ⚠️ MergeQueue: This merge request was unqueued

devflow unqueued this merge request: It did not become mergeable within the expected time

…rease as a result of lookup on ExecutionContext
@emmettbutler
emmettbutler requested a review from a team as a code owner July 16, 2026 17:36
@emmettbutler

Copy link
Copy Markdown
Collaborator Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 16, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-16 17:43:04 UTC ℹ️ Start processing command /merge


2026-07-16 17:43:07 UTC ❌ MergeQueue

PR already in the queue with status waiting

@emmettbutler

Copy link
Copy Markdown
Collaborator Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 16, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-16 18:34:44 UTC ℹ️ Start processing command /merge


2026-07-16 18:34:47 UTC ❌ MergeQueue

PR already in the queue with status waiting

@emmettbutler

Copy link
Copy Markdown
Collaborator Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 16, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-16 20:03:59 UTC ℹ️ Start processing command /merge


2026-07-16 20:04:17 UTC ℹ️ MergeQueue: waiting for PR to be ready

This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals. View in MergeQueue UI.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2026-07-16 21:51:08 UTC ℹ️ MergeQueue: merge request added to the queue

The expected merge time in main is approximately 58m (p90).


2026-07-16 22:08:11 UTCMergeQueue: The build pipeline contains failing jobs for this merge request

Build pipeline has failing jobs for 3ccdc23:

⚠️ Do NOT retry failed jobs directly (why?).

What to do next?

  • Investigate the failures and when ready, re-add your pull request to the queue!
  • If your PR checks are green, try to rebase/merge. It might be because the CI run is a bit old.
  • Any question, go check the FAQ.
Details

Since those jobs are not marked as being allowed to fail, the pipeline will most likely fail.
Therefore, and to allow other builds to be processed, this merge request has been rejected and the pipeline got canceled.

@emmettbutler

Copy link
Copy Markdown
Collaborator Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 16, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-16 21:33:05 UTC ℹ️ Start processing command /merge


2026-07-16 21:33:07 UTC ❌ MergeQueue

PR already in the queue with status waiting

@emmettbutler

Copy link
Copy Markdown
Collaborator Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 17, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-17 02:11:48 UTC ℹ️ Start processing command /merge


2026-07-17 02:11:53 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 58m (p90).


2026-07-17 02:47:15 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 0adee56 into main Jul 17, 2026
1282 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the emmett.butler/no-core-tracer branch July 17, 2026 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/no-changelog A changelog entry is not required for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants