Skip to content

Commit

Permalink
chore: remove unload event from OTLPExporterBrowserBase (#4438)
Browse files Browse the repository at this point in the history
* Add the ability for the implementation to provide the binding event for shutdown.

* fix: whoops totally missed the linting formatting fix step

* Remove any concept of a shutdown event

* add change log and obey interface

* no longer need globalthis

* modify the correct changelog and identify this as a breaking change under the scenario in comments

* markdown lint

* Update experimental/CHANGELOG.md

Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>

---------

Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>
  • Loading branch information
eldavojohn and pichlermarc authored Feb 15, 2024
1 parent 5bc8ced commit 356ef8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
7 changes: 7 additions & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ All notable changes to experimental packages in this project will be documented

### :boom: Breaking Change

* fix(otlp-exporter-base)!: remove unload event from OTLPExporterBrowserBase [#4438](https://github.com/open-telemetry/opentelemetry-js/pull/4438) @eldavojohn
* Reason: The 'unload' event prevents sites from taking advantage of Google's [backward/forward cache](https://web.dev/articles/bfcache#never_use_the_unload_event) and will be [deprecated](https://developer.chrome.com/articles/deprecating-unload/). It is now up to the consuming site to implement these shutdown events.
* This breaking change affects users under this scenario:
1. A user extends the exporter and overrides the shutdown function, and does something which is usually called by the unload listener
2. We remove the unload event listener
3. That user's overridden shutdown function no longer gets called

### :rocket: (Enhancement)

* feat(instrumentation): allow LoggerProvider to be specified in Instrumentations [#4314](https://github.com/open-telemetry/opentelemetry-js/pull/4314) @hectorhdzg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import * as otlpTypes from '../../types';
import { parseHeaders } from '../../util';
import { sendWithBeacon, sendWithXhr } from './util';
import { diag } from '@opentelemetry/api';
import { getEnv, baggageUtils, _globalThis } from '@opentelemetry/core';
import { getEnv, baggageUtils } from '@opentelemetry/core';

/**
* Collector Metric Exporter abstract base class
Expand Down Expand Up @@ -52,13 +52,9 @@ export abstract class OTLPExporterBrowserBase<
}
}

onInit(): void {
_globalThis.addEventListener('unload', this.shutdown);
}
onInit(): void {}

onShutdown(): void {
_globalThis.removeEventListener('unload', this.shutdown);
}
onShutdown(): void {}

send(
items: ExportItem[],
Expand Down

0 comments on commit 356ef8a

Please sign in to comment.