auto-instrumentation-fetch replaces headers when req.headers input is of type Map #4347
Labels
bug
Something isn't working
priority:p1
Bugs which cause problems in end-user applications such as crashes, data inconsistencies, etc
What happened?
Steps to Reproduce
initialize fetch instrumentation
Expected Result
A request to foobar.com, with the header
foo
in addition to any trace propagation headersActual Result
The header
foo
is omitted, and only the trace propagation headers are sentAdditional Details
This is a result of this function. Since it is not handling a type of Map, it is resorting to extracting the keys as if the headers are an object literal, which it isn't.
It is important to note that a type of Map is not, according to the type definition of Request.Header, a valid type. However, it is fairly reasonable to expect that some folk may pass a Map type as their headers when using fetch, and in JavaScript will not result in any type errors/warnings. A Map type functionality-wise is valid, as it works as a type for headers when using fetch. The current code results in a bug where users who use fetch and have set their headers with a Map type have their headers entirely replaced by instrumentation-fetch when using it, where they were previously present without instrumentation-fetch.
OpenTelemetry Setup Code
// see PR
package.json
// see PR
Relevant log output
No response
The text was updated successfully, but these errors were encountered: