Skip to content

fix(profiling): stub ImportError collectors so the profiler can skip them - #20005

Closed
vlad-scherbich wants to merge 2 commits into
mainfrom
vlad/315-profiling-collector-stubs
Closed

fix(profiling): stub ImportError collectors so the profiler can skip them#20005
vlad-scherbich wants to merge 2 commits into
mainfrom
vlad/315-profiling-collector-stubs

Conversation

@vlad-scherbich

@vlad-scherbich vlad-scherbich commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Description

Delta vs #19269: adds optional Cython collector import stubs and a fallback so the profiler can skip collectors whose optional extensions are unavailable.

The fallback raises CollectorUnavailable when that collector is started; it does not hide missing native module errors, add the native build, or change asyncio behavior.

Layer Meaning Which PR
Compiled Native prerequisite #19269
Armed Optional collector fallback this PR
Observable No standalone support claim

Testing

Risks

Additional Notes

changelog/no-changelog.

@vlad-scherbich vlad-scherbich added the changelog/no-changelog A changelog entry is not required for this PR. label Sep 1, 2026
@cit-pr-commenter-54b7da

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

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.llmobs -> ddtrace.llmobs._evaluators -> ddtrace.llmobs._evaluators.format -> ddtrace.llmobs._experiment -> ddtrace.llmobs
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.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 Sep 1, 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.

.gitlab-ci.yml                                                          @DataDog/python-guild @DataDog/apm-core-python
.gitlab/templates/build-base-venvs.yml                                  @DataDog/python-guild @DataDog/apm-core-python
ddtrace/internal/datadog/profiling/cmake/FindLibNative.cmake            @DataDog/profiling-python
ddtrace/internal/datadog/profiling/cmake/NativeHeaders.cmake            @DataDog/profiling-python
ddtrace/internal/datadog/profiling/dd_wrapper/src/sample.cpp            @DataDog/profiling-python
ddtrace/internal/datadog/profiling/ddup/CMakeLists.txt                  @DataDog/profiling-python
ddtrace/internal/datadog/profiling/stack/CMakeLists.txt                 @DataDog/profiling-python
ddtrace/internal/datadog/profiling/stack/echion/echion/cpython/tasks.h  @DataDog/profiling-python
ddtrace/internal/datadog/profiling/stack/fuzz/CMakeLists.txt            @DataDog/profiling-python
ddtrace/internal/datadog/profiling/stack/src/echion/frame.cc            @DataDog/profiling-python
ddtrace/internal/datadog/profiling/stack/test/CMakeLists.txt            @DataDog/profiling-python
ddtrace/internal/datadog/profiling/stack/test/test_cpython_layout_contracts.cpp  @DataDog/profiling-python
ddtrace/internal/datadog/profiling/stack/test/test_frame_state_315.cpp  @DataDog/profiling-python
ddtrace/profiling/collector/__init__.py                                 @DataDog/profiling-python
ddtrace/profiling/collector/asyncio.py                                  @DataDog/profiling-python
ddtrace/profiling/collector/exception.py                                @DataDog/profiling-python
ddtrace/profiling/collector/stack.py                                    @DataDog/profiling-python
ddtrace/profiling/collector/threading.py                                @DataDog/profiling-python
setup.py                                                                @DataDog/python-guild
tests/conftest.py                                                       @DataDog/python-guild
tests/profiling/collector/test_collector.py                             @DataDog/profiling-python
tests/profiling/test_profiler.py                                        @DataDog/profiling-python

@cit-pr-commenter-54b7da

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

Copy link
Copy Markdown

Dependency direction analysis

⚠️ Existing dependency direction violations

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

Show existing violations (showing 5 of 230 highest severity)
ddtrace.internal.tracemethods -×-> ddtrace.trace  (internal-core -> product:tracing, score=134)
ddtrace.llmobs._integrations.llama_index -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=132)
ddtrace.llmobs._integrations.mcp -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=132)
ddtrace.llmobs._integrations.bedrock -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=132)
ddtrace.llmobs._integrations.openai_agents -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=132)

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-prod-us1-5

datadog-prod-us1-5 Bot commented Sep 1, 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.

🚦 19 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-py | profiling/profile 11/23 — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-py | profiling/profile 13/23 — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-py | profiling_native_py315: [3.15, thread] — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

View all 19 failed jobs.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🔄 Datadog retried 15 tests - 3 passed on retry View in Datadog

Useful? React with 👍 / 👎

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

@vlad-scherbich
vlad-scherbich force-pushed the vlad/ddtracepy-315-profiling-collectors branch from 989dea6 to 551605d Compare September 2, 2026 16:09
@vlad-scherbich
vlad-scherbich force-pushed the vlad/315-profiling-collector-stubs branch from 59e31b4 to c8b40a3 Compare September 2, 2026 16:10
@vlad-scherbich
vlad-scherbich force-pushed the vlad/ddtracepy-315-profiling-collectors branch from 551605d to 33d1ad8 Compare September 2, 2026 19:10
@vlad-scherbich
vlad-scherbich force-pushed the vlad/315-profiling-collector-stubs branch from c8b40a3 to 11a47e3 Compare September 2, 2026 19:10
Base automatically changed from vlad/ddtracepy-315-profiling-collectors to vlad/ddtracepy-315-profiling-native September 2, 2026 19:23
@vlad-scherbich
vlad-scherbich force-pushed the vlad/315-profiling-collector-stubs branch from 11a47e3 to d9a17ef Compare September 2, 2026 19:34
@vlad-scherbich
vlad-scherbich force-pushed the vlad/ddtracepy-315-profiling-native branch from df5e2f7 to 6d624f8 Compare September 2, 2026 20:15
@vlad-scherbich
vlad-scherbich force-pushed the vlad/315-profiling-collector-stubs branch 2 times, most recently from 92912f5 to 8421ef7 Compare September 3, 2026 02:10
@vlad-scherbich
vlad-scherbich force-pushed the vlad/ddtracepy-315-profiling-native branch from 79b8faf to ddba58a Compare September 4, 2026 18:57
@vlad-scherbich
vlad-scherbich force-pushed the vlad/315-profiling-collector-stubs branch from 8421ef7 to 59eb80b Compare September 4, 2026 19:01
Base automatically changed from vlad/ddtracepy-315-profiling-native to main September 9, 2026 14:25
Carry the profiling-native C++, Rust-header, CMake, setup, test, and CI changes for Python 3.15.
@vlad-scherbich
vlad-scherbich force-pushed the vlad/315-profiling-collector-stubs branch from 59eb80b to 5f2fb11 Compare September 9, 2026 20:12
@vlad-scherbich

Copy link
Copy Markdown
Contributor Author

Revisit if becomes a problem

@pr-commenter

pr-commenter Bot commented Sep 9, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-09-09 21:03:09

Comparing candidate commit 5f2fb11 in PR branch vlad/315-profiling-collector-stubs with baseline commit 93fed02 in branch main.

📊 Benchmarking dashboard

Found 0 performance improvements and 1 performance regressions! Performance is the same for 532 metrics, 10 unstable metrics, 7 known flaky benchmarks, 17 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:samplingrules-high_match

  • 🟥 execution_time [+11.655µs; +14.014µs] or [+7.378%; +8.871%]

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 [-700.211ns; +762.390ns] or [-6.349%; +6.913%]

scenario:coreapiscenario-core_dispatch_1_listener

  • unstable execution_time [-28.870ns; +37.251ns] or [-4.730%; +6.104%]

scenario:coreapiscenario-core_dispatch_50_listeners

  • unstable execution_time [-1714.265ns; +1567.146ns] or [-10.035%; +9.174%]

scenario:coreapiscenario-core_dispatch_exception_listeners

  • unstable execution_time [-1202.817ns; +1224.050ns] or [-9.205%; +9.368%]

scenario:coreapiscenario-core_dispatch_listeners

  • unstable execution_time [-354.896ns; +303.938ns] or [-9.581%; +8.205%]

scenario:coreapiscenario-core_dispatch_no_args_listeners

  • unstable execution_time [-257.880ns; +245.608ns] or [-8.796%; +8.377%]

scenario:coreapiscenario-core_dispatch_with_results_1_listener

  • unstable execution_time [-54.659ns; +99.788ns] or [-4.775%; +8.717%]

scenario:coreapiscenario-core_dispatch_with_results_50_listeners

  • unstable execution_time [-3987.506ns; +4121.776ns] or [-9.677%; +10.003%]

scenario:coreapiscenario-core_dispatch_with_results_listeners

  • unstable execution_time [-735.124ns; +807.529ns] or [-9.061%; +9.953%]

scenario:packagesupdateimporteddependencies-import_many_stdlib_cached

  • unstable execution_time [-61.008µs; +50.531µs] or [-10.386%; +8.603%]

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:httppropagationinject-ids_only

  • 🟥 execution_time [+2.011µs; +2.201µs] or [+11.987%; +13.120%]

scenario:iastaspects-upper_noaspect

  • 🟥 execution_time [+13.382µs; +16.523µs] or [+7.985%; +9.859%]

scenario:iastaspectsospath-ospathbasename_aspect

  • 🟥 execution_time [+131.435µs; +137.906µs] or [+33.787%; +35.451%]

scenario:iastaspectssplit-rsplit_aspect

  • 🟥 execution_time [+20.781µs; +24.651µs] or [+14.848%; +17.612%]

scenario:span-start

  • 🟥 execution_time [+1.452ms; +1.571ms] or [+10.153%; +10.981%]

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

  • 🟥 execution_time [+442.079ns; +484.139ns] or [+15.931%; +17.447%]

scenario:tracer-small

  • 🟥 execution_time [+38.171µs; +41.036µs] or [+11.738%; +12.619%]

Known flaky benchmarks without significant changes:

  • scenario:errortrackingflasksqli-baseline
  • scenario:flasksimple-iast-get
  • scenario:iastaspects-casefold_aspect
  • scenario:iastaspects-casefold_noaspect
  • scenario:iastaspects-index_aspect
  • scenario:iastaspects-ljust_noaspect
  • scenario:iastaspects-lower_aspect
  • scenario:iastaspects-replace_aspect
  • scenario:iastaspects-rstrip_aspect
  • scenario:iastaspects-swapcase_aspect
  • scenario:iastaspects-title_noaspect
  • scenario:iastaspects-translate_aspect
  • scenario:iastaspects-translate_noaspect
  • scenario:packagespackageforrootmodulemapping-cache_off
  • scenario:packagespackageforrootmodulemapping-cache_on
  • scenario:sethttpmeta-all-enabled
  • scenario:telemetryaddmetric-record-100-metrics

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