-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tracing): Make
shouldAttachHeaders
not fall back to default val…
…ues (#6238) This patch fixes a bug in our `shouldAttachHeaders` function that determines internally if outgoing requests should have headers attached or not. Previously, we assigned the default values to `tracingOrigins` as well as `tracePropagationTargets` and overwrote these defaults, if users provided one (or (unlikely) both) options. In `shouldAttachHeaders`, we then first tested `tracingOrigins` for a match and in case there was no match, we'd test `tracePropagationTargets`. This, however, also meant that if users specified `tracingOrigins` and an URL didn't match them, there was still a chance that headers would be attached - in case the url matched the `tracePropagationTargets`' default values. With this fix, we don't assign default values to either option but check for definedness of them and only if they're both undefined, well fall back to defaults. ### Example: url: `/api/test/123` tracingOrigins: `[]` tracePropTargets: `['localhost', /^\//]` // default values `shouldAttachHeaders` returned `true` but should have returned `false`. This PR fixes this behaviour. In case, both options are defined, we prefer `tracePropagationTargets` over `tracingOrigins`, as defined in the [dev specification](https://develop.sentry.dev/sdk/performance/#example). Furthermore, this patch extracts the `shouldAttachHeaders` function by wrapping it in a factory function so that it's easier to test this behaviour. And it adds some tests to verify correct behaviour. We can get rid of some code around this in v8 when we finally remove `tracingOrigins`. Side-note: Because we're exporting `defaultRequestInstrumentationOptions` as public API, I decided to leave the optional value assignment in place but to simply not take the default values from it anymore in `instrumentOutgoingRequests` (see [aed40a6](aed40a6)).
- Loading branch information
Showing
2 changed files
with
82 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters