refactor: remove ExecutionContext._inner_span#19084
Conversation
🎉 All green!🧪 All tests passed 🔄 Datadog auto-retried 3 jobs - 2 passed on retry 🔗 Commit SHA: 683a5f6 | Docs | Datadog PR Page | Give us feedback! |
Codeowners resolved as |
Circular import analysis
|
BenchmarksBenchmark execution time: 2026-07-15 19:33:33 Comparing candidate commit 72f665e in PR branch Found 0 performance improvements and 5 performance regressions! Performance is the same for 613 metrics, 10 unstable metrics. scenario:iastaspects-lstrip_aspect
scenario:iastaspects-repr_aspect
scenario:iastaspects-translate_aspect
scenario:iastaspectsospath-ospathbasename_aspect
scenario:span-start
|
…rease as a result of lookup on ExecutionContext
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 683a5f6517
ℹ️ 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".
| return span._local_root or span | ||
|
|
||
|
|
||
| def span_from_context(ctx: core.ExecutionContext[t.Any]) -> "Span": |
There was a problem hiding this comment.
Update remaining ctx.span benchmark callers
Now that span access has moved to span_from_context, the repo still has ctx.span in benchmarks/events_api/scenario.py at lines 53 and 85. When the events_api benchmark runs those handlers after _start_span, ExecutionContext no longer has a span attribute, so the benchmark aborts with AttributeError instead of measuring the refactor. Please update the benchmark callers to use this helper or keep a compatibility alias.
Useful? React with 👍 / 👎.
This change removes the
_inner_spanattribute fromddtrace.core.ExecutionContext, replacing it with an_inner_spandatum stored via existing mechanisms. This eliminates Spans as a special case in the Core API, treating them like any other piece of data stored in the context tree.span_busis introduced containing two of the span-related helper functions fromcore, indicating the separateness of Span management from Core. Note that while this separation does fix the import-time coupling between_traceandcore, it does not address the functional dependence of certain products on_trace, specifically those that use Spans as context tracking.