Skip to content

Commit 1245846

Browse files
authored
chore(tracing): remove deprecated properties and parameters (#12199)
- Introduces the following breaking changes to tracing components: - Removes deprecated parameters from ``Tracer.configure(...)`` method and removes the ``Tracer.sampler`` attribute. - Drops support for multiple tracer instances, ``ddtrace.trace.Tracer`` can not be reinitialized. - Removes the deprecated ``Span.sampled`` property - Drops support for configuring sampling rules using functions and regex in the ``ddtrace.tracer.sampler.rules[].choose_matcher(...)`` method and removes the ``timestamp_ns`` parameter from ``ddtrace.internal.rate_limiter.RateLimiter.is_allowed()``. - Drops support for configuring ``DD_TRACE_METHODS`` with the '[]' notation. Ensure DD_TRACE_METHODS use the ':' notation instead". - Removes the deprecated ``ddtracer`` parameter from ``ddtrace.opentracer.tracer.Tracer()``. ## 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 3ac7025 commit 1245846

File tree

14 files changed

+53
-463
lines changed

14 files changed

+53
-463
lines changed

benchmarks/bm/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def process_trace(self, trace):
6565

6666

6767
def drop_traces(tracer):
68-
tracer.configure(settings={"FILTERS": [_DropTraces()]})
68+
tracer.configure(trace_processors=[_DropTraces()])
6969

7070

7171
def drop_telemetry_events():

benchmarks/rate_limiter/scenario.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def _(loops):
2323
windows = [start + (i * self.time_window) for i in range(self.num_windows)]
2424
per_window = math.floor(loops / self.num_windows)
2525

26-
for window in windows:
26+
for _ in windows:
2727
for _ in range(per_window):
28-
rate_limiter.is_allowed(window)
28+
rate_limiter.is_allowed()
2929

3030
yield _

ddtrace/_trace/sampling_rule.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
from ddtrace.internal.glob_matching import GlobMatcher
99
from ddtrace.internal.logger import get_logger
1010
from ddtrace.internal.utils.cache import cachedmethod
11-
from ddtrace.internal.utils.deprecations import DDTraceDeprecationWarning
12-
from ddtrace.vendor.debtcollector import deprecate
1311

1412

1513
if TYPE_CHECKING: # pragma: no cover
@@ -210,14 +208,12 @@ def choose_matcher(self, prop):
210208
# We currently support the ability to pass in a function, a regular expression, or a string
211209
# If a string is passed in we create a GlobMatcher to handle the matching
212210
if callable(prop) or isinstance(prop, pattern_type):
213-
# deprecated: passing a function or a regular expression'
214-
deprecate(
215-
"Using methods or regular expressions for SamplingRule matching is deprecated. ",
216-
message="Please move to passing in a string for Glob matching.",
217-
removal_version="3.0.0",
218-
category=DDTraceDeprecationWarning,
211+
log.error(
212+
"Using methods or regular expressions for SamplingRule matching is not supported: %s ."
213+
"Please move to passing in a string for Glob matching.",
214+
str(prop),
219215
)
220-
return prop
216+
return "None"
221217
# Name and Resource will never be None, but service can be, since we str()
222218
# whatever we pass into the GlobMatcher, we can just use its matching
223219
elif prop is None:

ddtrace/_trace/span.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@
5252
from ddtrace.internal.logger import get_logger
5353
from ddtrace.internal.sampling import SamplingMechanism
5454
from ddtrace.internal.sampling import set_sampling_decision_maker
55-
from ddtrace.internal.utils.deprecations import DDTraceDeprecationWarning
56-
from ddtrace.vendor.debtcollector import deprecate
5755

5856

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

282-
@property
283-
def sampled(self) -> Optional[bool]:
284-
deprecate(
285-
"span.sampled is deprecated and will be removed in a future version of the tracer.",
286-
message="""span.sampled references the state of span.context.sampling_priority.
287-
Please use span.context.sampling_priority instead to check if a span is sampled.""",
288-
category=DDTraceDeprecationWarning,
289-
)
290-
if self.context.sampling_priority is None:
291-
# this maintains original span.sampled behavior, where all spans would start
292-
# with span.sampled = True until sampling runs
293-
return True
294-
return self.context.sampling_priority > 0
295-
296-
@sampled.setter
297-
def sampled(self, value: bool) -> None:
298-
deprecate(
299-
"span.sampled is deprecated and will be removed in a future version of the tracer.",
300-
message="""span.sampled has a no-op setter.
301-
Please use span.set_tag('manual.keep'/'manual.drop') to keep or drop spans.""",
302-
category=DDTraceDeprecationWarning,
303-
)
304-
305280
def finish(self, finish_time: Optional[float] = None) -> None:
306281
"""Mark the end time of the span and submit it to the tracer.
307282
If the span has already been finished don't do anything.

ddtrace/_trace/tracer.py

Lines changed: 11 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from ddtrace._trace.processor import TraceProcessor
2525
from ddtrace._trace.processor import TraceSamplingProcessor
2626
from ddtrace._trace.processor import TraceTagsProcessor
27+
from ddtrace._trace.provider import BaseContextProvider
2728
from ddtrace._trace.provider import DefaultContextProvider
2829
from ddtrace._trace.sampler import BasePrioritySampler
2930
from ddtrace._trace.sampler import BaseSampler
@@ -200,7 +201,7 @@ def __init__(
200201
self,
201202
url: Optional[str] = None,
202203
dogstatsd_url: Optional[str] = None,
203-
context_provider: Optional[DefaultContextProvider] = None,
204+
context_provider: Optional[BaseContextProvider] = None,
204205
) -> None:
205206
"""
206207
Create a new ``Tracer`` instance. A global tracer is already initialized
@@ -328,28 +329,6 @@ def sample(self, span):
328329
else:
329330
log.error("No sampler available to sample span")
330331

331-
@property
332-
def sampler(self):
333-
deprecate(
334-
"tracer.sampler is deprecated and will be removed.",
335-
message="To manually sample call tracer.sample(span) instead.",
336-
category=DDTraceDeprecationWarning,
337-
)
338-
return self._sampler
339-
340-
@sampler.setter
341-
def sampler(self, value):
342-
deprecate(
343-
"Setting a custom sampler is deprecated and will be removed.",
344-
message="""Please use DD_TRACE_SAMPLING_RULES to configure the sampler instead:
345-
https://ddtrace.readthedocs.io/en/stable/configuration.html#DD_TRACE_SAMPLING_RULES""",
346-
category=DDTraceDeprecationWarning,
347-
)
348-
if asm_config._apm_opt_out:
349-
log.warning("Cannot set a custom sampler with Standalone ASM mode")
350-
return
351-
self._sampler = value
352-
353332
def on_start_span(self, func: Callable) -> Callable:
354333
"""Register a function to execute when a span start.
355334
@@ -441,21 +420,7 @@ def get_log_correlation_context(self, active: Optional[Union[Context, Span]] = N
441420

442421
def configure(
443422
self,
444-
enabled: Optional[bool] = None,
445-
hostname: Optional[str] = None,
446-
port: Optional[int] = None,
447-
uds_path: Optional[str] = None,
448-
https: Optional[bool] = None,
449-
sampler: Optional[BaseSampler] = None,
450-
context_provider: Optional[DefaultContextProvider] = None,
451-
wrap_executor: Optional[Callable] = None,
452-
priority_sampling: Optional[bool] = None,
453-
settings: Optional[Dict[str, Any]] = None,
454-
dogstatsd_url: Optional[str] = None,
455-
writer: Optional[TraceWriter] = None,
456-
partial_flush_enabled: Optional[bool] = None,
457-
partial_flush_min_spans: Optional[int] = None,
458-
api_version: Optional[str] = None,
423+
context_provider: Optional[BaseContextProvider] = None,
459424
compute_stats_enabled: Optional[bool] = None,
460425
appsec_enabled: Optional[bool] = None,
461426
iast_enabled: Optional[bool] = None,
@@ -472,58 +437,14 @@ def configure(
472437
:param bool appsec_standalone_enabled: When tracing is disabled ensures ASM support is still enabled.
473438
:param List[TraceProcessor] trace_processors: This parameter sets TraceProcessor (ex: TraceFilters).
474439
Trace processors are used to modify and filter traces based on certain criteria.
475-
476-
:param bool enabled: If True, finished traces will be submitted to the API, else they'll be dropped.
477-
This parameter is deprecated and will be removed.
478-
:param str hostname: Hostname running the Trace Agent. This parameter is deprecated and will be removed.
479-
:param int port: Port of the Trace Agent. This parameter is deprecated and will be removed.
480-
:param str uds_path: The Unix Domain Socket path of the agent. This parameter is deprecated and will be removed.
481-
:param bool https: Whether to use HTTPS or HTTP. This parameter is deprecated and will be removed.
482-
:param object sampler: A custom Sampler instance, locally deciding to totally drop the trace or not.
483-
This parameter is deprecated and will be removed.
484-
:param object wrap_executor: callable that is used when a function is decorated with
485-
``Tracer.wrap()``. This is an advanced option that usually doesn't need to be changed
486-
from the default value. This parameter is deprecated and will be removed.
487-
:param priority_sampling: This parameter is deprecated and will be removed in a future version.
488-
:param bool settings: This parameter is deprecated and will be removed.
489-
:param str dogstatsd_url: URL for UDP or Unix socket connection to DogStatsD
490-
This parameter is deprecated and will be removed.
491-
:param TraceWriter writer: This parameter is deprecated and will be removed.
492-
:param bool partial_flush_enabled: This parameter is deprecated and will be removed.
493-
:param bool partial_flush_min_spans: This parameter is deprecated and will be removed.
494-
:param str api_version: This parameter is deprecated and will be removed.
495-
:param bool compute_stats_enabled: This parameter is deprecated and will be removed.
496440
"""
497-
if settings is not None:
498-
deprecate(
499-
"Support for ``tracer.configure(...)`` with the settings parameter is deprecated",
500-
message="Please use the trace_processors parameter instead of settings['FILTERS'].",
501-
version="3.0.0",
502-
category=DDTraceDeprecationWarning,
503-
)
504-
trace_processors = (trace_processors or []) + (settings.get("FILTERS") or [])
505-
506441
return self._configure(
507-
enabled,
508-
hostname,
509-
port,
510-
uds_path,
511-
https,
512-
sampler,
513-
context_provider,
514-
wrap_executor,
515-
priority_sampling,
516-
trace_processors,
517-
dogstatsd_url,
518-
writer,
519-
partial_flush_enabled,
520-
partial_flush_min_spans,
521-
api_version,
522-
compute_stats_enabled,
523-
appsec_enabled,
524-
iast_enabled,
525-
appsec_standalone_enabled,
526-
True,
442+
context_provider=context_provider,
443+
trace_processors=trace_processors,
444+
compute_stats_enabled=compute_stats_enabled,
445+
appsec_enabled=appsec_enabled,
446+
iast_enabled=iast_enabled,
447+
appsec_standalone_enabled=appsec_standalone_enabled,
527448
)
528449

529450
def _configure(
@@ -534,7 +455,7 @@ def _configure(
534455
uds_path: Optional[str] = None,
535456
https: Optional[bool] = None,
536457
sampler: Optional[BaseSampler] = None,
537-
context_provider: Optional[DefaultContextProvider] = None,
458+
context_provider: Optional[BaseContextProvider] = None,
538459
wrap_executor: Optional[Callable] = None,
539460
priority_sampling: Optional[bool] = None,
540461
trace_processors: Optional[List[TraceProcessor]] = None,
@@ -547,48 +468,18 @@ def _configure(
547468
appsec_enabled: Optional[bool] = None,
548469
iast_enabled: Optional[bool] = None,
549470
appsec_standalone_enabled: Optional[bool] = None,
550-
log_deprecations: bool = False,
551471
) -> None:
552472
if enabled is not None:
553473
self.enabled = enabled
554-
if log_deprecations:
555-
deprecate(
556-
"Enabling/Disabling tracing after application start is deprecated",
557-
message="Please use DD_TRACE_ENABLED instead.",
558-
version="3.0.0",
559-
category=DDTraceDeprecationWarning,
560-
)
561-
562-
if priority_sampling is not None and log_deprecations:
563-
deprecate(
564-
"Disabling priority sampling is deprecated",
565-
message="Calling `tracer.configure(priority_sampling=....) has no effect",
566-
version="3.0.0",
567-
category=DDTraceDeprecationWarning,
568-
)
569474

570475
if trace_processors is not None:
571476
self._user_trace_processors = trace_processors
572477

573478
if partial_flush_enabled is not None:
574479
self._partial_flush_enabled = partial_flush_enabled
575-
if log_deprecations:
576-
deprecate(
577-
"Configuring partial flushing after application start is deprecated",
578-
message="Please use DD_TRACE_PARTIAL_FLUSH_ENABLED to enable/disable the partial flushing instead.",
579-
version="3.0.0",
580-
category=DDTraceDeprecationWarning,
581-
)
582480

583481
if partial_flush_min_spans is not None:
584482
self._partial_flush_min_spans = partial_flush_min_spans
585-
if log_deprecations:
586-
deprecate(
587-
"Configuring partial flushing after application start is deprecated",
588-
message="Please use DD_TRACE_PARTIAL_FLUSH_MIN_SPANS to set the flushing threshold instead.",
589-
version="3.0.0",
590-
category=DDTraceDeprecationWarning,
591-
)
592483

593484
if appsec_enabled is not None:
594485
asm_config._asm_enabled = appsec_enabled
@@ -620,33 +511,11 @@ def _configure(
620511
if sampler is not None:
621512
self._sampler = sampler
622513
self._user_sampler = self._sampler
623-
if log_deprecations:
624-
deprecate(
625-
"Configuring custom samplers is deprecated",
626-
message="Please use DD_TRACE_SAMPLING_RULES to configure the sample rates instead",
627-
category=DDTraceDeprecationWarning,
628-
removal_version="3.0.0",
629-
)
630514

631515
if dogstatsd_url is not None:
632-
if log_deprecations:
633-
deprecate(
634-
"Configuring dogstatsd_url after application start is deprecated",
635-
message="Please use DD_DOGSTATSD_URL instead.",
636-
version="3.0.0",
637-
category=DDTraceDeprecationWarning,
638-
)
639516
self._dogstatsd_url = dogstatsd_url
640517

641518
if any(x is not None for x in [hostname, port, uds_path, https]):
642-
if log_deprecations:
643-
deprecate(
644-
"Configuring tracer agent connection after application start is deprecated",
645-
message="Please use DD_TRACE_AGENT_URL instead.",
646-
version="3.0.0",
647-
category=DDTraceDeprecationWarning,
648-
)
649-
650519
# If any of the parts of the URL have updated, merge them with
651520
# the previous writer values.
652521
prev_url_parsed = compat.parse.urlparse(self._agent_url)
@@ -670,13 +539,6 @@ def _configure(
670539
new_url = None
671540

672541
if compute_stats_enabled is not None:
673-
if log_deprecations:
674-
deprecate(
675-
"Configuring tracer stats computation after application start is deprecated",
676-
message="Please use DD_TRACE_STATS_COMPUTATION_ENABLED instead.",
677-
version="3.0.0",
678-
category=DDTraceDeprecationWarning,
679-
)
680542
self._compute_stats = compute_stats_enabled
681543

682544
try:
@@ -685,14 +547,6 @@ def _configure(
685547
# It's possible the writer never got started
686548
pass
687549

688-
if api_version is not None and log_deprecations:
689-
deprecate(
690-
"Configuring Tracer API version after application start is deprecated",
691-
message="Please use DD_TRACE_API_VERSION instead.",
692-
version="3.0.0",
693-
category=DDTraceDeprecationWarning,
694-
)
695-
696550
if writer is not None:
697551
self._writer = writer
698552
elif any(x is not None for x in [new_url, api_version, sampler, dogstatsd_url, appsec_enabled]):
@@ -754,12 +608,6 @@ def _configure(
754608

755609
if wrap_executor is not None:
756610
self._wrap_executor = wrap_executor
757-
if log_deprecations:
758-
deprecate(
759-
"Support for tracer.configure(...) with the wrap_executor parameter is deprecated",
760-
version="3.0.0",
761-
category=DDTraceDeprecationWarning,
762-
)
763611

764612
self._generate_diagnostic_logs()
765613

@@ -1344,7 +1192,7 @@ def _handle_sampler_update(self, cfg: Config) -> None:
13441192
and self._user_sampler
13451193
):
13461194
# if we get empty configs from rc for both sample rate and rules, we should revert to the user sampler
1347-
self.sampler = self._user_sampler
1195+
self._sampler = self._user_sampler
13481196
return
13491197

13501198
if cfg._get_source("_trace_sample_rate") != "remote_config" and self._user_sampler:

0 commit comments

Comments
 (0)