-
Notifications
You must be signed in to change notification settings - Fork 825
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
feat(otlp-exporter): support user-agent
headers in web exporters
#3811
feat(otlp-exporter): support user-agent
headers in web exporters
#3811
Conversation
8111f47
to
3c01ac3
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3811 +/- ##
==========================================
- Coverage 92.95% 92.92% -0.04%
==========================================
Files 297 297
Lines 9060 9068 +8
Branches 1848 1852 +4
==========================================
+ Hits 8422 8426 +4
- Misses 638 642 +4
|
0118b41
to
f87d8d1
Compare
user-agent
headers in web exportersuser-agent
headers in web exporters
…tric exporters (open-telemetry#3806)" This reverts commit 6a876a0.
…ce exporters (open-telemetry#3790)" This reverts commit 758c7af.
…move `sendBeacon` which does not support custom headers
…nstructor parameter
f87d8d1
to
361c1ac
Compare
experimental/packages/exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts
Outdated
Show resolved
Hide resolved
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 added my suggestion inline in case my previous comment wasn't clear. What do you think?
experimental/packages/exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts
Outdated
Show resolved
Hide resolved
experimental/packages/exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts
Show resolved
Hide resolved
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'd like to see some duplication reduction and the beacon sending should not be removed in this PR.
I also think this PR is quite large and each changelog entry should have its own PR so that the changes can be reviewed independently.
* feat(opencensus-shim): add OpenCensus trace shim [#3809](https://github.com/open-telemetry/opentelemetry-js/pull/3809) @aabmass | ||
|
||
### :bug: (Bug Fix) | ||
|
||
* fix(sdk-node): use resource interface instead of concrete class [#3803](https://github.com/open-telemetry/opentelemetry-js/pull/3803) @blumamir | ||
* fix(sdk-logs): remove includeTraceContext configuration and use LogRecord context when available [#3817](https://github.com/open-telemetry/opentelemetry-js/pull/3817) @hectorhdzg | ||
* fix(otlp-exporters): correct applying order of http headers/gRPC metadata [#3811](https://github.com/open-telemetry/opentelemetry-js/pull/3811) @llc1123 |
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.
This changelog doesn't really describe what changed. Also, should this change be in the same PR or a separate one?
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.
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.
We had a discussion here.
sendWithXhr( | ||
body, | ||
this.url, | ||
this._headers, | ||
this.timeoutMillis, | ||
resolve, | ||
reject | ||
); |
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.
This is a breaking change. Beacon sending is an important feature that can't be removed without significant reasoning and discussion
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 user-agent
header is required, and sendBeacon()
doesn't support HTTP headers at all. Also, the sendBeacon
function is not used anywhere else. I think it should be safe removing it.
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.
This is an environment specific requirement and there is precedent for breaking from spec for such reasons. Without beacon sending telemetry can be lost in many cases.
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 do know the advantages of sendBeacon
. But the user-agent
header is required. The sendBeacon
function will never be reached.
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.
Using fetch
with keepalive=true
also allows the request to outlive the page. If we can replace xhr
with fetch
.
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.
fetch
with keep-alive is not supported in all environments, so we can't rely on simply using it instead.
While (most) current versions of environments that support sendBeacon
also support fetch keep alive, my understanding is that it is still considered to be expermenital.
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.
user-agent is a SHOULD requirement not a MUST requirement: https://github.com/open-telemetry/opentelemetry-specification/blob/ce2c5946faa9c961ea01d89c7aed83621865b67b/specification/protocol/exporter.md#user-agent
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.
Further discussion: #3845
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.
regardless I think the refactor should be done separately from this PR as it is a very significant change
* @param onSuccess | ||
* @param onError | ||
*/ | ||
export function sendWithBeacon( |
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.
This cannot be removed without a serious discussion and significant user benefit
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 agree with @dyladan during page unloading sendBeacon
and fetch
(with keepalive) are the only options for getting data off the browser. And fetch with keep-alive is not always supported.
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 checked the compatibility of these options. ~5% of the browsers support sendBeacon
but not keepalive
.
Maybe we should implement with fetch
and use sendBeacon
as a fallback?
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.
Further discussion: #3845
There are 3 major changes, which are dependent each other.
|
If this PR is too large, I would like to split it into following PRs:
|
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.
Do not remove sendBeacon
support
Further discussion about the use of |
I would support that |
Any update on this? |
It's blocked by #3845 I think. |
Closing this for now - the changes proposed by PR were very controversial around removing sendBeacon. |
Which problem is this PR solving?
Support setting
user-agent
header in web exporters.Fixes #3808
Update:
xhr
withfetch
in another PR.Short description of the changes
user-agent
header in web exporters in base packages.sendBeacon
which doesn't support custom headers.user-agent
header into base packages.Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist: