From d0e9430a8eb5fb9ee923960bec018942567dda6c Mon Sep 17 00:00:00 2001 From: Martin Kuba Date: Thu, 21 Mar 2024 10:12:54 -0700 Subject: [PATCH 1/3] removed domain from the events API --- experimental/packages/api-events/README.md | 2 +- .../packages/api-events/src/NoopEventEmitterProvider.ts | 1 - experimental/packages/api-events/src/api/events.ts | 2 -- .../packages/api-events/src/types/EventEmitterProvider.ts | 2 -- experimental/packages/api-events/test/api/api.test.ts | 4 ++-- .../noop-implementations/noop-event-emitter-provider.test.ts | 5 ++--- .../test/noop-implementations/noop-event-emitter.test.ts | 2 -- 7 files changed, 5 insertions(+), 13 deletions(-) diff --git a/experimental/packages/api-events/README.md b/experimental/packages/api-events/README.md index 3aff88eff6..1b8d168f62 100644 --- a/experimental/packages/api-events/README.md +++ b/experimental/packages/api-events/README.md @@ -39,7 +39,7 @@ api.events.getEventEmitterProvider(); const eventEmitter = api.events.getEventEmitter(name, version); // logging an event in an instrumentation library -eventEmitter.emit({ name: 'event-name', domain: 'event-domain' }); +eventEmitter.emit({ name: 'event-name' }); ``` ## Useful links diff --git a/experimental/packages/api-events/src/NoopEventEmitterProvider.ts b/experimental/packages/api-events/src/NoopEventEmitterProvider.ts index 95731b0a8d..4d33536ac5 100644 --- a/experimental/packages/api-events/src/NoopEventEmitterProvider.ts +++ b/experimental/packages/api-events/src/NoopEventEmitterProvider.ts @@ -22,7 +22,6 @@ import { NoopEventEmitter } from './NoopEventEmitter'; export class NoopEventEmitterProvider implements EventEmitterProvider { getEventEmitter( _name: string, - _domain: string, _version?: string | undefined, _options?: EventEmitterOptions | undefined ): EventEmitter { diff --git a/experimental/packages/api-events/src/api/events.ts b/experimental/packages/api-events/src/api/events.ts index f17c93a2d3..0888bd684b 100644 --- a/experimental/packages/api-events/src/api/events.ts +++ b/experimental/packages/api-events/src/api/events.ts @@ -73,13 +73,11 @@ export class EventsAPI { */ public getEventEmitter( name: string, - domain: string, version?: string, options?: EventEmitterOptions ): EventEmitter { return this.getEventEmitterProvider().getEventEmitter( name, - domain, version, options ); diff --git a/experimental/packages/api-events/src/types/EventEmitterProvider.ts b/experimental/packages/api-events/src/types/EventEmitterProvider.ts index 276b2e627d..26c45b8306 100644 --- a/experimental/packages/api-events/src/types/EventEmitterProvider.ts +++ b/experimental/packages/api-events/src/types/EventEmitterProvider.ts @@ -26,14 +26,12 @@ export interface EventEmitterProvider { * schemaUrl pair is not already created. * * @param name The name of the event emitter or instrumentation library. - * @param domain The domain for events created by the event emitter. * @param version The version of the event emitter or instrumentation library. * @param options The options of the event emitter or instrumentation library. * @returns EventEmitter An event emitter with the given name and version. */ getEventEmitter( name: string, - domain: string, version?: string, options?: EventEmitterOptions ): EventEmitter; diff --git a/experimental/packages/api-events/test/api/api.test.ts b/experimental/packages/api-events/test/api/api.test.ts index e091688ff8..27a4b23b5c 100644 --- a/experimental/packages/api-events/test/api/api.test.ts +++ b/experimental/packages/api-events/test/api/api.test.ts @@ -37,7 +37,7 @@ describe('API', () => { events.setGlobalEventEmitterProvider(new TestEventEmitterProvider()); const eventEmitter = events .getEventEmitterProvider() - .getEventEmitter('name', 'domain'); + .getEventEmitter('name'); assert.deepStrictEqual(eventEmitter, dummyEventEmitter); }); @@ -58,7 +58,7 @@ describe('API', () => { it('should return a event emitter instance from global provider', () => { events.setGlobalEventEmitterProvider(new TestEventEmitterProvider()); - const eventEmitter = events.getEventEmitter('myEventEmitter', 'domain'); + const eventEmitter = events.getEventEmitter('myEventEmitter'); assert.deepStrictEqual(eventEmitter, dummyEventEmitter); }); }); diff --git a/experimental/packages/api-events/test/noop-implementations/noop-event-emitter-provider.test.ts b/experimental/packages/api-events/test/noop-implementations/noop-event-emitter-provider.test.ts index ad88d37058..3cfcbf9d5e 100644 --- a/experimental/packages/api-events/test/noop-implementations/noop-event-emitter-provider.test.ts +++ b/experimental/packages/api-events/test/noop-implementations/noop-event-emitter-provider.test.ts @@ -23,18 +23,17 @@ describe('NoopLoggerProvider', () => { const eventEmitterProvider = new NoopEventEmitterProvider(); assert.ok( - eventEmitterProvider.getEventEmitter('emitter-name', 'domain') instanceof + eventEmitterProvider.getEventEmitter('emitter-name') instanceof NoopEventEmitter ); assert.ok( eventEmitterProvider.getEventEmitter( 'emitter-name', - 'domain', 'v1' ) instanceof NoopEventEmitter ); assert.ok( - eventEmitterProvider.getEventEmitter('emitter-name', 'domain', 'v1', { + eventEmitterProvider.getEventEmitter('emitter-name', 'v1', { schemaUrl: 'https://opentelemetry.io/schemas/1.7.0', }) instanceof NoopEventEmitter ); diff --git a/experimental/packages/api-events/test/noop-implementations/noop-event-emitter.test.ts b/experimental/packages/api-events/test/noop-implementations/noop-event-emitter.test.ts index 933a3e6e88..064e888e78 100644 --- a/experimental/packages/api-events/test/noop-implementations/noop-event-emitter.test.ts +++ b/experimental/packages/api-events/test/noop-implementations/noop-event-emitter.test.ts @@ -22,7 +22,6 @@ describe('NoopEventEmitter', () => { it('constructor should not crash', () => { const logger = new NoopEventEmitterProvider().getEventEmitter( 'test-noop', - 'test-domain' ); assert(logger instanceof NoopEventEmitter); }); @@ -30,7 +29,6 @@ describe('NoopEventEmitter', () => { it('calling emit should not crash', () => { const emitter = new NoopEventEmitterProvider().getEventEmitter( 'test-noop', - 'test-domain' ); emitter.emit({ name: 'event name', From c09136be497aca6d576fe2cb7d4ad5ffabcc4960 Mon Sep 17 00:00:00 2001 From: Martin Kuba Date: Thu, 21 Mar 2024 10:47:07 -0700 Subject: [PATCH 2/3] lint --- .../noop-event-emitter-provider.test.ts | 6 ++---- .../test/noop-implementations/noop-event-emitter.test.ts | 8 ++------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/experimental/packages/api-events/test/noop-implementations/noop-event-emitter-provider.test.ts b/experimental/packages/api-events/test/noop-implementations/noop-event-emitter-provider.test.ts index 3cfcbf9d5e..346a339ce9 100644 --- a/experimental/packages/api-events/test/noop-implementations/noop-event-emitter-provider.test.ts +++ b/experimental/packages/api-events/test/noop-implementations/noop-event-emitter-provider.test.ts @@ -27,10 +27,8 @@ describe('NoopLoggerProvider', () => { NoopEventEmitter ); assert.ok( - eventEmitterProvider.getEventEmitter( - 'emitter-name', - 'v1' - ) instanceof NoopEventEmitter + eventEmitterProvider.getEventEmitter('emitter-name', 'v1') instanceof + NoopEventEmitter ); assert.ok( eventEmitterProvider.getEventEmitter('emitter-name', 'v1', { diff --git a/experimental/packages/api-events/test/noop-implementations/noop-event-emitter.test.ts b/experimental/packages/api-events/test/noop-implementations/noop-event-emitter.test.ts index 064e888e78..1e4f0a4382 100644 --- a/experimental/packages/api-events/test/noop-implementations/noop-event-emitter.test.ts +++ b/experimental/packages/api-events/test/noop-implementations/noop-event-emitter.test.ts @@ -20,16 +20,12 @@ import { NoopEventEmitterProvider } from '../../src/NoopEventEmitterProvider'; describe('NoopEventEmitter', () => { it('constructor should not crash', () => { - const logger = new NoopEventEmitterProvider().getEventEmitter( - 'test-noop', - ); + const logger = new NoopEventEmitterProvider().getEventEmitter('test-noop'); assert(logger instanceof NoopEventEmitter); }); it('calling emit should not crash', () => { - const emitter = new NoopEventEmitterProvider().getEventEmitter( - 'test-noop', - ); + const emitter = new NoopEventEmitterProvider().getEventEmitter('test-noop'); emitter.emit({ name: 'event name', }); From 73fbda8df6a4f81330692e6d53d780adeed67e5b Mon Sep 17 00:00:00 2001 From: Martin Kuba Date: Thu, 21 Mar 2024 11:00:45 -0700 Subject: [PATCH 3/3] updated changelog --- experimental/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/experimental/CHANGELOG.md b/experimental/CHANGELOG.md index ad7e559391..4f8a844795 100644 --- a/experimental/CHANGELOG.md +++ b/experimental/CHANGELOG.md @@ -19,6 +19,7 @@ All notable changes to experimental packages in this project will be documented * was used internally to keep track of the service client used by the exporter, as a side effect it allowed end-users to modify the gRPC service client that was used * `compression` * was used internally to keep track of the compression to use but was unintentionally exposed to the users. It allowed to read and write the value, writing, however, would have no effect. +* feat(api-events)!: removed domain from the Events API [#4569](https://github.com/open-telemetry/opentelemetry-js/pull/4569) ### :rocket: (Enhancement)