Skip to content

feat(di): enable code origins for entry spans when di is enabled #13593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 11, 2025

Conversation

tylfin
Copy link
Contributor

@tylfin tylfin commented Jun 4, 2025

Enable code origins for entry spans when dynamic instrumentation is enabled.

This also breaks up code origin entry and exit spans into separate classes. This include a new processor for entry spans, updates to configuration and product management, and additional tests to ensure functionality and coverage.

Refs: DEBUG-3787

Checklist

  • PR author has checked that all the criteria below are met
  • The PR description includes an overview of the change
  • The PR description articulates the motivation for the change
  • The change includes tests OR the PR description describes a testing strategy
  • The PR description notes risks associated with the change, if any
  • Newly-added code is easy to change
  • The change follows the library release note guidelines
  • The change includes or references documentation updates if necessary
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

Copy link
Contributor

github-actions bot commented Jun 4, 2025

CODEOWNERS have been resolved as:

releasenotes/notes/entry-spans-di-79eb3b63aab0ecbe.yaml                 @DataDog/apm-python
ddtrace/debugging/_origin/span.py                                       @DataDog/debugger-python
ddtrace/debugging/_products/code_origin/span.py                         @DataDog/debugger-python
ddtrace/internal/products.py                                            @DataDog/apm-core-python
ddtrace/internal/symbol_db/remoteconfig.py                              @DataDog/debugger-python
tests/debugging/live/test_live_debugger.py                              @DataDog/debugger-python
tests/debugging/origin/test_span.py                                     @DataDog/debugger-python
tests/internal/test_products.py                                         @DataDog/apm-core-python

@tylfin tylfin added the changelog/no-changelog A changelog entry is not required for this PR. label Jun 4, 2025
Copy link
Contributor

github-actions bot commented Jun 4, 2025

Bootstrap import analysis

Comparison of import times between this PR and base.

Summary

The average import time from this PR is: 274 ± 2 ms.

The average import time from base is: 276 ± 2 ms.

The import time difference between this PR and base is: -2.6 ± 0.1 ms.

Import time breakdown

The following import paths have grown:

ddtrace.auto 0.797 ms (0.29%)
ddtrace.bootstrap.sitecustomize 0.797 ms (0.29%)
ddtrace.bootstrap.preload 0.797 ms (0.29%)
ddtrace.internal.products 0.710 ms (0.26%)
importlib.metadata 0.710 ms (0.26%)
importlib.metadata._itertools 0.638 ms (0.23%)
importlib.abc 0.072 ms (0.03%)
importlib.resources 0.072 ms (0.03%)
importlib.resources._legacy 0.072 ms (0.03%)
ddtrace.internal.runtime.runtime_metrics 0.087 ms (0.03%)
ddtrace.internal.runtime.tag_collectors 0.087 ms (0.03%)

The following import paths have shrunk:

ddtrace.auto 2.813 ms (1.03%)
ddtrace.bootstrap.sitecustomize 2.134 ms (0.78%)
ddtrace.bootstrap.preload 2.134 ms (0.78%)
ddtrace.internal.products 0.712 ms (0.26%)
importlib.metadata 0.712 ms (0.26%)
importlib.abc 0.712 ms (0.26%)
importlib.resources 0.642 ms (0.23%)
ddtrace.internal.remoteconfig.client 0.654 ms (0.24%)
ddtrace.settings.crashtracker 0.082 ms (0.03%)
ddtrace 0.678 ms (0.25%)
ddtrace.internal._unpatched 0.022 ms (0.01%)

@tylfin tylfin force-pushed the tyler.finethy/DEBUG-3945 branch from b6744e8 to 71f3dab Compare June 4, 2025 16:55
@tylfin tylfin requested a review from P403n1x87 June 4, 2025 16:56
@tylfin tylfin force-pushed the tyler.finethy/DEBUG-3945 branch 2 times, most recently from 711df1e to 5fe80f9 Compare June 4, 2025 17:02
@pr-commenter
Copy link

pr-commenter bot commented Jun 4, 2025

Benchmarks

Benchmark execution time: 2025-06-10 17:37:07

Comparing candidate commit 4c12a8b in PR branch tyler.finethy/DEBUG-3945 with baseline commit e7c0d74 in branch main.

Found 0 performance improvements and 4 performance regressions! Performance is the same for 549 metrics, 3 unstable metrics.

scenario:iastaspects-format_map_aspect

  • 🟥 execution_time [+386.366ns; +501.052ns] or [+12.043%; +15.617%]

scenario:iastaspectsospath-ospathbasename_aspect

  • 🟥 execution_time [+760.286ns; +872.596ns] or [+18.058%; +20.725%]

scenario:telemetryaddmetric-1-distribution-metric-1-times

  • 🟥 execution_time [+334.098ns; +376.721ns] or [+11.432%; +12.891%]

scenario:telemetryaddmetric-1-gauge-metric-1-times

  • 🟥 execution_time [+258.596ns; +312.248ns] or [+12.160%; +14.682%]

@tylfin tylfin marked this pull request as ready for review June 5, 2025 12:10
@tylfin tylfin requested a review from a team as a code owner June 5, 2025 12:10
@tylfin tylfin requested a review from a team as a code owner June 5, 2025 20:41
@tylfin tylfin requested a review from juanjux June 5, 2025 20:41
@tylfin tylfin force-pushed the tyler.finethy/DEBUG-3945 branch 4 times, most recently from 0bca853 to 976cfa6 Compare June 6, 2025 13:24
@tylfin tylfin force-pushed the tyler.finethy/DEBUG-3945 branch 4 times, most recently from bbd6881 to 0b98b5a Compare June 6, 2025 16:19
@tylfin tylfin removed the changelog/no-changelog A changelog entry is not required for this PR. label Jun 6, 2025
@tylfin tylfin requested a review from a team as a code owner June 6, 2025 16:28
@tylfin tylfin requested a review from rachelyangdog June 6, 2025 16:28
@tylfin tylfin force-pushed the tyler.finethy/DEBUG-3945 branch from 2ba2c4a to 29125a9 Compare June 6, 2025 17:09
@tylfin tylfin force-pushed the tyler.finethy/DEBUG-3945 branch 3 times, most recently from 287c115 to 0e52ca2 Compare June 9, 2025 15:34
@tylfin tylfin force-pushed the tyler.finethy/DEBUG-3945 branch 2 times, most recently from f21c3ed to 00074f0 Compare June 10, 2025 12:34
tylfin added 5 commits June 10, 2025 11:31
- Extract `SpanCodeOriginProcessorEntry` base class to handle entry span processing
- Enable entry-only code origins when DI is enabled and span code origins aren't explicitly disabled
- Refactor `SpanCodeOriginProcessor` to inherit from entry processor for code reuse
- Update product lifecycle to conditionally enable entry vs full span processing

Refs: DEBUG-3787
- Add is_enabled() method to ProductManager for consistent product state checking
- Replace duplicate DI enablement logic in symbol_db/remoteconfig with centralized method
- Update code_origin/span to use ProductManager.is_enabled() instead of direct config access
- Add constants for better maintainability (CO_ENABLED, DI_PRODUCT_KEY)
@tylfin tylfin force-pushed the tyler.finethy/DEBUG-3945 branch from 00074f0 to 6781193 Compare June 10, 2025 15:31
@tylfin tylfin force-pushed the tyler.finethy/DEBUG-3945 branch from 6781193 to 4c12a8b Compare June 10, 2025 16:42
@tylfin tylfin enabled auto-merge (squash) June 10, 2025 18:02
Copy link
Contributor

@P403n1x87 P403n1x87 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@tylfin tylfin merged commit 1b249e1 into main Jun 11, 2025
740 checks passed
@tylfin tylfin deleted the tyler.finethy/DEBUG-3945 branch June 11, 2025 13:04
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.

3 participants