Skip to content

Commit

Permalink
fix(opentelemetry-instrumentation-fetch): fixed override of headers
Browse files Browse the repository at this point in the history
Signed-off-by: Philip Szalla <philip@szalla.de>
  • Loading branch information
philipszalla committed Aug 23, 2021
1 parent 0ef1fc2 commit c6274ef
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/opentelemetry-instrumentation-fetch/src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ export class FetchInstrumentation extends InstrumentationBase<
api.propagation.inject(api.context.active(), options.headers, {
set: (h, k, v) => h.set(k, typeof v === 'string' ? v : String(v)),
});
} else if(options.headers instanceof Headers) {
// ||-operator causes ts type error
api.propagation.inject(api.context.active(), options.headers, {
set: (h, k, v) => h.set(k, typeof v === 'string' ? v : String(v)),
});
} else {
const headers: Partial<Record<string, unknown>> = {};
api.propagation.inject(api.context.active(), headers);
Expand Down

0 comments on commit c6274ef

Please sign in to comment.