Skip to content

refactor(telemetry): receive AppSec inputs and drop the _threads alias - #22091

Draft
gnufede wants to merge 2 commits into
gnufede/package-split-prepfrom
gnufede/package-split-layout
Draft

gnufede wants to merge 2 commits into
gnufede/package-split-prepfrom
gnufede/package-split-layout

Conversation

@gnufede

@gnufede gnufede commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Description

Follow-up to #22018 for the changes that need AppSec and serverless review. They were kept out of #22018 so it doesn't need those teams' approval.

  1. Telemetry receives its AppSec-driven inputs instead of importing ddtrace.internal.settings.appsec_telemetry (@DataDog/asm-python).
    • Telemetry moves to ddtrace-internal, which can't import dd-trace-py's AppSec settings. Three generic hooks replace those reads:
      • telemetry_inputs.dependencies: whether full dependency metadata is collected (today SCA_ENABLED);
      • telemetry_inputs.endpoints: whether API endpoints are collected, and how many;
      • telemetry_inputs.configurations: which configurations to report at import.
    • ddtrace/__init__.py registers them from the AppSec settings, read lazily on each use. Values, runtime changes and the configuration report order are unchanged.
    • Without registrations, telemetry uses the AppSec defaults: no dependency metadata, endpoint collection on, limit 300.
    • The SCA test now patches the registered getter.
  2. Drop the ddtrace.internal._threads alias (@DataDog/apm-serverless, @DataDog/serverless-aws). _threads moved to ddtrace.internal.native._threads in chore(package-split): prepare dd-trace-py for moving code into packages #22018. The serverless runtime-id test was the last importer of the old path.

Testing

Docker, Python 3.12: telemetry 275 passed, tests/appsec/sca 132 passed, tests/contrib/aws_lambda/test_runtime_id.py 83 passed. A new test covers telemetry's defaults when nothing is registered.

Risks

None expected: behavior is unchanged when dd-trace-py registers the inputs, which import ddtrace always does.

Additional Notes

Internal refactor, no release note.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Codeowners resolved as

Resolved from the full PR diff against gnufede/package-split-prep using the target branch CODEOWNERS file.
CODEOWNERS team requests not listed below are not required by the current file set.

ddtrace/__init__.py                                                     @DataDog/apm-python-guild
ddtrace/internal/telemetry/__init__.py                                  @DataDog/apm-python
ddtrace/internal/telemetry/dependency_tracker.py                        @DataDog/apm-python
ddtrace/internal/telemetry/writer.py                                    @DataDog/apm-python
ddtrace/internal/telemetry_inputs/__init__.py                           @DataDog/apm-core-python
ddtrace/internal/telemetry_inputs/configurations.py                     @DataDog/apm-core-python
ddtrace/internal/telemetry_inputs/dependencies.py                       @DataDog/apm-core-python
ddtrace/internal/telemetry_inputs/endpoints.py                          @DataDog/apm-core-python
tests/appsec/sca/test_telemetry.py                                      @DataDog/asm-python
tests/contrib/aws_lambda/test_runtime_id.py                             @DataDog/apm-serverless @DataDog/serverless-aws
tests/telemetry/test_dependency.py                                      @DataDog/apm-core-python @DataDog/apm-python
tests/telemetry/test_telemetry_inputs.py                                @DataDog/apm-core-python @DataDog/apm-python

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Dependency direction analysis

⚠️ Existing dependency direction violations

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

Show existing violations (showing 5 of 22 highest severity)
ddtrace.internal.tracemethods -×-> ddtrace.trace  (internal-core -> product:tracing, score=103)
ddtrace.llmobs._integrations.bedrock_agents -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=101)
ddtrace.llmobs._integrations.base -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=101)
ddtrace.internal.span_bus -×-> ddtrace._trace.span  (internal-core -> product:tracing, score=35)
ddtrace.llmobs._llmobs -×-> ddtrace._trace.span  (product:llmobs -> product:tracing, score=33)

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

@pr-commenter

pr-commenter Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-11-25 17:47:08

Comparing candidate commit 9b8586c in PR branch gnufede/package-split-layout with baseline commit 6d175f4 in branch gnufede/package-split-prep.

📊 Benchmarking dashboard

Found 0 performance improvements and 2 performance regressions! Performance is the same for 636 metrics, 10 unstable metrics, 1 flaky benchmarks without significant changes.

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:packagesupdateimporteddependencies-import_one_stdlib_cache

  • 🟥 execution_time [+580.086ns; +668.183ns] or [+7.171%; +8.260%]

scenario:packagesupdateimporteddependencies-import_one_unknown_cache

  • 🟥 execution_time [+573.321ns; +683.660ns] or [+7.066%; +8.426%]

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:coreapiscenario-context_with_data_listeners

  • unstable execution_time [-701.653ns; +709.169ns] or [-6.475%; +6.545%]

scenario:coreapiscenario-core_dispatch_1_listener

  • unstable execution_time [-38.110ns; +37.315ns] or [-5.927%; +5.803%]

scenario:coreapiscenario-core_dispatch_50_listeners

  • unstable execution_time [-1852.375ns; +1863.141ns] or [-9.186%; +9.239%]

scenario:coreapiscenario-core_dispatch_exception_listeners

  • unstable execution_time [-2006.301ns; +1495.000ns] or [-10.404%; +7.753%]

scenario:coreapiscenario-core_dispatch_listeners

  • unstable execution_time [-350.285ns; +388.268ns] or [-8.135%; +9.017%]

scenario:coreapiscenario-core_dispatch_no_args_listeners

  • unstable execution_time [-219.155ns; +223.440ns] or [-8.084%; +8.242%]

scenario:coreapiscenario-core_dispatch_with_results_1_listener

  • unstable execution_time [-94.059ns; +85.796ns] or [-6.989%; +6.375%]

scenario:coreapiscenario-core_dispatch_with_results_50_listeners

  • unstable execution_time [-4393.736ns; +4424.940ns] or [-9.070%; +9.135%]

scenario:coreapiscenario-core_dispatch_with_results_listeners

  • unstable execution_time [-818.787ns; +988.438ns] or [-8.059%; +9.729%]

scenario:packagesupdateimporteddependencies-import_many_stdlib_cached

  • unstable execution_time [-46.763µs; +71.996µs] or [-7.772%; +11.966%]

Known flaky benchmarks

These benchmarks are marked as flaky and will not trigger a failure. Modify FLAKY_BENCHMARKS_REGEX to control which benchmarks are marked as flaky.

Known flaky benchmarks without significant changes:

  • scenario:packagespackageforrootmodulemapping-cache_off

gnufede and others added 2 commits November 25, 2026 18:09
…rting them

Telemetry moves to ddtrace-internal, which can't import dd-trace-py's
AppSec settings. It now asks generic questions through telemetry_inputs:
whether to collect full dependency metadata, whether and how many API
endpoints to collect, and which configurations to report at import.
ddtrace/__init__.py answers them from the AppSec settings, read lazily
on each use, so behavior and the configuration report order are
unchanged. Without registrations telemetry falls back to the AppSec
defaults.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_threads moved to ddtrace.internal.native._threads, where it ships in
ddtrace-native. The serverless runtime-id test was the last importer of
the old path, so it imports the new one and the alias goes away.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gnufede
gnufede force-pushed the gnufede/package-split-layout branch from 82cd4cd to 9b8586c Compare November 25, 2026 17:14
@gnufede gnufede changed the title wip: package split layout refactor(telemetry): receive AppSec inputs and drop the _threads alias Nov 25, 2026
@gnufede gnufede added the changelog/no-changelog A changelog entry is not required for this PR. label Nov 25, 2026
@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

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

@gnufede
gnufede marked this pull request as ready for review November 25, 2026 19:02
@gnufede
gnufede requested review from a team as code owners November 25, 2026 19:02
@gnufede
gnufede requested review from avara1986, juanjux and lym953 and removed request for a team November 25, 2026 19:02
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T19:03:35.966829Z 9b8586c Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@gnufede

gnufede commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

@DataDog review

@gnufede
gnufede marked this pull request as draft November 25, 2026 19:03

@datadog-prod-us1-6 datadog-prod-us1-6 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.

Bits Code Review: PASS

More details

Static inspection supports preservation of AppSec runtime setting reads and configuration-report order. The human PR discussion contained no substantive review feedback.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 9b8586c

@datadog-prod-us1-6 datadog-prod-us1-6 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.

Bits Code Review: PASS

More details

AppSec settings remain lazily read through the registered hooks, preserving runtime updates and configuration reporting order. The static reviewer found no remaining callers of the removed _threads alias.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 9b8586c

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.

1 participant