-
Notifications
You must be signed in to change notification settings - Fork 821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(opentelemetry-instrumentation-fetch): fixed override of headers #2426
fix(opentelemetry-instrumentation-fetch): fixed override of headers #2426
Conversation
Signed-off-by: Philip Szalla <[email protected]>
|
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this comment referring to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to use the ||
-operator inside the if
-statement to avoid the else if
and the code duplication. But it caused a type error at the setter
-parameter of the api.propagation.inject
-function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is pretty unclear on its own. I would just remove it since it's a typing issue and not a functionality caveat.
Codecov Report
@@ Coverage Diff @@
## main #2426 +/- ##
==========================================
+ Coverage 92.22% 92.70% +0.48%
==========================================
Files 120 137 +17
Lines 4013 4993 +980
Branches 850 1056 +206
==========================================
+ Hits 3701 4629 +928
- Misses 312 364 +52
|
can you please add some unit tests to cover the fixes ? |
@philipszalla can you please add a test to cover this? |
Signed-off-by: Philip Szalla <[email protected]>
…ders Signed-off-by: Philip Szalla <[email protected]>
Signed-off-by: Philip Szalla [email protected]
Which problem is this PR solving?
opentelemetry-instrumentation-fetch removes headers from original request, when the
init
-object is not an instance ofRequest
but theheaders
-property is an instance ofHeaders
.Fetch-requests made by https://github.com/pnp/pnpjs can cause this problem.
Short description of the changes
headers
-property