Skip to content

Commit 0680d18

Browse files
docs: Document span filtering migration to span first
1 parent 5d6cf7e commit 0680d18

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

MIGRATION_GUIDE.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,41 @@ Looking to upgrade from Sentry SDK 1.x to 2.x? Here's a comprehensive list of wh
190190
- Deprecated `sentry_sdk.transport.Transport.capture_event`. Please use `sentry_sdk.transport.Transport.capture_envelope`, instead.
191191
- Passing a function to `sentry_sdk.init`'s `transport` keyword argument has been deprecated. If you wish to provide a custom transport, please pass a `sentry_sdk.transport.Transport` instance or a subclass.
192192
- The parameter `propagate_hub` in `ThreadingIntegration()` was deprecated and renamed to `propagate_scope`.
193+
194+
## Migrating Span Filtering to Span First
195+
196+
If you are using the experimental **Span First** mode (also known as span streaming, enabled via `_experiments={"trace_lifecycle": "stream"}`), you might notice that individual spans are sent in real-time and do not pass together through `before_send_transaction`.
197+
198+
To filter or ignore individual spans in Span First mode, you can use the experimental `ignore_spans` configuration option:
199+
200+
```python
201+
import sentry_sdk
202+
import re
203+
204+
sentry_sdk.init(
205+
dsn="...",
206+
traces_sample_rate=1.0, # Required for tracing
207+
_experiments={
208+
"trace_lifecycle": "stream",
209+
"ignore_spans": [
210+
"ignore_this_exact_name", # 1. Match by name (String)
211+
re.compile(r"^GET /static/.*"), # 2. Match by name (Regex Range)
212+
{"name": "ignore_by_name_dict"}, # 3. Match by name (Dict)
213+
{ # 4. Match by Span Attribute
214+
"attributes": {
215+
"http.status_code": 200,
216+
}
217+
}
218+
]
219+
}
220+
)
221+
```
222+
223+
### Key Differences:
224+
- **Before (Transaction Mode)**: You filtered child spans by mutating `event["spans"]` inside `before_send_transaction`.
225+
- **After (Span First)**: You define rules up-front in `ignore_spans`. If a rule matches, a `NoOpStreamedSpan` is returned immediately resulting in no overhead.
226+
- **Inheritance**: Any child span started with an ignored parent will automatically be ignored as well.
227+
228+
> [!NOTE]
229+
> `ignore_spans` is currently an experimental feature reading from `_experiments`.
230+

0 commit comments

Comments
 (0)