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

Describe the use cases for events in greater detail #3969

Merged
merged 21 commits into from
Jun 3, 2024
Merged
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 35 additions & 12 deletions specification/logs/event-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@

The Event API consists of these main components:

* [EventLoggerProvider](#eventloggerprovider) is the entry point of the API. It provides access to `EventLogger`s.
* [EventLoggerProvider](#eventloggerprovider) is the entry point of the API. It
provides access to `EventLogger`s.
* [EventLogger](#eventlogger) is the component responsible for emitting events.

## Data model
Expand All @@ -36,17 +37,39 @@ Wikipedia’s [definition of log file](https://en.wikipedia.org/wiki/Log_file):
>operating system or other software runs.

From OpenTelemetry's perspective LogRecords and Events are both represented
using the same [data model](./data-model.md).

However, OpenTelemetry does recognize a subtle semantic difference between
LogRecords and Events: Events are LogRecords which have a `name` which uniquely
defines a particular class or type of event. All events with the same `name`
have `Body` that conform to the same schema, which assists in analysis in
observability platforms. Events are described in more detail in
the [semantic conventions](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/general/events.md).

Unlike the [Logs Bridge API](./bridge-api.md), application developers and
instrumentation authors are encouraged to call this API directly.
using the same [data model](./data-model.md). An Event is a specialized type
of LogRecord, not a separate concept.

Events contain all of the features provided by LogRecords, plus one additional
feature: every event is a semantic convention. All Events have a
tedsuo marked this conversation as resolved.
Show resolved Hide resolved
`name`, and all Events with the same `name` MUST conform to the same schema for
both their `Attributes` and their `Body`.

The Events API was designed to allow shared libraries to emit high quality
logs without needing to depend on a third party logger. Unlike the
[Logs Bridge API](./bridge-api.md), instrumentation authors and application
developers and are encouraged to call this API directly. It is appropriate to
tedsuo marked this conversation as resolved.
Show resolved Hide resolved
use the Event API when these properties fit your requirements:

* Logging from a shared library that must run in many applications.
* A semantic convention needs to be defined. We do not define semantic
conventions for LogRecords that are not Events.
* Analysis by an observability platform is the intended use case. For
example: statistics, indexing, machine learning, session replay.
* Normalizing logging and having a consistent schema across a large
application is helpful.

If any of these properties fit your requirements, we recommend using the Event API.
tedsuo marked this conversation as resolved.
Show resolved Hide resolved
Events are described in more detail in the [semantic conventions](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/general/events.md).

Please note that Events are sent directly to the OTel Log SDK, which currently
pellared marked this conversation as resolved.
Show resolved Hide resolved
lacks a number of advanced features present in popular log frameworks. For example:
pattern logging, file rotation, network appenders, etc. These features cannot be
used with the Event API at this time.

If a logging framework is capable of creating logs which correctly map
tedsuo marked this conversation as resolved.
Show resolved Hide resolved
to the Event data model, logging in this manner is also an acceptable way to
create Events.

## EventLoggerProvider

Expand Down
Loading