question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Auto shutdown in collector-exporter can hurt performance in some browsers

See original GitHub issue
  • This only affects the JavaScript OpenTelemetry library
  • This may affect other libraries, but I would like to get opinions here first

Hi 👋

@opentelemtry/exporter-collector by default adds event listener for the unload event on browser platforms. According to MDN it can hurt website’s performance when doing back/forward buttons:

Additionally, the unload event is incompatible with the back/forward cache (bfcache) implemented in modern browsers. Some browsers, such as Firefox, handle this incompatibility by excluding pages from the bfcache if they contain unload handlers, thus hurting performance. See Avoid unload and beforeunload for more.

Also I’m not sure what’s the purpose of this behaviour? shutdown only returns a promise of already exported items, so doing it on unload doesn’t make more sense, does it? See the code I’m referring to.

Additionally, onShutdown is empty for node platform, so we could just remove the onInit and onShutdown functionalities. Am I missing something?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:16 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
dyladancommented, Jul 28, 2022

Got it. So sendBeacon is our best bet on shutdowns and if we have to use xhr we just have to hope

1reaction
vmarchaudcommented, Jul 27, 2022

Isn’t sendBeacon and fetch both async? The only sync option is sync XHR which has problems like you mentioned

I believe sendBeacon API is sync however the data is sent asynchronously, you just never get the callback. It ensentially just push the request into a queue that is handled even if the page is closed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enable Azure Monitor OpenTelemetry for .NET, Node.js, and ...
This article provides guidance on how to enable Azure Monitor on applications by using OpenTelemetry.
Read more >
Instrumenting web apps end to end with Cloud Monitoring and ...
This tutorial demonstrates instrumenting a web application end to end—from the browser to the backend application—with OpenTelemetry and Cloud ...
Read more >
Grafana Tempo, 8 Jul 2021 - mtngs.io The Open Meetings Hub
Discussion of Tempo News over the past 2 months including adding search, service graphs, Tempo 1.0 and other news! So the recording should...
Read more >
Kubernetes - DZone
When a pod is created, Kubernetes will monitor it and automatically restart it if a process terminates. In addition,. Kubernetes can be configured...
Read more >
Cisco Stealthwatch 7.0 DeploymentLab - StudyLib
If presented with a browser security warning in Chrome, click the ADVANCED ... It can use this ability to automatically classify certain types...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found