Skip to content

Commit

Permalink
fix[tracing]: fetch headers (#2712)
Browse files Browse the repository at this point in the history
* fix[tracing]: fetch headers

Fixes #2685

* meta: Changelog
  • Loading branch information
HazAT committed Jul 1, 2020
1 parent 0defcdc commit 3aba85e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,7 @@
- [tracing] feat: Pick up sentry-trace in JS <meta/> tag (#2703)
- [tracing] fix: Respect sample decision when continuing trace from header in node (#2703)
- [gatsby] fix: Package gatsby files properly (#2711)
- [tracing] fix: All options of adding fetch headers (#2712)

## 5.18.1

Expand Down
11 changes: 5 additions & 6 deletions packages/apm/src/integrations/tracing.ts
Expand Up @@ -1021,13 +1021,12 @@ function fetchCallback(handlerData: { [key: string]: any }): void {
if (span) {
const options = (handlerData.args[1] = (handlerData.args[1] as { [key: string]: any }) || {});
if (options.headers) {
if (Array.isArray(options.headers)) {
options.headers = [...options.headers, { 'sentry-trace': span.toTraceparent() }];
if (typeof options.headers.append === 'function') {
options.headers.append('sentry-trace', span.toTraceparent());
} else if (Array.isArray(options.headers)) {
options.headers = [...options.headers, ['sentry-trace', span.toTraceparent()]];
} else {
options.headers = {
...options.headers,
'sentry-trace': span.toTraceparent(),
};
options.headers = { ...options.headers, 'sentry-trace': span.toTraceparent() };
}
} else {
options.headers = { 'sentry-trace': span.toTraceparent() };
Expand Down

0 comments on commit 3aba85e

Please sign in to comment.