Skip to content

Commit 114fa1d

Browse files
chore(tracer): remove deprecated collect_metrics arg (#2555) (#2710)
* chore(tracer): remove deprecated collect_metrics arg The `collect_metrics` argument of the `Tracer.configure` method was marked for deprecation and set for removal with v0.51. * remove unnecessary type hint ignores Co-authored-by: Kyle Verhoog <[email protected]> Co-authored-by: Tahir H. Butt <[email protected]> (cherry picked from commit ddca338) Co-authored-by: Gabriele N. Tornetta <[email protected]>
1 parent 1446531 commit 114fa1d

File tree

5 files changed

+7
-37
lines changed

5 files changed

+7
-37
lines changed

ddtrace/bootstrap/sitecustomize.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,7 @@ def update_patched_modules():
9999
if priority_sampling:
100100
opts["priority_sampling"] = asbool(priority_sampling)
101101

102-
# FIXME: Remove as part of the deprecation of collect_metrics
103-
opts["collect_metrics"] = asbool(get_env("runtime_metrics", "enabled"))
104-
105-
if opts:
106-
tracer.configure(**opts)
102+
tracer.configure(**opts)
107103

108104
if patch:
109105
update_patched_modules()

ddtrace/tracer.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ def current_trace_context(self, *args, **kwargs):
247247
return None
248248

249249
# TODO: deprecate this method and make sure users create a new tracer if they need different parameters
250-
@debtcollector.removals.removed_kwarg("collect_metrics", removal_version="0.51")
251250
def configure(
252251
self,
253252
enabled=None, # type: Optional[bool]
@@ -260,7 +259,6 @@ def configure(
260259
wrap_executor=None, # type: Optional[Callable]
261260
priority_sampling=None, # type: Optional[bool]
262261
settings=None, # type: Optional[Dict[str, Any]]
263-
collect_metrics=None, # type: Optional[bool]
264262
dogstatsd_url=None, # type: Optional[str]
265263
writer=None, # type: Optional[TraceWriter]
266264
partial_flush_enabled=None, # type: Optional[bool]
@@ -286,7 +284,6 @@ def configure(
286284
from the default value
287285
:param priority_sampling: enable priority sampling, this is required for
288286
complete distributed tracing support. Enabled by default.
289-
:param collect_metrics: Whether to enable runtime metrics collection.
290287
:param str dogstatsd_url: URL for UDP or Unix socket connection to DogStatsD
291288
"""
292289
if enabled is not None:
@@ -376,18 +373,6 @@ def configure(
376373
if wrap_executor is not None:
377374
self._wrap_executor = wrap_executor
378375

379-
runtime_metrics_was_running = False
380-
# FIXME: Import RuntimeWorker here to avoid circular imports. This will
381-
# be gone together with the collect_metrics attribute soon.
382-
from .internal.runtime.runtime_metrics import RuntimeWorker
383-
384-
if RuntimeWorker._instance is not None:
385-
runtime_metrics_was_running = True
386-
RuntimeWorker.disable()
387-
388-
if (collect_metrics is None and runtime_metrics_was_running) or collect_metrics:
389-
RuntimeWorker.enable(tracer=self, dogstatsd_url=self._dogstatsd_url)
390-
391376
if debug_mode or asbool(environ.get("DD_TRACE_STARTUP_LOGS", False)):
392377
try:
393378
info = debug.collect(self)

docs/advanced_usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ To enable tracing with manual instrumentation and configuration, configure uWSGI
652652

653653

654654
patch_all()
655-
tracer.configure(collect_metrics=True)
655+
tracer.configure()
656656

657657
def application(env, start_response):
658658
with tracer.trace("uwsgi-app"):
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
deprecations:
3+
- |
4+
Removed the ``collect_metrics`` argument from ``Tracer.configure``. See the
5+
release notes for v0.49.0 for the migration instructions.

tests/tracer/runtime/test_runtime_metrics.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import contextlib
22
import os
33
import time
4-
import warnings
54

65
import mock
76

@@ -132,21 +131,6 @@ def test_only_root_span_runtime_internal_span_types(self):
132131
assert root.get_tag("language") == "python"
133132
assert child.get_tag("language") is None
134133

135-
def test_only_root_span_runtime_internal_span_types_with_tracer_config(self):
136-
with warnings.catch_warnings(record=True) as w:
137-
warnings.simplefilter("always")
138-
self.tracer.configure(collect_metrics=True)
139-
for span_type in ("custom", "template", "web", "worker"):
140-
with self.start_span("root", span_type=span_type) as root:
141-
with self.start_span("child", child_of=root) as child:
142-
pass
143-
assert root.get_tag("language") == "python"
144-
assert child.get_tag("language") is None
145-
self.tracer.configure(collect_metrics=False)
146-
147-
self.assertEqual(len(w), 2)
148-
self.assertTrue(all(issubclass(_.category, DeprecationWarning) for _ in w))
149-
150134
def test_span_no_runtime_tags(self):
151135
with self.start_span("root") as root:
152136
with self.start_span("child", child_of=root.context) as child:

0 commit comments

Comments
 (0)