feat(otel): Ignore outgoing Sentry HTTP requests from otel integration #6116
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With the basic setup of the SpanProcessor, you can get into an infinite loop quickly:
@opentelemetry/instrumentation-http
)The "cleanest" way to avoid this is to setup your auto-instrumentation to skip Sentry requests, e.g.:
However, this also means you need to make sure to cover any potential place where this is auto-instrumented, and it also makes the setup experience for users harder than necessary.
Instead, this PR adds some handling to handle these cases automatically.
Actual solution
Any transaction/span that we identify as being an HTTP request to the configured Sentry DSN is never finished, and thus never sent to Sentry.
Known downsides
Any theoretical child spans of the Sentry HTTP request span will also never be sent to Sentry. This shouldn't actually happen that much, or be of high relevance if it happens, but it is theoretically possible.
Explanation
At least as of now, there is simply no way in
onStart
of the SpanProcessor to access the attributes, as they are only set afteronStart
has been called. Because of this, any behavior where we handle this/properly filter this out before the span ends is not possible to implement.We will need to do some testing to ensure there are no memory leaks (it should be fine, but to be sure...)
ref #6112
References