-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(core): Add ignoreSpans
option
#17078
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
base: develop
Are you sure you want to change the base?
Conversation
size-limit report 📦
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Had some suggestions for types and performance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, excited to see this 👏
Should we refactor similar functions like ignoreResourceSpans
and ignorePerformanceApiSpans
to just alias ignoreSpans
?
@mydea, perfect timing. I was about to try to use beforeSendSpan. Do you have a prerelease with this or plan to merge it soon? |
Hey @amccloud thx for expressing interest! I just made some optimizations to this PR. We'll merge this soon. Expect it to be released Update: sorry, but we actually need to wait for next week to merge this. |
@bcoe I think it's easier and more bundle-size efficient to keep the options separate for now. Worth noting though that users can set |
} | ||
|
||
const nameMatches = pattern.name ? isMatchingPattern(span.description, pattern.name) : true; | ||
const opMatches = pattern.op ? span.op && isMatchingPattern(span.op, pattern.op) : true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Span Ignoring Fails for Empty Operations
The shouldIgnoreSpan
function fails to correctly evaluate ignoreSpans
patterns for spans with an empty op
value. The condition span.op && isMatchingPattern(span.op, pattern.op)
short-circuits when span.op
is an empty string (""
), as empty strings are falsy. This prevents isMatchingPattern
from being called, causing spans with empty op
values to not be ignored even when pattern.op
is configured to match them (e.g., /^$/
). The check should explicitly distinguish empty strings from undefined
(e.g., span.op != null
) to ensure proper pattern matching.
This adds a new
ignoreSpans
option to all SDKs. This can be used as follows:this will drop spans before they are sent. Eventual child spans in the same envelope will be re-parented, if possible.
Closes #16820