Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Events SDK #4629

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open

add Events SDK #4629

wants to merge 29 commits into from

Conversation

martinkuba
Copy link
Contributor

@martinkuba martinkuba commented Apr 11, 2024

Which problem is this PR solving?

This adds an experimental implementation of the Events SDK.

As a related update, I have also updated the Events API with the following:

  • replaced traceId and spanId fields in the Event interface with context field (see spec)
  • added severityNumber field

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

@martinkuba martinkuba requested a review from a team as a code owner April 11, 2024 19:33
Copy link
Member

@JamieDanielson JamieDanielson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! I added a few non-blocking suggestions to make it easier for someone to try it out. I also added a note about setting a default severityNumber of 9 based on the spec.

experimental/packages/sdk-events/src/EventLogger.ts Outdated Show resolved Hide resolved
experimental/examples/events/index.ts Show resolved Hide resolved
experimental/examples/events/README.md Outdated Show resolved Hide resolved
Copy link
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments, looks good overall 👍

experimental/packages/sdk-events/package.json Outdated Show resolved Hide resolved
experimental/examples/events/package.json Outdated Show resolved Hide resolved
experimental/packages/sdk-events/src/EventLogger.ts Outdated Show resolved Hide resolved
ConsoleLogRecordExporter,
} = require('@opentelemetry/sdk-logs');

// The Events SDK has a dependency on the Logs SDK
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nit: can you keep a consistency in the comments?
some start with capitalized letter and end with period, others don't. Some have a - between sentences on different lines, some don't.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made a few changes in this file to make the comments more consistent.

new SimpleLogRecordProcessor(new ConsoleLogRecordExporter())
);
logs.setGlobalLoggerProvider(loggerProvider);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JamieDanielson you made a comment on the other file to add an example for OTLP exporter, do you think one should also exist here?
Or since there is a link to that example right below is enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of the other SDK READMEs include OTLP exporters. IMO, this is a good thing, so that the README is focused only on how the package is used. The example is different because users might actually want to run it as is.


getEventLogger(
name: string,
version?: string | undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need to add undefined if you're using ? to mark as optional, since it will already be undefined if you don't pass anything.

Same for the options? below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

assert(
spy.calledWith(
sinon.match({
severityNumber: 9,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use SeverityNumber.INFO here instead of 9? In case the value ever changes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

// emit a log record
const eventLogger = events.getEventLogger('example');
eventLogger.emit({
name: 'my-event',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: 'my-event',
name: 'my-domain.my-event',

Just to emphasise using a domain prefix as a recommendation.

carlosalberto pushed a commit to open-telemetry/opentelemetry-specification that referenced this pull request May 23, 2024
This adds details to how EventLoggerProvider and EventLogger should be
implemented in the default Events SDK.

Prototypes
- [JavaScript
prototype](open-telemetry/opentelemetry-js#4629)
- [Java
prototype](https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/internal/SdkEventLoggerProvider.java)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

6 participants