fix(exporters): use sendBeacon with empty headers#6216
fix(exporters): use sendBeacon with empty headers#6216YangJonghun wants to merge 4 commits intoopen-telemetry:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6216 +/- ##
=======================================
Coverage 95.43% 95.43%
=======================================
Files 317 317
Lines 9521 9521
Branches 2197 2197
=======================================
Hits 9086 9086
Misses 435 435 🚀 New features to boost your workflow:
|
|
Could you fix the formatting issue and add a changelog entry ? |
|
@raphael-theriault-swi |
|
FYI, I know for a fact that people use that behavior to force the exporter to use |
|
@pichlermarc I understand that this change could be considered a kind of breaking change, but from a user’s perspective the implicit behavior you mentioned didn’t feel very intuitive to me. Coming from a web API background, I was dynamically passing This PR is also related to the If we want to support forcing a specific transport, I think it might be clearer to introduce an explicit option such as 'auto' | 'fetchLater' | 'sendBeacon' | 'fetch' | 'xhr' and let users choose, rather than relying on this implicit |
|
This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
|
As the sendBeacon transport was removed in PR #6391 , this PR is being closed. |
Which problem is this PR solving?
Currently,
sendBeaconis only used whenconfigHeadersis falsy (undefinedornull). However, when users pass an empty object{}as headers, the exporter falls back tofetchunnecessarily. SincesendBeaconhas better reliability for telemetry (works even when page is closing), it should be used when there are no actual custom headers to send.Short description of the changes
inferExportDelegateToUseto usesendBeaconwhenconfigHeadersis either falsy or an empty objectType of change
How Has This Been Tested?
npm run test:browser- All tests passuses the beacon delegate when headers is empty objectChecklist: