Skip to content

Commit fa00ac0

Browse files
authored
Merge branch 'munir/avoid-using-deprecated-apis-internally' into munir/remove-deprecated-tracing-modules
2 parents ab33489 + a75aa9a commit fa00ac0

File tree

145 files changed

+274
-266
lines changed

Some content is hidden

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

145 files changed

+274
-266
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: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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__()

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 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

ddtrace/_trace/utils_botocore/aws_payload_tagging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from typing import Dict
66
from typing import Optional
77

8-
from ddtrace import Span
98
from ddtrace import config
9+
from ddtrace.trace import Span
1010
from ddtrace.vendor.jsonpath_ng import parse
1111

1212

ddtrace/_trace/utils_botocore/span_tags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from typing import Dict
44
from typing import Optional
55

6-
from ddtrace import Span
76
from ddtrace import config
87
from ddtrace._trace.utils_botocore.aws_payload_tagging import AWSPayloadTagging
98
from ddtrace.constants import _ANALYTICS_SAMPLE_RATE_KEY
@@ -14,6 +13,7 @@
1413
from ddtrace.ext import http
1514
from ddtrace.internal.constants import COMPONENT
1615
from ddtrace.internal.utils.formats import deep_getattr
16+
from ddtrace.trace import Span
1717

1818

1919
_PAYLOAD_TAGGER = AWSPayloadTagging()

ddtrace/appsec/_asm_request_context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class ASM_Environment:
6363
"""
6464

6565
def __init__(self, span: Optional[Span] = None):
66-
from ddtrace import tracer
66+
from ddtrace.trace import tracer
6767

6868
self.root = not in_asm_context()
6969
if self.root:
@@ -178,7 +178,7 @@ def update_span_metrics(span: Span, name: str, value: Union[float, int]) -> None
178178
def flush_waf_triggers(env: ASM_Environment) -> None:
179179
# Make sure we find a root span to attach the triggers to
180180
if env.span is None:
181-
from ddtrace import tracer
181+
from ddtrace.trace import tracer
182182

183183
current_span = tracer.current_span()
184184
if current_span is None:

ddtrace/appsec/_exploit_prevention/stack_traces.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def report_stack(
3333
return False
3434

3535
if span is None:
36-
from ddtrace import tracer
36+
from ddtrace.trace import tracer
3737

3838
span = tracer.current_span()
3939

ddtrace/appsec/_iast/taint_sinks/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
from typing import Optional
55
from typing import Text
66

7-
from ddtrace import tracer
87
from ddtrace.appsec._deduplications import deduplication
98
from ddtrace.appsec._trace_utils import _asm_manual_keep
109
from ddtrace.internal.logger import get_logger
1110
from ddtrace.settings.asm import config as asm_config
11+
from ddtrace.trace import tracer
1212

1313
from .._iast_request_context import get_iast_reporter
1414
from .._iast_request_context import is_iast_request_enabled

ddtrace/appsec/_remoteconfiguration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from typing import Mapping
66
from typing import Optional
77

8-
from ddtrace import Tracer
98
from ddtrace.appsec._capabilities import _asm_feature_is_required
109
from ddtrace.appsec._constants import PRODUCTS
1110
from ddtrace.internal.logger import get_logger
@@ -17,6 +16,7 @@
1716
from ddtrace.internal.telemetry import telemetry_writer
1817
from ddtrace.internal.telemetry.constants import TELEMETRY_APM_PRODUCT
1918
from ddtrace.settings.asm import config as asm_config
19+
from ddtrace.trace import Tracer
2020

2121

2222
log = get_logger(__name__)
@@ -109,7 +109,7 @@ def _appsec_rules_data(features: Mapping[str, Any], test_tracer: Optional[Tracer
109109
# Tracer is a parameter for testing propose
110110
# Import tracer here to avoid a circular import
111111
if test_tracer is None:
112-
from ddtrace import tracer
112+
from ddtrace.trace import tracer
113113
else:
114114
tracer = test_tracer
115115

@@ -198,7 +198,7 @@ def _appsec_1click_activation(features: Mapping[str, Any], test_tracer: Optional
198198
# Tracer is a parameter for testing propose
199199
# Import tracer here to avoid a circular import
200200
if test_tracer is None:
201-
from ddtrace import tracer
201+
from ddtrace.trace import tracer
202202
else:
203203
tracer = test_tracer
204204

ddtrace/appsec/_trace_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from typing import Optional
22

3-
from ddtrace import Tracer
43
from ddtrace import constants
54
from ddtrace._trace.span import Span
65
from ddtrace.appsec import _asm_request_context
@@ -18,6 +17,7 @@
1817
from ddtrace.internal._exceptions import BlockingException
1918
from ddtrace.internal.logger import get_logger
2019
from ddtrace.settings.asm import config as asm_config
20+
from ddtrace.trace import Tracer
2121

2222

2323
log = get_logger(__name__)

ddtrace/bootstrap/preload.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from ddtrace.internal.utils.formats import asbool # noqa:F401
1616
from ddtrace.internal.utils.formats import parse_tags_str # noqa:F401
1717
from ddtrace.settings.crashtracker import config as crashtracker_config
18-
from ddtrace import tracer
18+
from ddtrace.trace import tracer
1919

2020

2121
import typing as t

ddtrace/contrib/aiohttp/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
the provided ``trace_app`` function must be used::
4848
4949
from aiohttp import web
50-
from ddtrace import tracer, patch
50+
from ddtrace.trace import tracer, patch
5151
from ddtrace.contrib.aiohttp import trace_app
5252
5353
# create your application

ddtrace/contrib/bottle/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
plugin to your app::
44
55
import bottle
6-
from ddtrace import tracer
6+
from ddtrace.trace import tracer
77
from ddtrace.contrib.bottle import TracePlugin
88
99
app = bottle.Bottle()

ddtrace/contrib/cherrypy/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
~~~~~
88
To install the middleware, add::
99
10-
from ddtrace import tracer
10+
from ddtrace.trace import tracer
1111
from ddtrace.contrib.cherrypy import TraceMiddleware
1212
1313
and create a `TraceMiddleware` object::
@@ -40,7 +40,7 @@
4040
4141
import cherrypy
4242
43-
from ddtrace import tracer, Pin
43+
from ddtrace.trace import tracer, Pin
4444
from ddtrace.contrib.cherrypy import TraceMiddleware
4545
TraceMiddleware(cherrypy, tracer, service="my-cherrypy-app")
4646

ddtrace/contrib/falcon/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
To trace the falcon web framework, install the trace middleware::
33
44
import falcon
5-
from ddtrace import tracer
5+
from ddtrace.trace import tracer
66
from ddtrace.contrib.falcon import TraceMiddleware
77
88
mw = TraceMiddleware(tracer, 'my-falcon-app')
@@ -11,7 +11,7 @@
1111
You can also use the autopatching functionality::
1212
1313
import falcon
14-
from ddtrace import tracer, patch
14+
from ddtrace.trace import tracer, patch
1515
1616
patch(falcon=True)
1717

ddtrace/contrib/flask_cache/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
The tracer supports both `Flask-Cache <https://pythonhosted.org/Flask-Cache/>`_
66
and `Flask-Caching <https://flask-caching.readthedocs.io/>`_.
77
8-
To install the tracer, ``from ddtrace import tracer`` needs to be added::
8+
To install the tracer, ``from ddtrace.trace import tracer`` needs to be added::
99
10-
from ddtrace import tracer
10+
from ddtrace.trace import tracer
1111
from ddtrace.contrib.flask_cache import get_traced_cache
1212
1313
and the tracer needs to be initialized::
@@ -18,7 +18,7 @@
1818
1919
from flask import Flask
2020
21-
from ddtrace import tracer
21+
from ddtrace.trace import tracer
2222
from ddtrace.contrib.flask_cache import get_traced_cache
2323
2424
app = Flask(__name__)
@@ -35,7 +35,7 @@ def counter():
3535
3636
Use a specific ``Cache`` implementation with::
3737
38-
from ddtrace import tracer
38+
from ddtrace.trace import tracer
3939
from ddtrace.contrib.flask_cache import get_traced_cache
4040
4141
from flask_caching import Cache

ddtrace/contrib/internal/cassandra/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from cassandra.query import SimpleStatement
2121
import wrapt
2222

23-
from ddtrace import Span
2423
from ddtrace import config
2524
from ddtrace.constants import _ANALYTICS_SAMPLE_RATE_KEY
2625
from ddtrace.constants import _SPAN_MEASURED_KEY
@@ -40,6 +39,7 @@
4039
from ddtrace.internal.utils import get_argument_value
4140
from ddtrace.internal.utils.formats import deep_getattr
4241
from ddtrace.trace import Pin
42+
from ddtrace.trace import Span
4343

4444

4545
log = get_logger(__name__)

ddtrace/contrib/internal/flask_cache/tracers.py

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

2121

2222
if typing.TYPE_CHECKING: # pragma: no cover
23-
from ddtrace import Span # noqa:F401
23+
from ddtrace.trace import Span # noqa:F401
2424

2525

2626
log = logging.Logger(__name__)

ddtrace/contrib/internal/grpc/aio_client_interceptor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from grpc.aio._typing import ResponseIterableType
1212
from grpc.aio._typing import ResponseType
1313

14-
from ddtrace import Span
1514
from ddtrace import config
1615
from ddtrace.constants import _ANALYTICS_SAMPLE_RATE_KEY
1716
from ddtrace.constants import _SPAN_MEASURED_KEY
@@ -30,6 +29,7 @@
3029
from ddtrace.internal.schema.span_attribute_schema import SpanDirection
3130
from ddtrace.propagation.http import HTTPPropagator
3231
from ddtrace.trace import Pin
32+
from ddtrace.trace import Span
3333

3434

3535
log = get_logger(__name__)

ddtrace/contrib/internal/grpc/aio_server_interceptor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from grpc.aio._typing import ResponseType
1414
import wrapt
1515

16-
from ddtrace import Span # noqa:F401
1716
from ddtrace import config
1817
from ddtrace.constants import _ANALYTICS_SAMPLE_RATE_KEY
1918
from ddtrace.constants import _SPAN_MEASURED_KEY
@@ -30,6 +29,7 @@
3029
from ddtrace.internal.schema import schematize_url_operation
3130
from ddtrace.internal.schema.span_attribute_schema import SpanDirection
3231
from ddtrace.trace import Pin # noqa:F401
32+
from ddtrace.trace import Span # noqa:F401
3333

3434

3535
Continuation = Callable[[grpc.HandlerCallDetails], Awaitable[grpc.RpcMethodHandler]]

ddtrace/contrib/internal/mongoengine/trace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __call__(self, *args, **kwargs):
2929
client = self.__wrapped__(*args, **kwargs)
3030
pin = ddtrace.trace.Pin.get_from(self)
3131
if pin:
32-
# Calling ddtrace.pin.Pin(...) with the `tracer` argument generates a deprecation warning.
32+
# Calling ddtrace.trace.Pin(...) with the `tracer` argument generates a deprecation warning.
3333
# Remove this if statement when the `tracer` argument is removed
3434
if pin.tracer is ddtrace.tracer:
3535
ddtrace.trace.Pin(service=pin.service).onto(client)

0 commit comments

Comments
 (0)