Skip to content

Commit a9f1040

Browse files
P403n1x87alyshawang
authored andcommitted
feat(co): add in-product enablement support (#13633)
We add support for in-product enablement to code origin for spans. ## Checklist - [x] 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](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) - The change includes or references documentation updates if necessary - Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] 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](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) 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](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
1 parent 24faf24 commit a9f1040

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

ddtrace/debugging/_products/code_origin/span.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import enum
2+
13
from ddtrace.internal.products import manager as product_manager
24
from ddtrace.settings._core import ValueSource
35
from ddtrace.settings.code_origin import config
@@ -14,6 +16,12 @@ def post_preload():
1416
pass
1517

1618

19+
def _start():
20+
from ddtrace.debugging._origin.span import SpanCodeOriginProcessorEntry
21+
22+
SpanCodeOriginProcessorEntry.enable()
23+
24+
1725
def start():
1826
if config.span.enabled:
1927
from ddtrace.debugging._origin.span import SpanCodeOriginProcessorEntry
@@ -33,6 +41,12 @@ def restart(join=False):
3341
pass
3442

3543

44+
def _stop():
45+
from ddtrace.debugging._origin.span import SpanCodeOriginProcessorEntry
46+
47+
SpanCodeOriginProcessorEntry.disable()
48+
49+
3650
def stop(join=False):
3751
if config.span.enabled:
3852
from ddtrace.debugging._origin.span import SpanCodeOriginProcessorEntry
@@ -48,3 +62,13 @@ def stop(join=False):
4862

4963
def at_exit(join=False):
5064
stop(join=join)
65+
66+
67+
class APMCapabilities(enum.IntFlag):
68+
APM_TRACING_ENABLE_CODE_ORIGIN = 1 << 40
69+
70+
71+
def apm_tracing_rc(lib_config, _config):
72+
if (enabled := lib_config.get("code_origin_enabled")) is not None:
73+
should_start = (config.span.spec.enabled.full_name not in config.source or config.span.enabled) and enabled
74+
_start() if should_start else _stop()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
features:
3+
- |
4+
code origin: added support for in-product enablement.

0 commit comments

Comments
 (0)