Skip to content

fix(profiling): scale the sampled exception count by interval when reporting - #21952

Open
gyuheon0h wants to merge 1 commit into
mainfrom
gyuheon0h/report-scaled-est-value-exception-profiling
Open

gyuheon0h wants to merge 1 commit into
mainfrom
gyuheon0h/report-scaled-est-value-exception-profiling

Conversation

@gyuheon0h

@gyuheon0h gyuheon0h commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Description

Exceptions get sampled with Poisson sampling with interval R. Therefore, when reporting, we should scale by R.

Some different options:

  1. Weight is 1 (previous behavior): The bias is -N(1 - 1/R) = -N, No variance, but reports raw sample count, ~1/Rth of reality
  2. Counter (C): The bias is ~-R, low, bounded variance, undercounts tail after last sample
  3. R (this PR): No bias, ~O(R * N) variance, unbiased since E[k·R] = N

Note: (2)'s bias is negligible compared to variance savings as N grows, but (3) is more statistically sound.

Testing

Unit test for upscaling

Risks

Additional Notes

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@gyuheon0h gyuheon0h changed the title fix: scale by interval R the reported exc count fix(profiling): scale the sampled exception count by interval when reporting Nov 20, 2026
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Pipelines  Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

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

@cit-pr-commenter-54b7da

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

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/profiling/collector/_exception.pyx                              @DataDog/profiling-python
releasenotes/notes/fix-exception-profiling-sample-count-scaling-b7ad25281db107bb.yaml  @DataDog/apm-python
tests/profiling/collector/test_exception.py                             @DataDog/profiling-python

@cit-pr-commenter-54b7da

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.base -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=101)
ddtrace.llmobs._integrations.bedrock_agents -×-> 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

@gyuheon0h
gyuheon0h marked this pull request as ready for review November 20, 2026 04:11
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/report-scaled-est-value-exception-profiling branch from d5ee1d8 to 491169c Compare November 20, 2026 04:11
@gyuheon0h
gyuheon0h requested review from a team as code owners November 20, 2026 04:11
@gyuheon0h
gyuheon0h requested a review from taegyunkim November 20, 2026 04:11
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 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-20T04:12:51.320245Z 491169c 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.

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 Bot left a comment

Copy link
Copy Markdown
Contributor

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

Weighting sampled exceptions by the configured interval matches the intended exception-volume estimator. No reportable defect emerged from static review; runtime behavior was not exercised.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 491169c

@pr-commenter

pr-commenter Bot commented Nov 20, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-11-20 04:34:55

Comparing candidate commit 491169c in PR branch gyuheon0h/report-scaled-est-value-exception-profiling with baseline commit a0211f2 in branch main.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 603 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 ----------------------------------'

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 [-741.215ns; +697.609ns] or [-6.856%; +6.453%]

scenario:coreapiscenario-core_dispatch_1_listener

  • unstable execution_time [-35.762ns; +40.358ns] or [-5.550%; +6.263%]

scenario:coreapiscenario-core_dispatch_50_listeners

  • unstable execution_time [-2127.625ns; +1629.225ns] or [-10.440%; +7.994%]

scenario:coreapiscenario-core_dispatch_exception_listeners

  • unstable execution_time [-1917.023ns; +1613.244ns] or [-9.917%; +8.346%]

scenario:coreapiscenario-core_dispatch_listeners

  • unstable execution_time [-368.178ns; +387.447ns] or [-8.437%; +8.878%]

scenario:coreapiscenario-core_dispatch_no_args_listeners

  • unstable execution_time [-235.160ns; +220.351ns] or [-8.523%; +7.986%]

scenario:coreapiscenario-core_dispatch_with_results_1_listener

  • unstable execution_time [-98.615ns; +101.196ns] or [-7.015%; +7.198%]

scenario:coreapiscenario-core_dispatch_with_results_50_listeners

  • unstable execution_time [-4751.349ns; +4321.711ns] or [-9.742%; +8.861%]

scenario:coreapiscenario-core_dispatch_with_results_listeners

  • unstable execution_time [-1024.140ns; +857.303ns] or [-9.820%; +8.220%]

scenario:packagesupdateimporteddependencies-import_many_stdlib_cached

  • unstable execution_time [-50.139µs; +60.855µs] or [-8.628%; +10.473%]

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

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