Skip to content

Commit df244f2

Browse files
committed
fix[tracing]: fetch headers
Fixes #2685
1 parent 0defcdc commit df244f2

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

packages/apm/src/integrations/tracing.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,13 +1021,12 @@ function fetchCallback(handlerData: { [key: string]: any }): void {
10211021
if (span) {
10221022
const options = (handlerData.args[1] = (handlerData.args[1] as { [key: string]: any }) || {});
10231023
if (options.headers) {
1024-
if (Array.isArray(options.headers)) {
1025-
options.headers = [...options.headers, { 'sentry-trace': span.toTraceparent() }];
1024+
if (typeof options.headers.append === 'function') {
1025+
options.headers.append('sentry-trace', span.toTraceparent());
1026+
} else if (Array.isArray(options.headers)) {
1027+
options.headers = [...options.headers, ['sentry-trace', span.toTraceparent()]];
10261028
} else {
1027-
options.headers = {
1028-
...options.headers,
1029-
'sentry-trace': span.toTraceparent(),
1030-
};
1029+
options.headers = { ...options.headers, 'sentry-trace': span.toTraceparent() };
10311030
}
10321031
} else {
10331032
options.headers = { 'sentry-trace': span.toTraceparent() };

0 commit comments

Comments
 (0)