Skip to content

Commit ff14361

Browse files
authored
chore(tracing): remove deprecated modules [3.0] (#12111)
1 parent ff6120c commit ff14361

15 files changed

+26
-215
lines changed

benchmarks/sampling_rule_matches/scenario.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import bm
66

7+
from ddtrace._trace.sampling_rule import SamplingRule
78
from ddtrace._trace.span import Span
8-
from ddtrace.sampling_rule import SamplingRule
99

1010

1111
def rands(size=6, chars=string.ascii_uppercase + string.digits):

ddtrace/__init__.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
from ._monkey import patch_all # noqa: E402
2828
from .internal.compat import PYTHON_VERSION_INFO # noqa: E402
2929
from .internal.utils.deprecations import DDTraceDeprecationWarning # noqa: E402
30-
from ddtrace._trace.pin import Pin # noqa: E402
31-
from ddtrace._trace.span import Span # noqa: E402
32-
from ddtrace._trace.tracer import Tracer # noqa: E402
3330
from ddtrace.vendor import debtcollector
3431
from .version import get_version # noqa: E402
3532

@@ -39,15 +36,6 @@
3936

4037
_start_mini_agent()
4138

42-
# DEV: Import deprecated tracer module in order to retain side-effect of package
43-
# initialization, which added this module to sys.modules. We catch deprecation
44-
# warnings as this is only to retain a side effect of the package
45-
# initialization.
46-
# TODO: Remove this in v3.0 when the ddtrace/tracer.py module is removed
47-
with warnings.catch_warnings():
48-
warnings.simplefilter("ignore")
49-
from .tracer import Tracer as _
50-
5139
__version__ = get_version()
5240

5341
# TODO: Deprecate accessing tracer from ddtrace.__init__ module in v4.0
@@ -57,36 +45,11 @@
5745
__all__ = [
5846
"patch",
5947
"patch_all",
60-
"Pin",
61-
"Span",
62-
"Tracer",
6348
"config",
6449
"DDTraceDeprecationWarning",
6550
]
6651

6752

68-
_DEPRECATED_TRACE_ATTRIBUTES = [
69-
"Span",
70-
"Tracer",
71-
"Pin",
72-
]
73-
74-
75-
def __getattr__(name):
76-
if name in _DEPRECATED_TRACE_ATTRIBUTES:
77-
debtcollector.deprecate(
78-
("%s.%s is deprecated" % (__name__, name)),
79-
message="Import from ddtrace.trace instead.",
80-
category=DDTraceDeprecationWarning,
81-
removal_version="3.0.0",
82-
)
83-
84-
if name in globals():
85-
return globals()[name]
86-
87-
raise AttributeError("%s has no attribute %s", __name__, name)
88-
89-
9053
def check_supported_python_version():
9154
if PYTHON_VERSION_INFO < (3, 8):
9255
deprecation_message = (

ddtrace/constants.py

Lines changed: 21 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,37 @@
1-
from ddtrace.internal.utils.deprecations import DDTraceDeprecationWarning as _DDTraceDeprecationWarning
2-
from ddtrace.vendor import debtcollector as _debtcollector
3-
4-
5-
# TODO: Deprecate and remove the SAMPLE_RATE_METRIC_KEY constant.
6-
# This key enables legacy trace sampling support in the Datadog agent.
7-
_SAMPLE_RATE_METRIC_KEY = SAMPLE_RATE_METRIC_KEY = "_sample_rate"
8-
_SAMPLING_PRIORITY_KEY = SAMPLING_PRIORITY_KEY = "_sampling_priority_v1"
9-
_ANALYTICS_SAMPLE_RATE_KEY = ANALYTICS_SAMPLE_RATE_KEY = "_dd1.sr.eausr"
10-
_SAMPLING_AGENT_DECISION = SAMPLING_AGENT_DECISION = "_dd.agent_psr"
11-
_SAMPLING_RULE_DECISION = SAMPLING_RULE_DECISION = "_dd.rule_psr"
12-
_SAMPLING_LIMIT_DECISION = SAMPLING_LIMIT_DECISION = "_dd.limit_psr"
1+
"""
2+
This module contains constants used across ddtrace products.
3+
4+
Constants that should NOT be referenced by ddtrace users are marked with a leading underscore.
5+
"""
6+
_SAMPLING_PRIORITY_KEY = "_sampling_priority_v1"
7+
_ANALYTICS_SAMPLE_RATE_KEY = "_dd1.sr.eausr"
8+
_SAMPLING_AGENT_DECISION = "_dd.agent_psr"
9+
_SAMPLING_RULE_DECISION = "_dd.rule_psr"
10+
_SAMPLING_LIMIT_DECISION = "_dd.limit_psr"
1311
_SINGLE_SPAN_SAMPLING_MECHANISM = "_dd.span_sampling.mechanism"
1412
_SINGLE_SPAN_SAMPLING_RATE = "_dd.span_sampling.rule_rate"
1513
_SINGLE_SPAN_SAMPLING_MAX_PER_SEC = "_dd.span_sampling.max_per_second"
1614
_SINGLE_SPAN_SAMPLING_MAX_PER_SEC_NO_LIMIT = -1
1715
_APM_ENABLED_METRIC_KEY = "_dd.apm.enabled"
1816

19-
_ORIGIN_KEY = ORIGIN_KEY = "_dd.origin"
20-
_USER_ID_KEY = USER_ID_KEY = "_dd.p.usr.id"
21-
_HOSTNAME_KEY = HOSTNAME_KEY = "_dd.hostname"
22-
_RUNTIME_FAMILY = RUNTIME_FAMILY = "_dd.runtime_family"
17+
_ORIGIN_KEY = "_dd.origin"
18+
_USER_ID_KEY = "_dd.p.usr.id"
19+
_HOSTNAME_KEY = "_dd.hostname"
20+
_RUNTIME_FAMILY = "_dd.runtime_family"
2321
ENV_KEY = "env"
2422
VERSION_KEY = "version"
2523
SERVICE_KEY = "service.name"
26-
_BASE_SERVICE_KEY = BASE_SERVICE_KEY = "_dd.base_service"
24+
_BASE_SERVICE_KEY = "_dd.base_service"
2725
SERVICE_VERSION_KEY = "service.version"
2826
SPAN_KIND = "span.kind"
29-
_SPAN_MEASURED_KEY = SPAN_MEASURED_KEY = "_dd.measured"
30-
_KEEP_SPANS_RATE_KEY = KEEP_SPANS_RATE_KEY = "_dd.tracer_kr"
31-
_MULTIPLE_IP_HEADERS = MULTIPLE_IP_HEADERS = "_dd.multiple-ip-headers"
27+
_SPAN_MEASURED_KEY = "_dd.measured"
28+
_KEEP_SPANS_RATE_KEY = "_dd.tracer_kr"
29+
_MULTIPLE_IP_HEADERS = "_dd.multiple-ip-headers"
3230

3331
APPSEC_ENV = "DD_APPSEC_ENABLED"
34-
_CONFIG_ENDPOINT_ENV = CONFIG_ENDPOINT_ENV = "_DD_CONFIG_ENDPOINT"
35-
_CONFIG_ENDPOINT_RETRIES_ENV = CONFIG_ENDPOINT_RETRIES_ENV = "_DD_CONFIG_ENDPOINT_RETRIES"
36-
_CONFIG_ENDPOINT_TIMEOUT_ENV = CONFIG_ENDPOINT_TIMEOUT_ENV = "_DD_CONFIG_ENDPOINT_TIMEOUT"
32+
_CONFIG_ENDPOINT_ENV = "_DD_CONFIG_ENDPOINT"
33+
_CONFIG_ENDPOINT_RETRIES_ENV = "_DD_CONFIG_ENDPOINT_RETRIES"
34+
_CONFIG_ENDPOINT_TIMEOUT_ENV = "_DD_CONFIG_ENDPOINT_TIMEOUT"
3735
IAST_ENV = "DD_IAST_ENABLED"
3836

3937
MANUAL_DROP_KEY = "manual.drop"
@@ -53,38 +51,3 @@
5351
AUTO_KEEP = 1
5452
# Use this to explicitly inform the backend that a trace should be kept and stored.
5553
USER_KEEP = 2
56-
57-
58-
_DEPRECATED_MODULE_ATTRIBUTES = [
59-
"ANALYTICS_SAMPLE_RATE_KEY",
60-
"SAMPLE_RATE_METRIC_KEY",
61-
"SAMPLING_PRIORITY_KEY",
62-
"SAMPLING_AGENT_DECISION",
63-
"SAMPLING_RULE_DECISION",
64-
"SAMPLING_LIMIT_DECISION",
65-
"USER_ID_KEY",
66-
"ORIGIN_KEY",
67-
"HOSTNAME_KEY",
68-
"RUNTIME_FAMILY",
69-
"BASE_SERVICE_KEY",
70-
"SPAN_MEASURED_KEY",
71-
"KEEP_SPANS_RATE_KEY",
72-
"MULTIPLE_IP_HEADERS",
73-
"CONFIG_ENDPOINT_ENV",
74-
"CONFIG_ENDPOINT_RETRIES_ENV",
75-
"CONFIG_ENDPOINT_TIMEOUT_ENV",
76-
]
77-
78-
79-
def __getattr__(name):
80-
if name in _DEPRECATED_MODULE_ATTRIBUTES:
81-
_debtcollector.deprecate(
82-
("%s.%s is deprecated" % (__name__, name)),
83-
category=_DDTraceDeprecationWarning,
84-
removal_version="3.0.0",
85-
)
86-
87-
if name in globals():
88-
return globals()[name]
89-
90-
raise AttributeError("%s has no attribute %s", __name__, name)

ddtrace/context.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

ddtrace/filters.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

ddtrace/pin.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

ddtrace/provider.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

ddtrace/sampler.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

ddtrace/sampling_rule.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

ddtrace/span.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

ddtrace/tracer.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

ddtrace/tracing/__init__.py

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
other:
3+
- |
4+
tracing: Removes the deprecated tracing modules `ddtrace` package.

tests/suitespec.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,6 @@ components:
116116
- ddtrace/_trace/*
117117
- ddtrace/trace/*
118118
- ddtrace/constants.py
119-
- ddtrace/context.py
120-
- ddtrace/filters.py
121-
- ddtrace/pin.py
122-
- ddtrace/provider.py
123-
- ddtrace/sampler.py
124-
- ddtrace/sampling_rule.py
125-
- ddtrace/span.py
126-
- ddtrace/tracer.py
127-
- ddtrace/tracing/*
128119
- ddtrace/settings/__init__.py
129120
- ddtrace/settings/config.py
130121
- ddtrace/settings/http.py

tests/tracer/test_tracer.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2010,21 +2010,6 @@ def test_ctx_api():
20102010
assert core.get_items(["appsec.key"]) == [None]
20112011

20122012

2013-
@pytest.mark.subprocess(parametrize={"IMPORT_DDTRACE_TRACER": ["true", "false"]})
2014-
def test_import_ddtrace_tracer_not_module():
2015-
import os
2016-
2017-
import_ddtrace_tracer = os.environ["IMPORT_DDTRACE_TRACER"] == "true"
2018-
2019-
if import_ddtrace_tracer:
2020-
import ddtrace.tracer # noqa: F401
2021-
2022-
from ddtrace.trace import Tracer
2023-
from ddtrace.trace import tracer
2024-
2025-
assert isinstance(tracer, Tracer)
2026-
2027-
20282013
@pytest.mark.parametrize("sca_enabled", ["true", "false"])
20292014
@pytest.mark.parametrize("appsec_enabled", [True, False])
20302015
@pytest.mark.parametrize("iast_enabled", [True, False])

0 commit comments

Comments
 (0)