Skip to content

Commit

Permalink
Merge branch '3.x-staging' into taegyunkim/prof-11194-windows-libdd
Browse files Browse the repository at this point in the history
  • Loading branch information
taegyunkim authored Feb 4, 2025
2 parents 2bce602 + 1245846 commit 238d262
Show file tree
Hide file tree
Showing 346 changed files with 1,378 additions and 5,819 deletions.
2 changes: 1 addition & 1 deletion benchmarks/bm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def process_trace(self, trace):


def drop_traces(tracer):
tracer.configure(settings={"FILTERS": [_DropTraces()]})
tracer.configure(trace_processors=[_DropTraces()])


def drop_telemetry_events():
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/rate_limiter/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def _(loops):
windows = [start + (i * self.time_window) for i in range(self.num_windows)]
per_window = math.floor(loops / self.num_windows)

for window in windows:
for _ in windows:
for _ in range(per_window):
rate_limiter.is_allowed(window)
rate_limiter.is_allowed()

yield _
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
14 changes: 5 additions & 9 deletions ddtrace/_trace/sampling_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
from ddtrace.internal.glob_matching import GlobMatcher
from ddtrace.internal.logger import get_logger
from ddtrace.internal.utils.cache import cachedmethod
from ddtrace.internal.utils.deprecations import DDTraceDeprecationWarning
from ddtrace.vendor.debtcollector import deprecate


if TYPE_CHECKING: # pragma: no cover
Expand Down Expand Up @@ -210,14 +208,12 @@ def choose_matcher(self, prop):
# We currently support the ability to pass in a function, a regular expression, or a string
# If a string is passed in we create a GlobMatcher to handle the matching
if callable(prop) or isinstance(prop, pattern_type):
# deprecated: passing a function or a regular expression'
deprecate(
"Using methods or regular expressions for SamplingRule matching is deprecated. ",
message="Please move to passing in a string for Glob matching.",
removal_version="3.0.0",
category=DDTraceDeprecationWarning,
log.error(
"Using methods or regular expressions for SamplingRule matching is not supported: %s ."
"Please move to passing in a string for Glob matching.",
str(prop),
)
return prop
return "None"
# Name and Resource will never be None, but service can be, since we str()
# whatever we pass into the GlobMatcher, we can just use its matching
elif prop is None:
Expand Down
25 changes: 0 additions & 25 deletions ddtrace/_trace/span.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
from ddtrace.internal.logger import get_logger
from ddtrace.internal.sampling import SamplingMechanism
from ddtrace.internal.sampling import set_sampling_decision_maker
from ddtrace.internal.utils.deprecations import DDTraceDeprecationWarning
from ddtrace.vendor.debtcollector import deprecate


_NUMERIC_TAGS = (_ANALYTICS_SAMPLE_RATE_KEY,)
Expand Down Expand Up @@ -279,29 +277,6 @@ def duration(self) -> Optional[float]:
def duration(self, value: float) -> None:
self.duration_ns = int(value * 1e9)

@property
def sampled(self) -> Optional[bool]:
deprecate(
"span.sampled is deprecated and will be removed in a future version of the tracer.",
message="""span.sampled references the state of span.context.sampling_priority.
Please use span.context.sampling_priority instead to check if a span is sampled.""",
category=DDTraceDeprecationWarning,
)
if self.context.sampling_priority is None:
# this maintains original span.sampled behavior, where all spans would start
# with span.sampled = True until sampling runs
return True
return self.context.sampling_priority > 0

@sampled.setter
def sampled(self, value: bool) -> None:
deprecate(
"span.sampled is deprecated and will be removed in a future version of the tracer.",
message="""span.sampled has a no-op setter.
Please use span.set_tag('manual.keep'/'manual.drop') to keep or drop spans.""",
category=DDTraceDeprecationWarning,
)

def finish(self, finish_time: Optional[float] = None) -> None:
"""Mark the end time of the span and submit it to the tracer.
If the span has already been finished don't do anything.
Expand Down
Loading

0 comments on commit 238d262

Please sign in to comment.