Skip to content

feat(tracing): support agentless adaptive sampling - #19938

Draft
mabdinur wants to merge 1 commit into
bob/agentless-settingfrom
codex/agentless-adaptive-sampling-plan
Draft

feat(tracing): support agentless adaptive sampling#19938
mabdinur wants to merge 1 commit into
bob/agentless-settingfrom
codex/agentless-adaptive-sampling-plan

Conversation

@mabdinur

@mabdinur mabdinur commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Expected end state

Agentless Python tracers can receive service-scoped adaptive-sampling rules through Remote Configuration and export selected traces directly through OTLP without losing sampling metadata.

  • Dynamic rules are applied before OTLP export.
  • Rejected traces are omitted from the exported payload.
  • Exported traces preserve the adaptive sample rate, sampling priority, and dynamic-rule mechanism -12.
  • The example app has one GET / endpoint that creates an OpenTelemetry span and custom metric.

Current diff

The stacked diff contains 3 files with 138 additions and 1 deletion:

  • Add focused OTLP coverage for agentless adaptive-sampling decisions and exported metadata.
  • Clarify the APM tracing Remote Configuration log message.
  • Add the single-endpoint OpenTelemetry sample app.
  • Keep testing instructions out of the PR so they can be distributed with the shareable sample ZIP.
  • Leave existing system tests and specifications unchanged.

Dependency

Nice to have: land Bob’s agentless settings PR #19631 first. This PR is currently based on bob/agentless-setting so its diff stays focused on adaptive sampling.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codeowners resolved as

Resolved from the full PR diff against bob/agentless-setting using the target branch CODEOWNERS file.
CODEOWNERS team requests not listed below are not required by the current file set.

ddtrace/_trace/product.py                                               @DataDog/apm-sdk-capabilities-python
scripts/agentless_rc_flask/app.py                                       @DataDog/python-guild
tests/opentelemetry/test_otlp_trace.py                                  @DataDog/apm-sdk-capabilities-python

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Circular import analysis

⚠️ Existing circular imports

There are 3 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
ddtrace.llmobs -> ddtrace.llmobs._evaluators -> ddtrace.llmobs._evaluators.format -> ddtrace.llmobs._experiment -> ddtrace.llmobs
ddtrace.appsec._asm_request_context -> ddtrace.appsec._iast._iast_request_context_base -> ddtrace.appsec._iast._iast_env -> ddtrace.appsec._iast.reporter -> ddtrace.appsec._exploit_prevention.stack_traces -> ddtrace.appsec._asm_request_context

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 28, 2026

Copy link
Copy Markdown

Dependency direction analysis

⚠️ Existing dependency direction violations

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

Show existing violations (showing 5 of 250 highest severity)
ddtrace.internal.tracemethods -×-> ddtrace.trace  (internal-core -> product:tracing, score=135)
ddtrace.internal.openfeature._span_enrichment -×-> ddtrace.trace  (product:openfeature -> product:tracing, score=133)
ddtrace.profiling.collector.stack -×-> ddtrace.trace  (product:profiling -> product:tracing, score=133)
ddtrace.llmobs._evaluators.runner -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=133)
ddtrace.debugging._exception.replay -×-> ddtrace.trace  (product:debugging -> product:tracing, score=133)

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

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Pipelines  Tests

Unblock PR with BitsAI

⚠️ Warnings

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

🚦 12 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-py | build linux serverless: [amd64, cp315-cp315, v113741238-d2b8243-manylinux2014_x86_64, 1] — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-py | core/internal 1/6 — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-py | core/internal 2/6 — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

View all 12 failed jobs.

ℹ️ 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: ba5757b | Docs | View more details | Give us feedback!

@mabdinur

Copy link
Copy Markdown
Contributor Author

Agentless Remote Config verification — ddstaging org / default site

Validated the Flask example against the ddstaging org (197728) while using its default DD_SITE=datadoghq.com routing.

  • Service/environment: service:moontest-agentless-rc env:staging
  • Trace intake: https://public-trace-http-intake.logs.datadoghq.com/v1/input
  • Remote Config: 3 successful direct polls; backend interval was 50 seconds
  • Traffic: 688 GET /adaptive/keep requests and 688 GET /adaptive/drop requests over 65 seconds
  • APM aggregate API: 12 retained GET /adaptive/keep spans and 12 retained GET /adaptive/drop spans at verification time
  • Sampling: no matching APM_TRACING RC payload was dispatched, so tracer logs show baseline sampling (mechanism=0, no matched rule)
  • Cleanup: app stopped cleanly and port 8051 is free

Open the filtered traces in ddstaging

Backend retention sampling means indexed counts are expected to be lower than emitted request counts.

@pr-commenter

pr-commenter Bot commented Aug 28, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-08-28 19:46:31

Comparing candidate commit ba5757b in PR branch codex/agentless-adaptive-sampling-plan with baseline commit ed2556f in branch bob/agentless-setting.

📊 Benchmarking dashboard

Found 0 performance improvements and 4 performance regressions! Performance is the same for 366 metrics, 9 unstable metrics, 1 known flaky benchmarks, 4 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:httppropagationextract-wsgi_valid_headers_all

  • 🟥 execution_time [+482.116ns; +542.010ns] or [+8.925%; +10.033%]

scenario:httppropagationinject-ids_only

  • 🟥 execution_time [+1.792µs; +1.962µs] or [+9.608%; +10.520%]

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

  • 🟥 execution_time [+444.215ns; +481.407ns] or [+16.787%; +18.192%]

scenario:tracer-small

  • 🟥 execution_time [+36.005µs; +38.113µs] or [+10.675%; +11.300%]

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 [-685.386ns; +781.174ns] or [-6.296%; +7.176%]

scenario:coreapiscenario-core_dispatch_1_listener

  • unstable execution_time [-33.739ns; +31.571ns] or [-5.542%; +5.186%]

scenario:coreapiscenario-core_dispatch_50_listeners

  • unstable execution_time [-1726.949ns; +1550.533ns] or [-10.189%; +9.148%]

scenario:coreapiscenario-core_dispatch_exception_listeners

  • unstable execution_time [-1473.005ns; +1075.802ns] or [-10.919%; +7.974%]

scenario:coreapiscenario-core_dispatch_listeners

  • unstable execution_time [-335.280ns; +306.697ns] or [-9.184%; +8.401%]

scenario:coreapiscenario-core_dispatch_no_args_listeners

  • unstable execution_time [-262.383ns; +231.365ns] or [-8.982%; +7.920%]

scenario:coreapiscenario-core_dispatch_with_results_1_listener

  • unstable execution_time [-66.760ns; +88.536ns] or [-5.793%; +7.683%]

scenario:coreapiscenario-core_dispatch_with_results_50_listeners

  • unstable execution_time [-3875.462ns; +4272.763ns] or [-9.398%; +10.362%]

scenario:coreapiscenario-core_dispatch_with_results_listeners

  • unstable execution_time [-674.577ns; +885.539ns] or [-8.283%; +10.873%]

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.

scenario:span-start

  • 🟥 execution_time [+1.869ms; +2.050ms] or [+12.841%; +14.085%]

Known flaky benchmarks without significant changes:

  • scenario:errortrackingflasksqli-baseline
  • scenario:flasksimple-iast-get
  • scenario:sethttpmeta-all-enabled
  • scenario:telemetryaddmetric-record-100-metrics

@mabdinur

Copy link
Copy Markdown
Contributor Author

Live service-only validation is now active in the dd-trace-py test org.

  • Service: moontest-agentless-rc
  • Environment: staging
  • Agentless intake: datadoghq.com
  • Remote Config: tracing_sampling_rate=0.5 targeted only to this service/environment
  • Tracer application: config dispatched as APM_TRACING; sampler updated without restart
  • Observed after application: 185 kept / 167 dropped across 352 decisions (52.6% kept)

The Flask app and continuous traffic generator remain running. No organization-wide ingestion target was changed.

@mabdinur
mabdinur changed the base branch from main to bob/agentless-setting August 28, 2026 18:20
@mabdinur
mabdinur changed the base branch from bob/agentless-setting to main August 28, 2026 18:21
@mabdinur
mabdinur changed the base branch from main to bob/agentless-setting August 28, 2026 18:46
@mabdinur
mabdinur force-pushed the codex/agentless-adaptive-sampling-plan branch from 2114282 to 338d022 Compare August 28, 2026 19:11
@mabdinur mabdinur added the changelog/no-changelog A changelog entry is not required for this PR. label Aug 28, 2026
@mabdinur
mabdinur force-pushed the codex/agentless-adaptive-sampling-plan branch from 338d022 to aadbaa0 Compare August 28, 2026 19:16
@mabdinur
mabdinur force-pushed the codex/agentless-adaptive-sampling-plan branch from aadbaa0 to ba5757b Compare August 28, 2026 19:17
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