Skip to content

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

@kkruk-sumo

Description

@kkruk-sumo
  • 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestup-for-grabsGood for taking. Extra help will be provided by maintainers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions