Skip to content

Commit

Permalink
Merge branch '2.20' into backport-12029-to-2.20
Browse files Browse the repository at this point in the history
  • Loading branch information
taegyunkim authored Feb 4, 2025
2 parents 7c544fe + 57910a7 commit 4ba58c2
Show file tree
Hide file tree
Showing 234 changed files with 526 additions and 504 deletions.
2 changes: 1 addition & 1 deletion benchmarks/ddtrace_run/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def run(self):
env["DD_TRACE_API_VERSION"] = "v0.4"
code += """
import httpretty
from ddtrace import tracer
from ddtrace.trace import tracer
from ddtrace.internal.telemetry import telemetry_writer
httpretty.enable(allow_net_connect=False)
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/otel_span/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from opentelemetry.trace import set_tracer_provider

from ddtrace import config
from ddtrace import tracer
from ddtrace.opentelemetry import TracerProvider # Requires ``ddtrace>=1.11``
from ddtrace.trace import tracer


set_tracer_provider(TracerProvider())
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/span/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import bm.utils as utils

from ddtrace import config
from ddtrace import tracer
from ddtrace.trace import tracer


class Span(Scenario):
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/threading/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def create_trace(self, tracer: Tracer) -> None:
random.random()

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

# configure global tracer to drop traces rather
tracer.configure(writer=NoopWriter())
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/tracer/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Tracer(bm.Scenario):
def run(self):
# configure global tracer to drop traces rather than encoded and sent to
# an agent
from ddtrace import tracer
from ddtrace.trace import tracer

utils.drop_traces(tracer)
utils.drop_telemetry_events()
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/_trace/_span_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
SpanLinks can be set using :meth:`ddtrace.Span.link_span(...)` Ex::
from ddtrace import tracer
from ddtrace.trace import tracer
s1 = tracer.trace("s1")
s2 = tracer.trace("s2")
Expand Down
20 changes: 10 additions & 10 deletions ddtrace/_trace/pin.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(
# type: (...) -> None
if tracer is not None and tracer is not ddtrace.tracer:
deprecate(
"Initializing ddtrace.Pin with `tracer` argument is deprecated",
"Initializing ddtrace.trace.Pin with `tracer` argument is deprecated",
message="All Pin instances should use the global tracer instance",
removal_version="3.0.0",
)
Expand Down Expand Up @@ -79,15 +79,15 @@ def __repr__(self):
def _find(*objs):
# type: (Any) -> Optional[Pin]
"""
Return the first :class:`ddtrace.pin.Pin` found on any of the provided objects or `None` if none were found
Return the first :class:`ddtrace.trace.Pin` found on any of the provided objects or `None` if none were found
>>> pin = Pin._find(wrapper, instance, conn)
:param objs: The objects to search for a :class:`ddtrace.pin.Pin` on
:param objs: The objects to search for a :class:`ddtrace.trace.Pin` on
:type objs: List of objects
:rtype: :class:`ddtrace.pin.Pin`, None
:returns: The first found :class:`ddtrace.pin.Pin` or `None` is none was found
:rtype: :class:`ddtrace.trace.Pin`, None
:returns: The first found :class:`ddtrace.trace.Pin` or `None` is none was found
"""
for obj in objs:
pin = Pin.get_from(obj)
Expand All @@ -105,10 +105,10 @@ def get_from(obj):
>>> pin = Pin.get_from(conn)
:param obj: The object to look for a :class:`ddtrace.pin.Pin` on
:param obj: The object to look for a :class:`ddtrace.trace.Pin` on
:type obj: object
:rtype: :class:`ddtrace.pin.Pin`, None
:returns: :class:`ddtrace.pin.Pin` associated with the object, or None if none was found
:rtype: :class:`ddtrace.trace.Pin`, None
:returns: :class:`ddtrace.trace.Pin` associated with the object, or None if none was found
"""
if hasattr(obj, "__getddpin__"):
return obj.__getddpin__()
Expand Down Expand Up @@ -141,7 +141,7 @@ def override(
"""
if tracer is not None:
deprecate(
"Calling ddtrace.Pin.override(...) with the `tracer` argument is deprecated",
"Calling ddtrace.trace.Pin.override(...) with the `tracer` argument is deprecated",
message="All Pin instances should use the global tracer instance",
removal_version="3.0.0",
)
Expand Down Expand Up @@ -208,7 +208,7 @@ def clone(

if tracer is not None:
deprecate(
"Initializing ddtrace.Pin with `tracer` argument is deprecated",
"Initializing ddtrace.trace.Pin with `tracer` argument is deprecated",
message="All Pin instances should use the global tracer instance",
removal_version="3.0.0",
)
Expand Down
4 changes: 3 additions & 1 deletion ddtrace/_trace/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ def __init__(
if isinstance(rule, SamplingRule):
self.rules.append(rule)
elif config._raise:
raise TypeError("Rule {!r} must be a sub-class of type ddtrace.sampler.SamplingRules".format(rule))
raise TypeError(
"Rule {!r} must be a sub-class of type ddtrace._trace.sampler.SamplingRules".format(rule)
)

# DEV: sampling rule must come last
if effective_sample_rate is not None:
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/_trace/trace_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@


if TYPE_CHECKING:
from ddtrace import Span
from ddtrace._trace.span import Span


log = get_logger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/_trace/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class Tracer(object):
If you're running an application that will serve a single trace per thread,
you can use the global tracer instance::
from ddtrace import tracer
from ddtrace.trace import tracer
trace = tracer.trace('app.request', 'web-server').finish()
"""

Expand Down
2 changes: 1 addition & 1 deletion ddtrace/_trace/utils_botocore/aws_payload_tagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from typing import Dict
from typing import Optional

from ddtrace import Span
from ddtrace import config
from ddtrace._trace.span import Span
from ddtrace.vendor.jsonpath_ng import parse


Expand Down
2 changes: 1 addition & 1 deletion ddtrace/_trace/utils_botocore/span_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from typing import Dict
from typing import Optional

from ddtrace import Span
from ddtrace import config
from ddtrace._trace.span import Span
from ddtrace._trace.utils_botocore.aws_payload_tagging import AWSPayloadTagging
from ddtrace.constants import _ANALYTICS_SAMPLE_RATE_KEY
from ddtrace.constants import _SPAN_MEASURED_KEY
Expand Down
6 changes: 3 additions & 3 deletions ddtrace/appsec/_asm_request_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from typing import Union
from urllib import parse

from ddtrace._trace.span import Span
from ddtrace.appsec._constants import APPSEC
from ddtrace.appsec._constants import EXPLOIT_PREVENTION
from ddtrace.appsec._constants import SPAN_DATA_NAMES
Expand All @@ -27,6 +26,7 @@
from ddtrace.internal.constants import REQUEST_PATH_PARAMS
from ddtrace.internal.logger import get_logger
from ddtrace.settings.asm import config as asm_config
from ddtrace.trace import Span


if TYPE_CHECKING:
Expand Down Expand Up @@ -63,7 +63,7 @@ class ASM_Environment:
"""

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

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

current_span = tracer.current_span()
if current_span is None:
Expand Down
4 changes: 2 additions & 2 deletions ddtrace/appsec/_capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _asm_feature_is_required() -> bool:
return (_FEATURE_REQUIRED & flags) != 0


def _rc_capabilities(test_tracer: Optional[ddtrace.Tracer] = None) -> Flags:
def _rc_capabilities(test_tracer: Optional[ddtrace.trace.Tracer] = None) -> Flags:
tracer = ddtrace.tracer if test_tracer is None else test_tracer
value = Flags(0)
if ddtrace.config._remote_config_enabled:
Expand All @@ -74,7 +74,7 @@ def _rc_capabilities(test_tracer: Optional[ddtrace.Tracer] = None) -> Flags:
return value


def _appsec_rc_capabilities(test_tracer: Optional[ddtrace.Tracer] = None) -> str:
def _appsec_rc_capabilities(test_tracer: Optional[ddtrace.trace.Tracer] = None) -> str:
r"""return the bit representation of the composed capabilities in base64
bit 0: Reserved
bit 1: ASM 1-click Activation
Expand Down
4 changes: 2 additions & 2 deletions ddtrace/appsec/_exploit_prevention/stack_traces.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from typing import Iterable
from typing import Optional

from ddtrace._trace.span import Span
from ddtrace.appsec._constants import STACK_TRACE
from ddtrace.settings.asm import config as asm_config
from ddtrace.trace import Span


def report_stack(
Expand All @@ -33,7 +33,7 @@ def report_stack(
return False

if span is None:
from ddtrace import tracer
from ddtrace.trace import tracer

span = tracer.current_span()

Expand Down
2 changes: 1 addition & 1 deletion ddtrace/appsec/_iast/_iast_request_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from typing import Dict
from typing import Optional

from ddtrace._trace.span import Span
from ddtrace.appsec._constants import APPSEC
from ddtrace.appsec._constants import IAST
from ddtrace.appsec._iast import _is_iast_enabled
Expand All @@ -18,6 +17,7 @@
from ddtrace.internal import core
from ddtrace.internal.logger import get_logger
from ddtrace.internal.utils.formats import asbool
from ddtrace.trace import Span


log = get_logger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/appsec/_iast/processor.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from dataclasses import dataclass

from ddtrace._trace.processor import SpanProcessor
from ddtrace._trace.span import Span
from ddtrace.ext import SpanTypes
from ddtrace.internal.logger import get_logger
from ddtrace.trace import Span

from ._iast_request_context import _iast_end_request
from ._iast_request_context import _iast_start_request
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/appsec/_iast/taint_sinks/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from typing import Optional
from typing import Text

from ddtrace import tracer
from ddtrace.appsec._deduplications import deduplication
from ddtrace.appsec._trace_utils import _asm_manual_keep
from ddtrace.internal.logger import get_logger
from ddtrace.settings.asm import config as asm_config
from ddtrace.trace import tracer

from .._iast_request_context import get_iast_reporter
from .._iast_request_context import is_iast_request_enabled
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/appsec/_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import weakref

from ddtrace._trace.processor import SpanProcessor
from ddtrace._trace.span import Span
from ddtrace.appsec import _asm_request_context
from ddtrace.appsec._constants import APPSEC
from ddtrace.appsec._constants import DEFAULT
Expand All @@ -35,6 +34,7 @@
from ddtrace.internal.logger import get_logger
from ddtrace.internal.rate_limiter import RateLimiter
from ddtrace.settings.asm import config as asm_config
from ddtrace.trace import Span


log = get_logger(__name__)
Expand Down
6 changes: 3 additions & 3 deletions ddtrace/appsec/_remoteconfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from typing import Mapping
from typing import Optional

from ddtrace import Tracer
from ddtrace.appsec._capabilities import _asm_feature_is_required
from ddtrace.appsec._constants import PRODUCTS
from ddtrace.internal import forksafe
Expand All @@ -18,6 +17,7 @@
from ddtrace.internal.telemetry import telemetry_writer
from ddtrace.internal.telemetry.constants import TELEMETRY_APM_PRODUCT
from ddtrace.settings.asm import config as asm_config
from ddtrace.trace import Tracer


log = get_logger(__name__)
Expand Down Expand Up @@ -111,7 +111,7 @@ def _appsec_rules_data(features: Mapping[str, Any], test_tracer: Optional[Tracer
# Tracer is a parameter for testing propose
# Import tracer here to avoid a circular import
if test_tracer is None:
from ddtrace import tracer
from ddtrace.trace import tracer
else:
tracer = test_tracer

Expand Down Expand Up @@ -200,7 +200,7 @@ def _appsec_1click_activation(features: Mapping[str, Any], test_tracer: Optional
# Tracer is a parameter for testing propose
# Import tracer here to avoid a circular import
if test_tracer is None:
from ddtrace import tracer
from ddtrace.trace import tracer
else:
tracer = test_tracer

Expand Down
4 changes: 2 additions & 2 deletions ddtrace/appsec/_trace_utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from typing import Optional

from ddtrace import Tracer
from ddtrace import constants
from ddtrace._trace.span import Span
from ddtrace.appsec import _asm_request_context
from ddtrace.appsec._asm_request_context import call_waf_callback
from ddtrace.appsec._asm_request_context import get_blocked
Expand All @@ -18,6 +16,8 @@
from ddtrace.internal._exceptions import BlockingException
from ddtrace.internal.logger import get_logger
from ddtrace.settings.asm import config as asm_config
from ddtrace.trace import Span
from ddtrace.trace import Tracer


log = get_logger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/bootstrap/preload.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from ddtrace.internal.utils.formats import parse_tags_str # noqa:F401
from ddtrace.settings.asm import config as asm_config # noqa:F401
from ddtrace.settings.crashtracker import config as crashtracker_config
from ddtrace import tracer
from ddtrace.trace import tracer


import typing as t
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/context.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ddtrace._trace.context import Context # noqa: F401
from ddtrace.internal.utils.deprecations import DDTraceDeprecationWarning
from ddtrace.trace import Context # noqa: F401
from ddtrace.vendor.debtcollector import deprecate


Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/aiohttp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
the provided ``trace_app`` function must be used::
from aiohttp import web
from ddtrace import tracer, patch
from ddtrace.trace import tracer, patch
from ddtrace.contrib.aiohttp import trace_app
# create your application
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/bottle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
plugin to your app::
import bottle
from ddtrace import tracer
from ddtrace.trace import tracer
from ddtrace.contrib.bottle import TracePlugin
app = bottle.Bottle()
Expand Down
4 changes: 2 additions & 2 deletions ddtrace/contrib/cherrypy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
~~~~~
To install the middleware, add::
from ddtrace import tracer
from ddtrace.trace import tracer
from ddtrace.contrib.cherrypy import TraceMiddleware
and create a `TraceMiddleware` object::
Expand Down Expand Up @@ -40,7 +40,7 @@
import cherrypy
from ddtrace import tracer, Pin
from ddtrace.trace import tracer, Pin
from ddtrace.contrib.cherrypy import TraceMiddleware
TraceMiddleware(cherrypy, tracer, service="my-cherrypy-app")
Expand Down
Loading

0 comments on commit 4ba58c2

Please sign in to comment.