Skip to content

chore(tracing): remove deprecated modules [3.0] #12186

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 59 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
a75aa9a
chore(tracing): avoid using deprecated code internally
mabdinur Jan 27, 2025
c092d57
chore(tracing): remove deprecated modules 3.0
mabdinur Jan 27, 2025
d5ba6fa
fix docs
mabdinur Jan 27, 2025
a8b1d89
fix typing
mabdinur Jan 27, 2025
02edc9d
Merge branch 'munir/avoid-using-deprecated-apis-internally' into muni…
mabdinur Jan 27, 2025
d3f0d1a
don't remove deprecations
mabdinur Jan 27, 2025
deeeb84
update tests
mabdinur Jan 28, 2025
5d1a37e
Merge branch 'munir/avoid-using-deprecated-apis-internally' into muni…
mabdinur Jan 28, 2025
d0d966e
removing tracing
mabdinur Jan 28, 2025
4d6a286
update suitespec
mabdinur Jan 28, 2025
3ffdf51
remove deprecated tracing module from tests
mabdinur Jan 28, 2025
49348e9
remove test for deprecated module
mabdinur Jan 28, 2025
8351e5c
undo py version check removal and fix langchain/tornado
mabdinur Jan 28, 2025
851229a
don't remove py version check
mabdinur Jan 28, 2025
bbbf1db
Merge branch 'munir/avoid-using-deprecated-apis-internally' into muni…
mabdinur Jan 28, 2025
5320ea8
fix docs
mabdinur Jan 28, 2025
499e080
fix gevent and testagent
mabdinur Jan 28, 2025
bb45fb6
Merge branch 'munir/avoid-using-deprecated-apis-internally' into muni…
mabdinur Jan 28, 2025
2734d43
fix testagent test
mabdinur Jan 28, 2025
091b225
fix selenium
mabdinur Jan 28, 2025
47bb172
Merge branch 'munir/avoid-using-deprecated-apis-internally' into muni…
mabdinur Jan 28, 2025
b79a3b4
fix trace handlers
mabdinur Jan 28, 2025
7863735
fix failing civis test
mabdinur Jan 28, 2025
1a26940
fix rn
mabdinur Jan 28, 2025
ae9325a
fmt
mabdinur Jan 28, 2025
6d7762d
fix benchmarks
mabdinur Jan 28, 2025
8a31953
fmt
mabdinur Jan 29, 2025
b74e5b5
match imports
mabdinur Jan 29, 2025
589c330
revert __init__ changes
mabdinur Jan 29, 2025
f155c2a
Merge branch '3.x-staging' into munir/avoid-using-deprecated-apis-int…
mabdinur Jan 29, 2025
4cc7428
span updates
mabdinur Jan 29, 2025
51215c8
update tracer
mabdinur Jan 29, 2025
5185ce0
update tracer
mabdinur Jan 29, 2025
f2033b2
update Context
mabdinur Jan 29, 2025
2b94d7f
update pin
mabdinur Jan 29, 2025
c29f428
Merge branch '3.x-staging' into munir/avoid-using-deprecated-apis-int…
mabdinur Jan 29, 2025
76fb16a
Merge branch '3.x-staging' into munir/avoid-using-deprecated-apis-int…
mabdinur Jan 29, 2025
34d3471
Merge remote-tracking branch 'origin/munir/avoid-using-deprecated-api…
mabdinur Jan 29, 2025
c7bbf93
remove ddtrace.tracing
mabdinur Jan 29, 2025
3a78805
use testvis from upstream branch
mabdinur Jan 29, 2025
936754e
Merge branch 'munir/avoid-using-deprecated-apis-internally' into muni…
mabdinur Jan 29, 2025
fa3c329
Merge remote-tracking branch 'origin/3.x-staging' into munir/remove-d…
mabdinur Jan 29, 2025
0d46738
chore(aws_lambda): bump minimum supported version
mabdinur Jan 30, 2025
50ad4a4
ci(aws_Lambda): bump minimum tested version
mabdinur Jan 30, 2025
45731d3
Merge branch '3.x-staging' into munir/upgrade-min-aws-lambda
mabdinur Jan 30, 2025
8d2d4e8
test against more py versions
mabdinur Jan 31, 2025
ff6120c
bump pinned ddtrace version
mabdinur Jan 31, 2025
d87d210
Merge remote-tracking branch 'origin/3.x-staging' into munir/remove-d…
mabdinur Jan 31, 2025
75a8bf3
Merge branch 'munir/upgrade-min-aws-lambda' into munir/remove-depreca…
mabdinur Jan 31, 2025
f146f27
release note
mabdinur Jan 31, 2025
da40186
fix .riot deps
mabdinur Jan 31, 2025
fa89b16
Merge branch 'munir/upgrade-min-aws-lambda' into munir/remove-depreca…
mabdinur Jan 31, 2025
ed011de
Merge branch '3.x-staging' into munir/remove-deprecated-tracing-modules
mabdinur Jan 31, 2025
11a4b4e
rn
mabdinur Feb 3, 2025
8be593b
Update releasenotes/notes/remove-deprecated-tracing-modules-a129231d4…
mabdinur Feb 3, 2025
e97c33f
Merge branch '3.x-staging' into munir/remove-deprecated-tracing-modules
erikayasuda Feb 3, 2025
7290cfe
fix conflicts
mabdinur Feb 3, 2025
8581289
add back missing test
mabdinur Feb 4, 2025
dfc581f
see if this resolves civis pytest deadlocks
mabdinur Feb 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmarks/sampling_rule_matches/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import bm

from ddtrace._trace.sampling_rule import SamplingRule
from ddtrace._trace.span import Span
from ddtrace.sampling_rule import SamplingRule


def rands(size=6, chars=string.ascii_uppercase + string.digits):
Expand Down
42 changes: 5 additions & 37 deletions ddtrace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
from ._monkey import patch_all # noqa: E402
from .internal.compat import PYTHON_VERSION_INFO # noqa: E402
from .internal.utils.deprecations import DDTraceDeprecationWarning # noqa: E402
from ddtrace._trace.pin import Pin # noqa: E402
from ddtrace._trace.span import Span # noqa: E402
from ddtrace._trace.tracer import Tracer # noqa: E402

# TODO(munir): Remove the imports below in v3.0
from ddtrace._trace import pin as _p # noqa: E402, F401
from ddtrace._trace import span as _s # noqa: E402, F401
from ddtrace._trace import tracer as _t # noqa: E402, F401
from ddtrace.vendor import debtcollector
from .version import get_version # noqa: E402

Expand All @@ -39,15 +41,6 @@

_start_mini_agent()

# DEV: Import deprecated tracer module in order to retain side-effect of package
# initialization, which added this module to sys.modules. We catch deprecation
# warnings as this is only to retain a side effect of the package
# initialization.
# TODO: Remove this in v3.0 when the ddtrace/tracer.py module is removed
with warnings.catch_warnings():
warnings.simplefilter("ignore")
from .tracer import Tracer as _

__version__ = get_version()

# TODO: Deprecate accessing tracer from ddtrace.__init__ module in v4.0
Expand All @@ -57,36 +50,11 @@
__all__ = [
"patch",
"patch_all",
"Pin",
"Span",
"Tracer",
"config",
"DDTraceDeprecationWarning",
]


_DEPRECATED_TRACE_ATTRIBUTES = [
"Span",
"Tracer",
"Pin",
]


def __getattr__(name):
if name in _DEPRECATED_TRACE_ATTRIBUTES:
debtcollector.deprecate(
("%s.%s is deprecated" % (__name__, name)),
message="Import from ddtrace.trace instead.",
category=DDTraceDeprecationWarning,
removal_version="3.0.0",
)

if name in globals():
return globals()[name]

raise AttributeError("%s has no attribute %s", __name__, name)


def check_supported_python_version():
if PYTHON_VERSION_INFO < (3, 8):
deprecation_message = (
Expand Down
79 changes: 21 additions & 58 deletions ddtrace/constants.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
from ddtrace.internal.utils.deprecations import DDTraceDeprecationWarning as _DDTraceDeprecationWarning
from ddtrace.vendor import debtcollector as _debtcollector


# TODO: Deprecate and remove the SAMPLE_RATE_METRIC_KEY constant.
# This key enables legacy trace sampling support in the Datadog agent.
_SAMPLE_RATE_METRIC_KEY = SAMPLE_RATE_METRIC_KEY = "_sample_rate"
_SAMPLING_PRIORITY_KEY = SAMPLING_PRIORITY_KEY = "_sampling_priority_v1"
_ANALYTICS_SAMPLE_RATE_KEY = ANALYTICS_SAMPLE_RATE_KEY = "_dd1.sr.eausr"
_SAMPLING_AGENT_DECISION = SAMPLING_AGENT_DECISION = "_dd.agent_psr"
_SAMPLING_RULE_DECISION = SAMPLING_RULE_DECISION = "_dd.rule_psr"
_SAMPLING_LIMIT_DECISION = SAMPLING_LIMIT_DECISION = "_dd.limit_psr"
"""
This module contains constants used across ddtrace products.

Constants that should NOT be referenced by ddtrace users are marked with a leading underscore.
"""
_SAMPLING_PRIORITY_KEY = "_sampling_priority_v1"
_ANALYTICS_SAMPLE_RATE_KEY = "_dd1.sr.eausr"
_SAMPLING_AGENT_DECISION = "_dd.agent_psr"
_SAMPLING_RULE_DECISION = "_dd.rule_psr"
_SAMPLING_LIMIT_DECISION = "_dd.limit_psr"
_SINGLE_SPAN_SAMPLING_MECHANISM = "_dd.span_sampling.mechanism"
_SINGLE_SPAN_SAMPLING_RATE = "_dd.span_sampling.rule_rate"
_SINGLE_SPAN_SAMPLING_MAX_PER_SEC = "_dd.span_sampling.max_per_second"
_SINGLE_SPAN_SAMPLING_MAX_PER_SEC_NO_LIMIT = -1
_APM_ENABLED_METRIC_KEY = "_dd.apm.enabled"

_ORIGIN_KEY = ORIGIN_KEY = "_dd.origin"
_USER_ID_KEY = USER_ID_KEY = "_dd.p.usr.id"
_HOSTNAME_KEY = HOSTNAME_KEY = "_dd.hostname"
_RUNTIME_FAMILY = RUNTIME_FAMILY = "_dd.runtime_family"
_ORIGIN_KEY = "_dd.origin"
_USER_ID_KEY = "_dd.p.usr.id"
_HOSTNAME_KEY = "_dd.hostname"
_RUNTIME_FAMILY = "_dd.runtime_family"
ENV_KEY = "env"
VERSION_KEY = "version"
SERVICE_KEY = "service.name"
_BASE_SERVICE_KEY = BASE_SERVICE_KEY = "_dd.base_service"
_BASE_SERVICE_KEY = "_dd.base_service"
SERVICE_VERSION_KEY = "service.version"
SPAN_KIND = "span.kind"
_SPAN_MEASURED_KEY = SPAN_MEASURED_KEY = "_dd.measured"
_KEEP_SPANS_RATE_KEY = KEEP_SPANS_RATE_KEY = "_dd.tracer_kr"
_MULTIPLE_IP_HEADERS = MULTIPLE_IP_HEADERS = "_dd.multiple-ip-headers"
_SPAN_MEASURED_KEY = "_dd.measured"
_KEEP_SPANS_RATE_KEY = "_dd.tracer_kr"
_MULTIPLE_IP_HEADERS = "_dd.multiple-ip-headers"

APPSEC_ENV = "DD_APPSEC_ENABLED"
_CONFIG_ENDPOINT_ENV = CONFIG_ENDPOINT_ENV = "_DD_CONFIG_ENDPOINT"
_CONFIG_ENDPOINT_RETRIES_ENV = CONFIG_ENDPOINT_RETRIES_ENV = "_DD_CONFIG_ENDPOINT_RETRIES"
_CONFIG_ENDPOINT_TIMEOUT_ENV = CONFIG_ENDPOINT_TIMEOUT_ENV = "_DD_CONFIG_ENDPOINT_TIMEOUT"
_CONFIG_ENDPOINT_ENV = "_DD_CONFIG_ENDPOINT"
_CONFIG_ENDPOINT_RETRIES_ENV = "_DD_CONFIG_ENDPOINT_RETRIES"
_CONFIG_ENDPOINT_TIMEOUT_ENV = "_DD_CONFIG_ENDPOINT_TIMEOUT"
IAST_ENV = "DD_IAST_ENABLED"

MANUAL_DROP_KEY = "manual.drop"
Expand All @@ -53,38 +51,3 @@
AUTO_KEEP = 1
# Use this to explicitly inform the backend that a trace should be kept and stored.
USER_KEEP = 2


_DEPRECATED_MODULE_ATTRIBUTES = [
"ANALYTICS_SAMPLE_RATE_KEY",
"SAMPLE_RATE_METRIC_KEY",
"SAMPLING_PRIORITY_KEY",
"SAMPLING_AGENT_DECISION",
"SAMPLING_RULE_DECISION",
"SAMPLING_LIMIT_DECISION",
"USER_ID_KEY",
"ORIGIN_KEY",
"HOSTNAME_KEY",
"RUNTIME_FAMILY",
"BASE_SERVICE_KEY",
"SPAN_MEASURED_KEY",
"KEEP_SPANS_RATE_KEY",
"MULTIPLE_IP_HEADERS",
"CONFIG_ENDPOINT_ENV",
"CONFIG_ENDPOINT_RETRIES_ENV",
"CONFIG_ENDPOINT_TIMEOUT_ENV",
]


def __getattr__(name):
if name in _DEPRECATED_MODULE_ATTRIBUTES:
_debtcollector.deprecate(
("%s.%s is deprecated" % (__name__, name)),
category=_DDTraceDeprecationWarning,
removal_version="3.0.0",
)

if name in globals():
return globals()[name]

raise AttributeError("%s has no attribute %s", __name__, name)
10 changes: 0 additions & 10 deletions ddtrace/context.py

This file was deleted.

10 changes: 0 additions & 10 deletions ddtrace/filters.py

This file was deleted.

10 changes: 0 additions & 10 deletions ddtrace/pin.py

This file was deleted.

14 changes: 0 additions & 14 deletions ddtrace/provider.py

This file was deleted.

10 changes: 0 additions & 10 deletions ddtrace/sampler.py

This file was deleted.

10 changes: 0 additions & 10 deletions ddtrace/sampling_rule.py

This file was deleted.

10 changes: 0 additions & 10 deletions ddtrace/span.py

This file was deleted.

10 changes: 0 additions & 10 deletions ddtrace/tracer.py

This file was deleted.

11 changes: 0 additions & 11 deletions ddtrace/tracing/__init__.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
other:
- |
tracing: Removes the deprecated tracing modules and constants from the ``ddtrace`` package.
25 changes: 25 additions & 0 deletions tests/internal/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,3 +615,28 @@ def test_remoteconfig_header_tags(run_python_code_in_subprocess):
env=env,
)
assert status == 0, f"err={err.decode('utf-8')} out={out.decode('utf-8')}"


def test_config_public_properties_and_methods():
# Regression test to prevent unexpected changes to public attributes in Config
# By default most attributes should be private and set via Environment Variables
from ddtrace.settings import Config

public_attrs = set()
c = Config()
# Check for public attributes in Config
for attr in dir(c):
if not attr.startswith("_") and not attr.startswith("__"):
public_attrs.add(attr)
# Check for public keys in Config._config
for key in c._config:
if not key.startswith("_"):
public_attrs.add(key)

assert public_attrs == {
"service",
"service_mapping",
"env",
"tags",
"version",
}, public_attrs
2 changes: 1 addition & 1 deletion tests/llmobs/test_llmobs_ragas_evaluators.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ddtrace.llmobs._evaluators.ragas.context_precision import RagasContextPrecisionEvaluator
from ddtrace.llmobs._evaluators.ragas.faithfulness import RagasFaithfulnessEvaluator
from ddtrace.llmobs._evaluators.runner import EvaluatorRunner
from ddtrace.span import Span
from ddtrace.trace import Span
from tests.llmobs._utils import _expected_llmobs_llm_span_event
from tests.llmobs._utils import _expected_ragas_answer_relevancy_spans
from tests.llmobs._utils import _expected_ragas_context_precision_spans
Expand Down
9 changes: 0 additions & 9 deletions tests/suitespec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,6 @@ components:
- ddtrace/_trace/*
- ddtrace/trace/*
- ddtrace/constants.py
- ddtrace/context.py
- ddtrace/filters.py
- ddtrace/pin.py
- ddtrace/provider.py
- ddtrace/sampler.py
- ddtrace/sampling_rule.py
- ddtrace/span.py
- ddtrace/tracer.py
- ddtrace/tracing/*
- ddtrace/settings/__init__.py
- ddtrace/settings/config.py
- ddtrace/settings/http.py
Expand Down
15 changes: 0 additions & 15 deletions tests/tracer/test_tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2010,21 +2010,6 @@ def test_ctx_api():
assert core.get_items(["appsec.key"]) == [None]


@pytest.mark.subprocess(parametrize={"IMPORT_DDTRACE_TRACER": ["true", "false"]})
def test_import_ddtrace_tracer_not_module():
import os

import_ddtrace_tracer = os.environ["IMPORT_DDTRACE_TRACER"] == "true"

if import_ddtrace_tracer:
import ddtrace.tracer # noqa: F401

from ddtrace.trace import Tracer
from ddtrace.trace import tracer

assert isinstance(tracer, Tracer)


@pytest.mark.parametrize("sca_enabled", ["true", "false"])
@pytest.mark.parametrize("appsec_enabled", [True, False])
@pytest.mark.parametrize("iast_enabled", [True, False])
Expand Down
Loading