Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(tracing): deprecates FilterRequestsOnUrl [3.0] #11962

Merged
merged 3 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions ddtrace/contrib/tornado/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ def log_exception(self, typ, value, tb):
'default_service': 'my-tornado-app',
'tags': {'env': 'production'},
'distributed_tracing': False,
'settings': {
'FILTERS': [
FilterRequestsOnUrl(r'http://test\\.example\\.com'),
],
},
},
}

Expand Down
4 changes: 2 additions & 2 deletions ddtrace/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


deprecate(
"The ddtrace.filters module is deprecated and will be removed.",
message="Import ``TraceFilter`` and/or ``FilterRequestsOnUrl`` from the ddtrace.trace package.",
"The ddtrace.filters module and the ``FilterRequestsOnUrl`` class is deprecated and will be removed.",
message="Import ``TraceFilter`` from the ddtrace.trace package.",
category=DDTraceDeprecationWarning,
)
3 changes: 1 addition & 2 deletions ddtrace/trace/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from ddtrace._trace.context import Context
from ddtrace._trace.filters import FilterRequestsOnUrl
mabdinur marked this conversation as resolved.
Show resolved Hide resolved
from ddtrace._trace.filters import TraceFilter
from ddtrace._trace.pin import Pin


# TODO: Move `ddtrace.Tracer`, `ddtrace.Span`, and `ddtrace.tracer` to this module
__all__ = ["Context", "Pin", "TraceFilter", "FilterRequestsOnUrl"]
__all__ = ["Context", "Pin", "TraceFilter"]
19 changes: 10 additions & 9 deletions docs/advanced_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -332,24 +332,25 @@ configuring the tracer with a filters list. For instance, to filter out
all traces of incoming requests to a specific url::

from ddtrace import tracer
from ddtrace.trace import TraceFilter

class FilterbyName(TraceFilter):
def process_trace(self, trace):
for span in trace:
if span.name == "some_name"
# drop the full trace chunk
return None
return trace

tracer.configure(settings={
'FILTERS': [
FilterRequestsOnUrl(r'http://test\.example\.com'),
FilterbyName(),
],
})

The filters in the filters list will be applied sequentially to each trace
and the resulting trace will either be sent to the Agent or discarded.

**Built-in filters**

The library comes with a ``FilterRequestsOnUrl`` filter that can be used to
filter out incoming requests to specific urls:

.. autoclass:: ddtrace.trace.FilterRequestsOnUrl
:members:

**Writing a custom filter**

Create a filter by implementing a class with a ``process_trace`` method and
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
deprecations:
- |
tracing: Deprecates ``ddtrace.filters.FilterRequestsOnUrl``. Spans should be filtered/sampled using DD_TRACE_SAMPLING_RULES configuration.
2 changes: 1 addition & 1 deletion tests/tracer/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import pytest

from ddtrace._trace.filters import FilterRequestsOnUrl
from ddtrace._trace.span import Span
from ddtrace.ext.http import URL
from ddtrace.trace import FilterRequestsOnUrl
from ddtrace.trace import TraceFilter


Expand Down
Loading