-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add error information and filtering to spans #13119
Comments
Hi @cuchi thanks for opening this issue! I looked at your PR as well and I agree with closing it for the moment. Now, your suggestion to get from a span to an error generally makes sense to but unfortunately we can't add methods to the So I thought a bit about if we can turn around your logic to solve this outside the SDK and I think I came up with an (admittedly slightly hacky) solution: const spansWithError = new Set();
Sentry.init({
beforeSend(event) {
if (_possiblyShouldDropEvent(event)) {
return null;
}
// If we end up here, we did not drop the event
// so let's remember the root span that should have an erroneous status
const activeSpan = Sentry.getActiveSpan();
const rootSpan = activeSpan && Sentry.getRootSpan(activeSpan);
if (rootSpan) {
spansWithError.add(Sentry.spanToJSON(rootSpan).span_id);
}
return event;
},
beforeSendTransaction(transaction) {
const spanId = transaction.contexts.trace.span_id;
if (!spansWithError.has(spanId)) {
transaction.contexts.trace.status = 'ok';
} else {
// clean up the set to avoid memory leaks
spansWithError.delete(spanId);
}
return transaction;
},
}); Do you think this would solve your use case of avoiding to send spans with an error status where the error event was dropped? If my suggestion doesn't work for you, there would probably be a way to emit a callback within the SDK when we drop an event that you could subscribe to to adjust the span status. However, for now, we'd like to avoid expanding the public API to the SDK if possible. Note: I replaced |
This PR changes the `beforeSendSpan` JSDoc analogously to the docs change (getsentry/sentry-docs#10907). It now more clearly points out that `beforeSendSpan` is only called for child spans but not for root spans. ref #13119
Hey @Lms24! I just tested and validated your hack, it works! Thanks for looking into that, I'm closing this issue. |
Great to hear, thanks for letting us know! Yup, I fully agree that this isn't pretty. If it comes up again we can think about a cleaner solution. For now I'll leave this closed. |
Problem Statement
In the context of traces/transactions/spans:
Spans are being tagged with the
internal_error
status when either a globalunhandledRejection
orerror
happen. This is expected, but we don't have the error information in the faulty span.In our case, we have some filters for errors that should be ignored (with the
ignoreErrors
option), but transactions that fail because of these errors are still being tagged withinternal_error
and triggering alerts that we created to track failure rates.ingoreErrors
optionIn the current state, we just have a bunch of failed transactions that point to no error and just render our failure rate (%) alert useless.
Solution Brainstorm
I tried to actively use the
ignoreErrors
logic when capturing these errors: #13084But the solution breaks some of the scope between integrations.
A better solution (IMHO), would be to just capture the
error
information inside the span object: (here)...so we're able to do what we want with that info:
The text was updated successfully, but these errors were encountered: