Skip to content

Commit 3bd50fa

Browse files
authored
chore(tracing): avoid using deprecated code internally [3.0] [backports 2.20] (#12182)
Backports: #12113 ## 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 1b2ec1c commit 3bd50fa

File tree

232 files changed

+518
-504
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

232 files changed

+518
-504
lines changed

benchmarks/ddtrace_run/scenario.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def run(self):
3232
env["DD_TRACE_API_VERSION"] = "v0.4"
3333
code += """
3434
import httpretty
35-
from ddtrace import tracer
35+
from ddtrace.trace import tracer
3636
from ddtrace.internal.telemetry import telemetry_writer
3737
3838
httpretty.enable(allow_net_connect=False)

benchmarks/otel_span/scenario.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from opentelemetry.trace import set_tracer_provider
77

88
from ddtrace import config
9-
from ddtrace import tracer
109
from ddtrace.opentelemetry import TracerProvider # Requires ``ddtrace>=1.11``
10+
from ddtrace.trace import tracer
1111

1212

1313
set_tracer_provider(TracerProvider())

benchmarks/span/scenario.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import bm.utils as utils
33

44
from ddtrace import config
5-
from ddtrace import tracer
5+
from ddtrace.trace import tracer
66

77

88
class Span(Scenario):

benchmarks/threading/scenario.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def create_trace(self, tracer: Tracer) -> None:
3939
random.random()
4040

4141
def run(self) -> Generator[Callable[[int], None], None, None]:
42-
from ddtrace import tracer
42+
from ddtrace.trace import tracer
4343

4444
# configure global tracer to drop traces rather
4545
tracer.configure(writer=NoopWriter())

benchmarks/tracer/scenario.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Tracer(bm.Scenario):
88
def run(self):
99
# configure global tracer to drop traces rather than encoded and sent to
1010
# an agent
11-
from ddtrace import tracer
11+
from ddtrace.trace import tracer
1212

1313
utils.drop_traces(tracer)
1414
utils.drop_telemetry_events()

ddtrace/_trace/_span_link.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
1616
SpanLinks can be set using :meth:`ddtrace.Span.link_span(...)` Ex::
1717
18-
from ddtrace import tracer
18+
from ddtrace.trace import tracer
1919
2020
s1 = tracer.trace("s1")
2121
s2 = tracer.trace("s2")

ddtrace/_trace/pin.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __init__(
4444
# type: (...) -> None
4545
if tracer is not None and tracer is not ddtrace.tracer:
4646
deprecate(
47-
"Initializing ddtrace.Pin with `tracer` argument is deprecated",
47+
"Initializing ddtrace.trace.Pin with `tracer` argument is deprecated",
4848
message="All Pin instances should use the global tracer instance",
4949
removal_version="3.0.0",
5050
)
@@ -79,15 +79,15 @@ def __repr__(self):
7979
def _find(*objs):
8080
# type: (Any) -> Optional[Pin]
8181
"""
82-
Return the first :class:`ddtrace.pin.Pin` found on any of the provided objects or `None` if none were found
82+
Return the first :class:`ddtrace.trace.Pin` found on any of the provided objects or `None` if none were found
8383
8484
8585
>>> pin = Pin._find(wrapper, instance, conn)
8686
87-
:param objs: The objects to search for a :class:`ddtrace.pin.Pin` on
87+
:param objs: The objects to search for a :class:`ddtrace.trace.Pin` on
8888
:type objs: List of objects
89-
:rtype: :class:`ddtrace.pin.Pin`, None
90-
:returns: The first found :class:`ddtrace.pin.Pin` or `None` is none was found
89+
:rtype: :class:`ddtrace.trace.Pin`, None
90+
:returns: The first found :class:`ddtrace.trace.Pin` or `None` is none was found
9191
"""
9292
for obj in objs:
9393
pin = Pin.get_from(obj)
@@ -105,10 +105,10 @@ def get_from(obj):
105105
106106
>>> pin = Pin.get_from(conn)
107107
108-
:param obj: The object to look for a :class:`ddtrace.pin.Pin` on
108+
:param obj: The object to look for a :class:`ddtrace.trace.Pin` on
109109
:type obj: object
110-
:rtype: :class:`ddtrace.pin.Pin`, None
111-
:returns: :class:`ddtrace.pin.Pin` associated with the object, or None if none was found
110+
:rtype: :class:`ddtrace.trace.Pin`, None
111+
:returns: :class:`ddtrace.trace.Pin` associated with the object, or None if none was found
112112
"""
113113
if hasattr(obj, "__getddpin__"):
114114
return obj.__getddpin__()
@@ -141,7 +141,7 @@ def override(
141141
"""
142142
if tracer is not None:
143143
deprecate(
144-
"Calling ddtrace.Pin.override(...) with the `tracer` argument is deprecated",
144+
"Calling ddtrace.trace.Pin.override(...) with the `tracer` argument is deprecated",
145145
message="All Pin instances should use the global tracer instance",
146146
removal_version="3.0.0",
147147
)
@@ -208,7 +208,7 @@ def clone(
208208

209209
if tracer is not None:
210210
deprecate(
211-
"Initializing ddtrace.Pin with `tracer` argument is deprecated",
211+
"Initializing ddtrace.trace.Pin with `tracer` argument is deprecated",
212212
message="All Pin instances should use the global tracer instance",
213213
removal_version="3.0.0",
214214
)

ddtrace/_trace/sampler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,9 @@ def __init__(
261261
if isinstance(rule, SamplingRule):
262262
self.rules.append(rule)
263263
elif config._raise:
264-
raise TypeError("Rule {!r} must be a sub-class of type ddtrace.sampler.SamplingRules".format(rule))
264+
raise TypeError(
265+
"Rule {!r} must be a sub-class of type ddtrace._trace.sampler.SamplingRules".format(rule)
266+
)
265267

266268
# DEV: sampling rule must come last
267269
if effective_sample_rate is not None:

ddtrace/_trace/trace_handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040

4141
if TYPE_CHECKING:
42-
from ddtrace import Span
42+
from ddtrace._trace.span import Span
4343

4444

4545
log = get_logger(__name__)

ddtrace/_trace/tracer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class Tracer(object):
189189
If you're running an application that will serve a single trace per thread,
190190
you can use the global tracer instance::
191191
192-
from ddtrace import tracer
192+
from ddtrace.trace import tracer
193193
trace = tracer.trace('app.request', 'web-server').finish()
194194
"""
195195

0 commit comments

Comments
 (0)