-
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
bug(exporter-collector): headers are appended to existing one #2335
Comments
This is duplicate with #2321 so i'll close this one, the problem comes from the collector exporter / collector itself and not zonejs |
hi @vmarchaud , this issue was raised because of the usage of CollectorTraceExporter api .
results in a headers object where Content-Type is set twice. "Content-Type": "application/json application/json" If i implicit define it as follows:
results are that the headers object hat a Content-Type of: "Content-Type": "application/json" If i implicit omit the headers object it as follows:
results are that the headers object hat a Content-Type of: "Content-Type": "plain/text;charset=utf-8" Maybe the design of the CollectorTraceExporter api needs an enhancement for being more explicit than implicit ?
should result in a headers object where Content-Type is application/json . "Content-Type": "application/json" |
@vmarchaud i think actually not . Additionally if headers config is present and the application developer provides explicit the Content-Type: "application/json" |
This is because headers can't be used as-is with beacon (see this), thats one of the things that #2336 should fix.
Could you provide a full example of this ? I can't reproduce locally |
then in network tab of chrome dev tools i see this: Notice: |
hi @vmarchaud managed to reproduce locally given the infos above ? I am asking with the motivation that maybe i have done something wrong on the setup on my side ? i get |
I did not, i'll reopen this in the mean time but if you have the time to make PR that would be welcome :) |
@vmarchaud i checked the code in opentelemetry-js/utils : https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-exporter-collector/src/platform/browser/util.ts#L59 when setting the same header twice , the value(a.k.a body) of the header is appended . But before making a PR i would like to ask , how should an application developer use the api of Or should the api of |
* fix: headers are appended to existing one (#2335) * test(browser-util): added 2 more test-cases refactored desc, it wording * test: split tests review * fix: review headers are appended to existing one (#2335) * test: review DRY * fix: review lint Co-authored-by: Valentin Marchaud <[email protected]> Co-authored-by: Daniel Dyla <[email protected]>
Please answer these questions before submitting a bug report.
What version of OpenTelemetry are you using?
"@opentelemetry/context-zone": "^0.23.0",
"@opentelemetry/exporter-collector": "^0.23.0",
"@opentelemetry/instrumentation": "^0.23.0",
"@opentelemetry/auto-instrumentations-web": "^0.23.0",
"@opentelemetry/propagator-b3": "^0.23.0",
"@opentelemetry/tracing": "^0.23.0",
"@opentelemetry/web": "^0.23.0",
"@opentelemetry/resources": "0.23.0",
"@opentelemetry/semantic-conventions": "0.23.0",
Collector docker image: otel/opentelemetry-collector-contrib:0.29.0 and/or otel/opentelemetry-collector:0.29.0
What version of Node are you using?
14 --lts : latest
Please provide the code you used to setup the OpenTelemetry SDK
https://github.com/niko-achilles/otlp-logzio-fullstack/blob/main/frontend/lib/useOpentelemetry.js#L25
What did you do?
If i provide explicitly , the content type of application/json as follows:
Then the zone.js script makes a request of type xhr and applies in content-type application/json twice ,
Content-type: application/json application/json
If i do not provide explicitly the Content-Type in the headers object , then
zone.js script makes a request of type xhr and applies in content-type : text/plain;charset=utf8
What did you expect to see?
content-type: application/json in the request of zone.js .
What did you see instead?
zone.js script makes a request of type xhr and applies in content-type : text/plain;charset=utf8
or
zone.js script makes a request of type xhr and applies in content-type application/json twice ,
Content-type: application/json application/json.
Additional context
If i write implicit , having the headers object as follows:
Then the traces are collected, because zone.js applies as content-type: application/json
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: