Events API Interface
Wikipedia’s definition of log file:
In computing, a log file is a file that records either events that occur in an operating system or other software runs.
From OpenTelemetry’s perspective LogRecords and Events are both represented using the same data model.
However, OpenTelemetry does recognize a subtle semantic difference between
LogRecords and Events: Events are LogRecords which have a
Within a particular
name uniquely defines a particular class or
type of event. Events with the same
name follow the same schema
which assists in analysis in observability platforms. Events are described in
more detail in the semantic conventions.
While the logging space has a diverse legacy with many existing logging libraries in different languages, there is not ubiquitous alignment with OpenTelemetry events. In some logging libraries, producing records shaped as OpenTelemetry events is clunky or error-prone.
The Event API offers convenience methods for emitting LogRecords that conform to the semantic conventions for Events. Unlike the Logs Bridge API, application developers and instrumentation authors are encouraged to call this API directly.
EventLogger is the entrypoint of the Event API, and is responsible for
EventLogger MUST provide functions to:
EventLogger instances are created though a constructor or factory method
logger- the delegate Logger used to emit
event_domain- the domain of emitted events, used to set the
LogRecord representing an
Event to the delegate
This function MAY be named
event_name- the Event name. This argument MUST be recorded as a
LogRecordattribute with the key
event.name. Care MUST be taken by the implementation to not override or delete this attribute while the Event is emitted to preserve its identity.
logRecord- the LogRecord representing the Event.
event_domainspecified when creating the EventLogger MUST be set as the
event.domainattribute on the
event_nameMUST be set as the
event.nameattribute on the