Skip to content

Commit

Permalink
Remove domain from the Events API (#4569)
Browse files Browse the repository at this point in the history
* removed domain from the events API

* lint

* updated changelog

---------

Co-authored-by: Marc Pichler <[email protected]>
  • Loading branch information
martinkuba and pichlermarc authored Mar 25, 2024
1 parent 5fb65b4 commit fec6286
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 23 deletions.
1 change: 1 addition & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/api-events/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions experimental/packages/api-events/src/api/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions experimental/packages/api-events/test/api/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('API', () => {
events.setGlobalEventEmitterProvider(new TestEventEmitterProvider());
const eventEmitter = events
.getEventEmitterProvider()
.getEventEmitter('name', 'domain');
.getEventEmitter('name');
assert.deepStrictEqual(eventEmitter, dummyEventEmitter);
});

Expand All @@ -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);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,15 @@ 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
eventEmitterProvider.getEventEmitter('emitter-name', '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
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,12 @@ import { NoopEventEmitterProvider } from '../../src/NoopEventEmitterProvider';

describe('NoopEventEmitter', () => {
it('constructor should not crash', () => {
const logger = new NoopEventEmitterProvider().getEventEmitter(
'test-noop',
'test-domain'
);
const logger = new NoopEventEmitterProvider().getEventEmitter('test-noop');
assert(logger instanceof NoopEventEmitter);
});

it('calling emit should not crash', () => {
const emitter = new NoopEventEmitterProvider().getEventEmitter(
'test-noop',
'test-domain'
);
const emitter = new NoopEventEmitterProvider().getEventEmitter('test-noop');
emitter.emit({
name: 'event name',
});
Expand Down

0 comments on commit fec6286

Please sign in to comment.