ref: Add span filtering to span first (15)#5633
Conversation
…first-6-add-continue-and-new-trace
…na/span-first-7-add-trace-decorator
…-first-8-bucket-based-limits-in-batcher
…-first-8-bucket-based-limits-in-batcher
…tom-sampling-context
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. This PR will not appear in the changelog. 🤖 This preview updates automatically when you update the PR. |
1 similar comment
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. This PR will not appear in the changelog. 🤖 This preview updates automatically when you update the PR. |
Codecov Results 📊✅ 13 passed | Total: 13 | Pass Rate: 100% | Execution Time: 7.30s All tests are passing successfully. ❌ Patch coverage is 8.57%. Project has 14043 uncovered lines. Files with missing lines (4)
Generated by Codecov Action |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
alexander-alderman-webb
left a comment
There was a problem hiding this comment.
looks good, see one non-blocking suggestion
| IgnoreSpansContext = TypedDict( | ||
| "IgnoreSpansContext", | ||
| {"name": IgnoreSpansName, "attributes": Attributes}, | ||
| total=False, | ||
| ) |
There was a problem hiding this comment.
Maybe we can have a proper IgnoreSpansContext class?
I think creating a dedicated IgnoreSpansContext would give us more control in the future, as we can add new parameters with default arguments, etc ...
There was a problem hiding this comment.
Can you give me an example what that could look like? Would we require users to wrap their ignore_spans rules in the class, too?
There was a problem hiding this comment.
Yes, re-reading my comment that's super vague 😅 .
The idea would be to funnel everything through
class IgnoreSpansConfig:
def __init__(self, rules: "list[IgnoreSpansContext]"):
self.rules = rules + [
IgnoreSpansContext(attributes = {"http.url": "https://api.openai.com/v1/traces"})
]
class IgnoreSpansContext:
def __init__(self, name: "IgnoreSpansName", attributes: "Attributes"):
self.name = name
self.attributes = attributes
So the user would pass in
ignore_spans=IgnoreSpansConfig([IgnoreSpansContext(name="/health")])There would still be dedicated options for common filtering cases like the trace_ignore_status_codes option. The class could let us cater for cases where we want to filter out some spans by default, but give the user an option to override it by controlling self.rules themselves?
There was a problem hiding this comment.
Very rough idea. The motivation is that I found calls to https://api.openai.com/v1/traces clutter the trace view and it'd be nice to have the facility to globally disable them.
If there's another way to do this please let me know 🙏
In span first, we're introducing a new span filtering
initoption calledignore_spanswhich allows to ignore spans at start time based on name and attributes.ignoredclient report (set viaNoOpStreamedSpan.unsampled_reason).ignore_spans, the whole span tree will be ignored. The implementation achieves this by allowingNoOpStreamedSpans to be set on the scope in this one single case, so that their children can easily determine their segment was dropped.Spec: https://develop.sentry.dev/sdk/telemetry/spans/filtering/#filter-with-ignorespans