From 25548fd9a5a130752fa378cdf5d7fd8e02d7bf5f Mon Sep 17 00:00:00 2001 From: Marc Pichler Date: Mon, 12 Feb 2024 13:08:45 +0100 Subject: [PATCH 1/7] feat(context-zone*): support zone.js 0.13.x, 0.14.x (#4469) * feat(context-zone*): support zone.js 0.13.x, 0.14.x * fix(changelog): add changelog entry * fix(changelog): formatting --- CHANGELOG.md | 3 ++ package-lock.json | 32 +++++++------------ .../package.json | 2 +- .../opentelemetry-context-zone/package.json | 2 +- selenium-tests/package.json | 2 +- 5 files changed, 17 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f2ffadf63..e3a1497245 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/ * feat(sdk-metrics): allow single bucket histograms [#4456](https://github.com/open-telemetry/opentelemetry-js/pull/4456) @pichlermarc * feat(instrumentation): Make `init()` method public [#4418](https://github.com/open-telemetry/opentelemetry-js/pull/4418) +* feat(context-zone-peer-dep, context-zone): support zone.js 0.13.x, 0.14.x [#4469](https://github.com/open-telemetry/opentelemetry-js/pull/4469) @pichlermarc ### :bug: (Bug Fix) @@ -21,6 +22,8 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/ * fixes a bug where recording `NaN` on a histogram would result in the sum of bucket count values not matching the overall count * fix(sdk-metrics): allow single bucket histograms [#4456](https://github.com/open-telemetry/opentelemetry-js/pull/4456) @pichlermarc * fixes a bug where `Meter.createHistogram()` with the advice `explicitBucketBoundaries: []` would throw +* fix(context-zone-peer-dep, context-zone): support zone.js 0.13.x, 0.14.x [#4469](https://github.com/open-telemetry/opentelemetry-js/pull/4469) @pichlermarc + * fixes a bug where old versions of `zone.js` affected by would be pulled in ### :books: (Refine Doc) diff --git a/package-lock.json b/package-lock.json index daff8df12e..07bc80e1db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33287,8 +33287,9 @@ } }, "node_modules/zone.js": { - "version": "0.11.8", - "license": "MIT", + "version": "0.14.3", + "resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.14.3.tgz", + "integrity": "sha512-jYoNqF046Q+JfcZSItRSt+oXFcpXL88yq7XAZjb/NKTS7w2hHpKjRJ3VlFD1k75wMaRRXNUt5vrZVlygiMyHbA==", "dependencies": { "tslib": "^2.3.0" } @@ -33322,7 +33323,7 @@ "license": "Apache-2.0", "dependencies": { "@opentelemetry/context-zone-peer-dep": "1.21.0", - "zone.js": "^0.11.0" + "zone.js": "^0.11.0 || ^0.13.0 || ^0.14.0" }, "devDependencies": { "cross-var": "1.1.0", @@ -33372,7 +33373,7 @@ }, "peerDependencies": { "@opentelemetry/api": ">=1.0.0 <1.8.0", - "zone.js": "^0.10.2 || ^0.11.0 || ^0.13.0" + "zone.js": "^0.10.2 || ^0.11.0 || ^0.13.0 || ^0.14.0" } }, "packages/opentelemetry-context-zone-peer-dep/node_modules/@webpack-cli/configtest": { @@ -35547,7 +35548,7 @@ "@opentelemetry/sdk-metrics": "1.21.0", "@opentelemetry/sdk-trace-base": "1.21.0", "@opentelemetry/sdk-trace-web": "1.21.0", - "zone.js": "0.11.4" + "zone.js": "^0.11.0 || ^0.13.0 || ^0.14.0" }, "devDependencies": { "@babel/core": "7.23.6", @@ -36095,13 +36096,6 @@ "engines": { "node": ">= 8" } - }, - "selenium-tests/node_modules/zone.js": { - "version": "0.11.4", - "license": "MIT", - "dependencies": { - "tslib": "^2.0.0" - } } }, "dependencies": { @@ -39219,7 +39213,7 @@ "cross-var": "1.1.0", "lerna": "6.6.2", "typescript": "4.4.4", - "zone.js": "^0.11.0" + "zone.js": "^0.11.0 || ^0.13.0 || ^0.14.0" } }, "@opentelemetry/context-zone-peer-dep": { @@ -43029,7 +43023,7 @@ "webpack-cli": "5.1.4", "webpack-dev-server": "4.5.0", "webpack-merge": "5.10.0", - "zone.js": "0.11.4" + "zone.js": "^0.11.0 || ^0.13.0 || ^0.14.0" }, "dependencies": { "@webpack-cli/configtest": { @@ -43315,12 +43309,6 @@ "requires": { "isexe": "^2.0.0" } - }, - "zone.js": { - "version": "0.11.4", - "requires": { - "tslib": "^2.0.0" - } } } }, @@ -59475,7 +59463,9 @@ } }, "zone.js": { - "version": "0.11.8", + "version": "0.14.3", + "resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.14.3.tgz", + "integrity": "sha512-jYoNqF046Q+JfcZSItRSt+oXFcpXL88yq7XAZjb/NKTS7w2hHpKjRJ3VlFD1k75wMaRRXNUt5vrZVlygiMyHbA==", "requires": { "tslib": "^2.3.0" } diff --git a/packages/opentelemetry-context-zone-peer-dep/package.json b/packages/opentelemetry-context-zone-peer-dep/package.json index 53c143ba17..a3670ad10f 100644 --- a/packages/opentelemetry-context-zone-peer-dep/package.json +++ b/packages/opentelemetry-context-zone-peer-dep/package.json @@ -84,7 +84,7 @@ }, "peerDependencies": { "@opentelemetry/api": ">=1.0.0 <1.8.0", - "zone.js": "^0.10.2 || ^0.11.0 || ^0.13.0" + "zone.js": "^0.10.2 || ^0.11.0 || ^0.13.0 || ^0.14.0" }, "sideEffects": false, "homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-context-zone-peer-dep" diff --git a/packages/opentelemetry-context-zone/package.json b/packages/opentelemetry-context-zone/package.json index b09c844e95..e5d964c092 100644 --- a/packages/opentelemetry-context-zone/package.json +++ b/packages/opentelemetry-context-zone/package.json @@ -56,7 +56,7 @@ }, "dependencies": { "@opentelemetry/context-zone-peer-dep": "1.21.0", - "zone.js": "^0.11.0" + "zone.js": "^0.11.0 || ^0.13.0 || ^0.14.0" }, "sideEffects": true, "homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-context-zone" diff --git a/selenium-tests/package.json b/selenium-tests/package.json index 8af0f1f07d..6ec77a3f8a 100644 --- a/selenium-tests/package.json +++ b/selenium-tests/package.json @@ -66,6 +66,6 @@ "@opentelemetry/sdk-metrics": "1.21.0", "@opentelemetry/sdk-trace-base": "1.21.0", "@opentelemetry/sdk-trace-web": "1.21.0", - "zone.js": "0.11.4" + "zone.js": "^0.11.0 || ^0.13.0 || ^0.14.0" } } From 01348e6fbc73646703c64f85c623406503692ebc Mon Sep 17 00:00:00 2001 From: Marc Pichler Date: Mon, 12 Feb 2024 13:09:15 +0100 Subject: [PATCH 2/7] fix(instrumentation): normalize paths for internal files in scoped packages (#4467) * fix(instrumentation): normalize paths for internal files in scoped packages * fix(instrumentation): normalize name passed to onRequire in RequireInTheMiddleSingleton * fix(instrumentation): apply normalization during filtering internal files * fix(changelog): add changelog entry * fix: normalize before filtering * fix: lint --- experimental/CHANGELOG.md | 2 + .../src/platform/node/instrumentation.ts | 3 +- .../scoped-test-module/package.json | 5 + .../scoped-test-module/src/index.js | 7 ++ .../scoped-test-module/src/internal.js | 1 + .../scoped-package-instrumentation.test.ts | 105 ++++++++++++++++++ 6 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 experimental/packages/opentelemetry-instrumentation/test/node/node_modules/@opentelemetry/scoped-test-module/package.json create mode 100644 experimental/packages/opentelemetry-instrumentation/test/node/node_modules/@opentelemetry/scoped-test-module/src/index.js create mode 100644 experimental/packages/opentelemetry-instrumentation/test/node/node_modules/@opentelemetry/scoped-test-module/src/internal.js create mode 100644 experimental/packages/opentelemetry-instrumentation/test/node/scoped-package-instrumentation.test.ts diff --git a/experimental/CHANGELOG.md b/experimental/CHANGELOG.md index a9bd8d8d16..01b1b3d688 100644 --- a/experimental/CHANGELOG.md +++ b/experimental/CHANGELOG.md @@ -16,6 +16,8 @@ All notable changes to experimental packages in this project will be documented ### :bug: (Bug Fix) * fix(sdk-node): allow using samplers when the exporter is defined in the environment [#4394](https://github.com/open-telemetry/opentelemetry-js/pull/4394) @JacksonWeber +* fix(instrumentation): normalize paths for internal files in scoped packages [#4467](https://github.com/open-telemetry/opentelemetry-js/pull/4467) @pichlermarc + * Fixes a bug where, on Windows, internal files on scoped packages would not be instrumented. ### :books: (Refine Doc) diff --git a/experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts b/experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts index a4c11498c9..c639bc8bd4 100644 --- a/experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts +++ b/experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts @@ -204,8 +204,9 @@ export abstract class InstrumentationBase } // internal file const files = module.files ?? []; + const normalizedName = path.normalize(name); const supportedFileInstrumentations = files - .filter(f => f.name === name) + .filter(f => f.name === normalizedName) .filter(f => isSupported(f.supportedVersions, version, module.includePrerelease) ); diff --git a/experimental/packages/opentelemetry-instrumentation/test/node/node_modules/@opentelemetry/scoped-test-module/package.json b/experimental/packages/opentelemetry-instrumentation/test/node/node_modules/@opentelemetry/scoped-test-module/package.json new file mode 100644 index 0000000000..2863978928 --- /dev/null +++ b/experimental/packages/opentelemetry-instrumentation/test/node/node_modules/@opentelemetry/scoped-test-module/package.json @@ -0,0 +1,5 @@ +{ + "name": "@opentelemetry/scoped-test-module", + "version": "0.1.0", + "main": "./src/index.js" +} diff --git a/experimental/packages/opentelemetry-instrumentation/test/node/node_modules/@opentelemetry/scoped-test-module/src/index.js b/experimental/packages/opentelemetry-instrumentation/test/node/node_modules/@opentelemetry/scoped-test-module/src/index.js new file mode 100644 index 0000000000..939163a6b2 --- /dev/null +++ b/experimental/packages/opentelemetry-instrumentation/test/node/node_modules/@opentelemetry/scoped-test-module/src/index.js @@ -0,0 +1,7 @@ +const { testString } = require('./internal'); + +exports.getString = function () { + return "from index.js: " + testString; +} + +exports.propertyOnMainModule = 'string in main module'; diff --git a/experimental/packages/opentelemetry-instrumentation/test/node/node_modules/@opentelemetry/scoped-test-module/src/internal.js b/experimental/packages/opentelemetry-instrumentation/test/node/node_modules/@opentelemetry/scoped-test-module/src/internal.js new file mode 100644 index 0000000000..9e591ef0dd --- /dev/null +++ b/experimental/packages/opentelemetry-instrumentation/test/node/node_modules/@opentelemetry/scoped-test-module/src/internal.js @@ -0,0 +1 @@ +exports.testString = "internal string"; diff --git a/experimental/packages/opentelemetry-instrumentation/test/node/scoped-package-instrumentation.test.ts b/experimental/packages/opentelemetry-instrumentation/test/node/scoped-package-instrumentation.test.ts new file mode 100644 index 0000000000..b3478cfe46 --- /dev/null +++ b/experimental/packages/opentelemetry-instrumentation/test/node/scoped-package-instrumentation.test.ts @@ -0,0 +1,105 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as assert from 'assert'; + +import { + InstrumentationBase, + InstrumentationConfig, + InstrumentationNodeModuleDefinition, + InstrumentationNodeModuleFile, +} from '../../src'; + +class TestInstrumentationSimple extends InstrumentationBase { + constructor(config: InstrumentationConfig) { + super('test-scoped-package-instrumentation', '0.0.1', config); + } + init() { + return new InstrumentationNodeModuleDefinition( + '@opentelemetry/scoped-test-module', + ['*'], + moduleExports => { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + moduleExports.propertyOnMainModule = 'modified string in main module'; + return moduleExports; + }, + moduleExports => { + return moduleExports; + }, + [ + new InstrumentationNodeModuleFile( + '@opentelemetry/scoped-test-module/src/internal.js', + ['*'], + moduleExports => { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore no types + moduleExports.testString = 'modified internal string'; + return moduleExports; + }, + moduleExports => { + return moduleExports; + } + ), + ] + ); + } +} + +describe('instrumenting a scoped package', function () { + /** + * On Windows, instrumentation would fail on internal files of scoped packages. + * The reason: the path would include a '/' separator in the package name: + * - actual: @opentelemetry/scoped-test-module\src\internal.js + * - expected: @opentelemetry\scoped-test-module\src\internal.js + * This resulted in internal files of scoped packages not being instrumented. + * + * See https://github.com/open-telemetry/opentelemetry-js/issues/4436 + */ + it('should patch internal file and main module', function () { + const instrumentation = new TestInstrumentationSimple({ + enabled: false, + }); + instrumentation.enable(); + + const { getString } = require('@opentelemetry/scoped-test-module'); + + assert.strictEqual(getString(), 'from index.js: modified internal string'); + }); + + /** + * Normalizing everything passed to onRequire() from RequireInTheMiddleSingleton would cause main modules from a + * scoped package not to be instrumented. + * The reason: we'd check: + * '@opentelemetry\scoped-test-module' === '@opentelemetry/scoped-test-module' + * + * then determine that since this evaluates to false, this is not the main module, and we'd never instrument it. + * + * Therefore, the fix to the above test (internal files) is not to normalize everything passed to onRequire() + */ + it('should patch main module', function () { + const instrumentation = new TestInstrumentationSimple({ + enabled: false, + }); + instrumentation.enable(); + + const { + propertyOnMainModule, + } = require('@opentelemetry/scoped-test-module'); + + assert.strictEqual(propertyOnMainModule, 'modified string in main module'); + }); +}); From 7e709a6fd91e701cbd59b6e0aa3c0130093de515 Mon Sep 17 00:00:00 2001 From: Mike Shi Date: Mon, 12 Feb 2024 11:49:04 -0800 Subject: [PATCH 3/7] docs: Update getting started link in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bc2244868a..5e6f3e4d35 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ---

- Getting Started + Getting Started   •   API and SDK Reference From 8bbebfd1912468fa3a0f5a10094291370014d818 Mon Sep 17 00:00:00 2001 From: Marc Pichler Date: Thu, 15 Feb 2024 13:59:01 +0100 Subject: [PATCH 4/7] feat(instrumentation): add `getModuleDefinitions()` instead of making `init()` public (#4475) * feat(instrumentation): add getModuleDefinitions() instead of making init() public * test(instrumetation): add tests for getModuleDefinitions() * chore: changelog --- experimental/CHANGELOG.md | 2 +- .../src/instrumentation.ts | 22 ++++++-- .../test/common/Instrumentation.test.ts | 51 +++++++++++++++++++ 3 files changed, 70 insertions(+), 5 deletions(-) diff --git a/experimental/CHANGELOG.md b/experimental/CHANGELOG.md index 01b1b3d688..ab698812ef 100644 --- a/experimental/CHANGELOG.md +++ b/experimental/CHANGELOG.md @@ -9,7 +9,7 @@ All notable changes to experimental packages in this project will be documented ### :rocket: (Enhancement) * feat(instrumentation): allow LoggerProvider to be specified in Instrumentations [#4314](https://github.com/open-telemetry/opentelemetry-js/pull/4314) @hectorhdzg -* feat(instrumentation): Make `init()` method public [#4418](https://github.com/open-telemetry/opentelemetry-js/pull/4418) +* feat(instrumentation): add getModuleDefinitions() to InstrumentationBase [#4475](https://github.com/open-telemetry/opentelemetry-js/pull/4475) @pichlermarc * feat(exporter-metrics-otlp-http): add option to set the exporter aggregation preference [#4409](https://github.com/open-telemetry/opentelemetry-js/pull/4409) @AkselAllas * feat(node-sdk): add spanProcessors option [#4454](https://github.com/open-telemetry/opentelemetry-js/pull/4454) @naseemkullah diff --git a/experimental/packages/opentelemetry-instrumentation/src/instrumentation.ts b/experimental/packages/opentelemetry-instrumentation/src/instrumentation.ts index 88a6b03887..ed619bd139 100644 --- a/experimental/packages/opentelemetry-instrumentation/src/instrumentation.ts +++ b/experimental/packages/opentelemetry-instrumentation/src/instrumentation.ts @@ -108,6 +108,23 @@ export abstract class InstrumentationAbstract ); } + /** + * @experimental + * + * Get module definitions defined by {@link init}. + * This can be used for experimental compile-time instrumentation. + * + * @returns an array of {@link InstrumentationModuleDefinition} + */ + public getModuleDefinitions(): InstrumentationModuleDefinition[] { + const initResult = this.init() ?? []; + if (!Array.isArray(initResult)) { + return [initResult]; + } + + return initResult; + } + /** * Sets the new metric instruments with the current Meter. */ @@ -153,11 +170,8 @@ export abstract class InstrumentationAbstract /** * Init method in which plugin should define _modules and patches for * methods. - * Use `enable()` if you are trying to turn on this plugin. This method - * will return objects to patch specific modules with the appropriate - * instrumentation (or not return anything). */ - abstract init(): + protected abstract init(): | InstrumentationModuleDefinition | InstrumentationModuleDefinition[] | void; diff --git a/experimental/packages/opentelemetry-instrumentation/test/common/Instrumentation.test.ts b/experimental/packages/opentelemetry-instrumentation/test/common/Instrumentation.test.ts index 126f4c0944..fde0c2c34e 100644 --- a/experimental/packages/opentelemetry-instrumentation/test/common/Instrumentation.test.ts +++ b/experimental/packages/opentelemetry-instrumentation/test/common/Instrumentation.test.ts @@ -19,6 +19,7 @@ import { Instrumentation, InstrumentationBase, InstrumentationConfig, + InstrumentationModuleDefinition, } from '../../src'; import { MeterProvider } from '@opentelemetry/sdk-metrics'; @@ -132,4 +133,54 @@ describe('BaseInstrumentation', () => { assert.strictEqual(configuration.isActive, true); }); }); + + describe('getModuleDefinitions', () => { + const moduleDefinition: InstrumentationModuleDefinition = { + name: 'foo', + patch: moduleExports => {}, + unpatch: moduleExports => {}, + moduleExports: {}, + files: [], + supportedVersions: ['*'], + }; + + it('should return single module definition from init() as array ', () => { + class TestInstrumentation2 extends TestInstrumentation { + override init() { + return moduleDefinition; + } + } + const instrumentation = new TestInstrumentation2(); + + assert.deepStrictEqual(instrumentation.getModuleDefinitions(), [ + moduleDefinition, + ]); + }); + + it('should return multiple module definitions from init() as array ', () => { + class TestInstrumentation2 extends TestInstrumentation { + override init() { + return [moduleDefinition, moduleDefinition, moduleDefinition]; + } + } + const instrumentation = new TestInstrumentation2(); + + assert.deepStrictEqual(instrumentation.getModuleDefinitions(), [ + moduleDefinition, + moduleDefinition, + moduleDefinition, + ]); + }); + + it('should return void from init() as empty array ', () => { + class TestInstrumentation2 extends TestInstrumentation { + override init() { + return; + } + } + const instrumentation = new TestInstrumentation2(); + + assert.deepStrictEqual(instrumentation.getModuleDefinitions(), []); + }); + }); }); From 5bc8cedbd3e16daa27e0881cffe7eaa179bd5a64 Mon Sep 17 00:00:00 2001 From: Marc Pichler Date: Thu, 15 Feb 2024 14:04:35 +0100 Subject: [PATCH 5/7] fix(otlp-transformer): only use BigInt inside hrTimeToNanos() (#4484) * fix(otlp-transformer): only use BigInt inside hrTimeToNanos() * fix: changelog --- experimental/CHANGELOG.md | 1 + experimental/packages/otlp-transformer/src/common/index.ts | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/experimental/CHANGELOG.md b/experimental/CHANGELOG.md index ab698812ef..64336d36d5 100644 --- a/experimental/CHANGELOG.md +++ b/experimental/CHANGELOG.md @@ -18,6 +18,7 @@ All notable changes to experimental packages in this project will be documented * fix(sdk-node): allow using samplers when the exporter is defined in the environment [#4394](https://github.com/open-telemetry/opentelemetry-js/pull/4394) @JacksonWeber * fix(instrumentation): normalize paths for internal files in scoped packages [#4467](https://github.com/open-telemetry/opentelemetry-js/pull/4467) @pichlermarc * Fixes a bug where, on Windows, internal files on scoped packages would not be instrumented. +* fix(otlp-transformer): only use BigInt inside hrTimeToNanos() [#4484](https://github.com/open-telemetry/opentelemetry-js/pull/4484) @pichlermarc ### :books: (Refine Doc) diff --git a/experimental/packages/otlp-transformer/src/common/index.ts b/experimental/packages/otlp-transformer/src/common/index.ts index 00dcccfb05..96d281bad6 100644 --- a/experimental/packages/otlp-transformer/src/common/index.ts +++ b/experimental/packages/otlp-transformer/src/common/index.ts @@ -18,9 +18,8 @@ import type { OtlpEncodingOptions, Fixed64, LongBits } from './types'; import { HrTime } from '@opentelemetry/api'; import { hexToBinary, hrTimeToNanoseconds } from '@opentelemetry/core'; -const NANOSECONDS = BigInt(1_000_000_000); - export function hrTimeToNanos(hrTime: HrTime): bigint { + const NANOSECONDS = BigInt(1_000_000_000); return BigInt(hrTime[0]) * NANOSECONDS + BigInt(hrTime[1]); } From 356ef8af4a8b329ee039b94a43a1311354f58e9b Mon Sep 17 00:00:00 2001 From: eldavojohn Date: Thu, 15 Feb 2024 08:07:54 -0600 Subject: [PATCH 6/7] chore: remove unload event from OTLPExporterBrowserBase (#4438) * 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 --------- Co-authored-by: Marc Pichler --- experimental/CHANGELOG.md | 7 +++++++ .../src/platform/browser/OTLPExporterBrowserBase.ts | 10 +++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/experimental/CHANGELOG.md b/experimental/CHANGELOG.md index 64336d36d5..2442005860 100644 --- a/experimental/CHANGELOG.md +++ b/experimental/CHANGELOG.md @@ -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 diff --git a/experimental/packages/otlp-exporter-base/src/platform/browser/OTLPExporterBrowserBase.ts b/experimental/packages/otlp-exporter-base/src/platform/browser/OTLPExporterBrowserBase.ts index dbe02b222d..1c3715055a 100644 --- a/experimental/packages/otlp-exporter-base/src/platform/browser/OTLPExporterBrowserBase.ts +++ b/experimental/packages/otlp-exporter-base/src/platform/browser/OTLPExporterBrowserBase.ts @@ -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 @@ -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[], From 89caef9bb92704482210db9684e115d583d8a805 Mon Sep 17 00:00:00 2001 From: Marc Pichler Date: Thu, 22 Feb 2024 13:03:52 +0100 Subject: [PATCH 7/7] Add @david-luna to triagers (#4497) --- README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5e6f3e4d35..1877f9e9f3 100644 --- a/README.md +++ b/README.md @@ -202,16 +202,16 @@ We have a weekly SIG meeting! See the [community page](https://github.com/open-t ### Community members -#### Maintainers ([@open-telemetry/js-maintainers](https://github.com/orgs/open-telemetry/teams/javascript-maintainers)) +#### Maintainers ([@open-telemetry/javascript-maintainers](https://github.com/orgs/open-telemetry/teams/javascript-maintainers)) - [Amir Blum](https://github.com/blumamir), Keyval - [Chengzhong Wu](https://github.com/legendecas), Alibaba - [Daniel Dyla](https://github.com/dyladan), Dynatrace - [Marc Pichler](https://github.com/pichlermarc), Dynatrace -*Find more about the maintainer role in [community repository](https://github.com/open-telemetry/community/blob/main/community-membership.md#maintainer).* +*Find more about the maintainer role in the [community repository](https://github.com/open-telemetry/community/blob/main/community-membership.md#maintainer).* -#### Approvers ([@open-telemetry/js-approvers](https://github.com/orgs/open-telemetry/teams/javascript-approvers)) +#### Approvers ([@open-telemetry/javascript-approvers](https://github.com/orgs/open-telemetry/teams/javascript-approvers)) - [Gerhard Stöbich](https://github.com/Flarna), Dynatrace - [Haddas Bronfman](https://github.com/haddasbronfman), Cisco @@ -225,7 +225,13 @@ We have a weekly SIG meeting! See the [community page](https://github.com/open-t - [Svetlana Brennan](https://github.com/svetlanabrennan), New Relic - [Trent Mick](https://github.com/trentm), Elastic -*Find more about the approver role in [community repository](https://github.com/open-telemetry/community/blob/main/community-membership.md#approver).* +*Find more about the approver role in the [community repository](https://github.com/open-telemetry/community/blob/main/community-membership.md#approver).* + +#### Triager ([@open-telemetry/javascript-triagers](https://github.com/orgs/open-telemetry/teams/javascript-triagers)) + +- [David Luna](https://github.com/david-luna), Elastic + +*Find more about the triager role in the [community repository](https://github.com/open-telemetry/community/blob/main/community-membership.md#triager).* #### Emeriti