Skip to content

Commit 123e5bd

Browse files
taegyunkimnsrip-dd
andauthored
feat(profiling): mark v1 profiler to be deprecated (#15055)
## Description <!-- Provide an overview of the change and motivation for the change --> ## Testing <!-- Describe your testing strategy or note what tests are included --> ## Risks <!-- Note any risks associated with this change, or "None" if no risks --> ## Additional Notes <!-- Any other information that would be helpful for reviewers --> --------- Co-authored-by: Nick Ripley <[email protected]>
1 parent 2d1058c commit 123e5bd

File tree

3 files changed

+32
-23
lines changed

3 files changed

+32
-23
lines changed

ddtrace/settings/profiling.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,31 @@ def _parse_profiling_enabled(raw: str) -> bool:
8585
return False
8686

8787

88+
def _parse_v2_enabled(raw: str) -> bool:
89+
if sys.version_info >= (3, 14):
90+
return False
91+
92+
# Parse the boolean value
93+
raw_lc = raw.lower()
94+
enabled = raw_lc in ("1", "true", "yes", "on")
95+
96+
# Warn if user explicitly disabled v2 profiler (v1 is deprecated)
97+
if raw_lc in ("false", "0", "no", "off"):
98+
from ddtrace.internal.utils.deprecations import DDTraceDeprecationWarning
99+
from ddtrace.vendor.debtcollector import deprecate
100+
101+
deprecate(
102+
"Setting DD_PROFILING_STACK_V2_ENABLED=false is deprecated",
103+
message="The v1 stack profiler is deprecated and will be removed in a future version. "
104+
"Please migrate to the v2 stack profiler by removing DD_PROFILING_STACK_V2_ENABLED=false "
105+
"or setting it to true.",
106+
category=DDTraceDeprecationWarning,
107+
removal_version="4.0.0",
108+
)
109+
110+
return enabled
111+
112+
88113
def _update_git_metadata_tags(tags):
89114
"""
90115
Update profiler tags with git metadata
@@ -261,6 +286,7 @@ class ProfilingConfigStack(DDConfig):
261286
_v2_enabled = DDConfig.v(
262287
bool,
263288
"v2_enabled",
289+
parser=_parse_v2_enabled,
264290
# Not yet supported on 3.14
265291
default=sys.version_info < (3, 14),
266292
help_type="Boolean",
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
deprecations:
3+
- |
4+
profiling: The V1 stack profiler is deprecated and will be removed in 4.0.
5+
V2 has been enabled by default since v2.20.0.
6+
``DD_PROFILING_STACK_V2_ENABLED=false`` will no longer have an effect starting in 4.0.

tests/profiling/test_profiler.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import pytest
66

77
import ddtrace
8-
from ddtrace.internal.compat import PYTHON_VERSION_INFO
98
from ddtrace.profiling import collector
109
from ddtrace.profiling import profiler
1110
from ddtrace.profiling import scheduler
@@ -146,25 +145,3 @@ def test_profiler_serverless(monkeypatch):
146145
p = profiler.Profiler()
147146
assert isinstance(p._scheduler, scheduler.ServerlessScheduler)
148147
assert p.tags["functionname"] == "foobar"
149-
150-
151-
@pytest.mark.skipif(PYTHON_VERSION_INFO < (3, 9), reason="Python 3.8 throws a deprecation warning")
152-
@pytest.mark.subprocess()
153-
def test_profiler_ddtrace_deprecation():
154-
"""
155-
ddtrace interfaces loaded by the profiler can be marked deprecated, and we should update
156-
them when this happens. As reported by https://github.com/DataDog/dd-trace-py/issues/8881
157-
"""
158-
import warnings
159-
160-
with warnings.catch_warnings():
161-
warnings.simplefilter("error", DeprecationWarning)
162-
from ddtrace.profiling import _threading # noqa:F401
163-
from ddtrace.profiling import event # noqa:F401
164-
from ddtrace.profiling import profiler # noqa:F401
165-
from ddtrace.profiling import scheduler # noqa:F401
166-
from ddtrace.profiling.collector import _lock # noqa:F401
167-
from ddtrace.profiling.collector import _task # noqa:F401
168-
from ddtrace.profiling.collector import _traceback # noqa:F401
169-
from ddtrace.profiling.collector import memalloc # noqa:F401
170-
from ddtrace.profiling.collector import stack # noqa:F401

0 commit comments

Comments
 (0)