Skip to content

refactor: fix layering violations in otel related to Span typechecking - #20343

Draft
emmettbutler wants to merge 2 commits into
mainfrom
emmett.butler/otel-span-proto
Draft

emmettbutler wants to merge 2 commits into
mainfrom
emmett.butler/otel-span-proto

Conversation

@emmettbutler

Copy link
Copy Markdown
Collaborator

No description provided.

@emmettbutler
emmettbutler requested review from a team as code owners September 15, 2026 18:32
@emmettbutler
emmettbutler requested review from avara1986, mabdinur and taegyunkim and removed request for a team September 15, 2026 18:32
@emmettbutler
emmettbutler marked this pull request as draft September 15, 2026 18:32
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Pipelines  Tests

⚠️ Warnings

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 2 Pipeline jobs failed

Changelog | Validate changelog

View more details · View in GitHub Actions

Team freeze guard | Team freeze guard

View more details · View in GitHub Actions

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 91ab0d8 | Docs | View more details | Give us feedback!

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Codeowners resolved as

Resolved from the full PR diff against main using the target branch CODEOWNERS file.
CODEOWNERS team requests not listed below are not required by the current file set.

ddtrace/internal/opentelemetry/context.py                               @DataDog/apm-sdk-capabilities-python
ddtrace/internal/opentelemetry/span.py                                  @DataDog/apm-sdk-capabilities-python
ddtrace/internal/opentelemetry/thread_context.py                        @DataDog/apm-sdk-capabilities-python @DataDog/asm-python @DataDog/profiling-python
ddtrace/internal/opentelemetry/trace.py                                 @DataDog/apm-sdk-capabilities-python

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Circular import analysis

⚠️ Existing circular imports

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

ddtrace.errortracking._handled_exceptions.bytecode_injector -> ddtrace.errortracking._handled_exceptions.callbacks -> ddtrace.errortracking._handled_exceptions.collector -> ddtrace.errortracking._handled_exceptions.bytecode_reporting -> ddtrace.errortracking._handled_exceptions.bytecode_injector

@cit-pr-commenter-54b7da

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

Copy link
Copy Markdown

Dependency direction analysis

⚠️ Existing dependency direction violations

There are 215 dependency direction violations that already exist on the base branch and have not been changed by this PR.

Show existing violations (showing 5 of 215 highest severity)
ddtrace.internal.tracemethods -×-> ddtrace.trace  (internal-core -> product:tracing, score=133)
ddtrace.internal.ci_visibility.git_client -×-> ddtrace.trace  (product:ci_visibility -> product:tracing, score=131)
ddtrace.appsec._listeners -×-> ddtrace.trace  (product:appsec -> product:tracing, score=131)
ddtrace.llmobs._integrations.vllm -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=131)
ddtrace.llmobs._integrations.pydantic_ai -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=131)

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

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

✅ Dependency direction violations removed

3 violation(s) have been removed by this PR.

ddtrace.internal.opentelemetry.context -×-> ddtrace._trace.span  (product:opentelemetry -> product:tracing, score=46)
ddtrace.internal.opentelemetry.thread_context -×-> ddtrace._trace.span  (product:opentelemetry -> product:tracing, score=46)
ddtrace.internal.opentelemetry.span -×-> ddtrace._trace.span  (product:opentelemetry -> product:tracing, score=46)

@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: d2a0ad0b9d

ℹ️ 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 on lines +45 to +46
Lets this module type-annotate the wrapped Datadog span without a runtime dependency on the
concrete ``ddtrace._trace.span.Span`` class.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Use plain text in the private protocol docstring

This private internal helper is not rendered by Sphinx, so the double-backtick literal violates the repository convention and adds editor-only markup; write ddtrace._trace.span.Span as plain text instead.

AGENTS.md reference: AGENTS.md:L44-L52

Useful? React with 👍 / 👎.

Comment on lines +23 to +24
class _LocalRootProtocol(Protocol):
"""Structural interface for the ``_local_root`` a thread-context span sync needs."""

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove rST markup from the private helper docstring

Because _LocalRootProtocol is a private helper in an internal module rather than a Sphinx-rendered interface, its double-backtick markup conflicts with the repository's plain-prose requirement; spell _local_root without rST markup.

AGENTS.md reference: AGENTS.md:L44-L52

Useful? React with 👍 / 👎.

@pr-commenter

pr-commenter Bot commented Sep 15, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-09-15 19:02:46

Comparing candidate commit 91ab0d8 in PR branch emmett.butler/otel-span-proto with baseline commit a9bd5d1 in branch main.

📊 Benchmarking dashboard

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

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

scenario:otelspan-start

  • 🟥 execution_time [+2.370ms; +3.152ms] or [+7.271%; +9.672%]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant