-
Notifications
You must be signed in to change notification settings - Fork 926
Description
OpenTelemetry has added the concept of an event, but has not fully defined the purpose of events. This has created some confusion and difficulty in the Event SIG, and will create further confusion as events become stable. Before we go any further, I'm requesting that we agree on the purpose of events, and how they relate to logs, and add this description to the specification. Much like how we recently defined the purpose of OpenTelemetry attributes, clarity here will allow us to make coherent decisions in our design.
Through many discussions, I believe that we have arrived at a useful definition, and the motivations for that definition. I've described it below:
OpenTelemetry Events
Unlike some other systems, OpenTelemetry's definition of an event is not a separate data stream. In OpenTelemetry, an event is a "semantically rigorous log." Events in OpenTelemetry are explicitly defined as semantic convention for logs.
Because OpenTelemetry is designed to emit logs that are not only human readable, but machine readable, a definition for rigorous semantics is needed. Whenever OpenTelemetry instrumentation emits a log to describe a computer operation, that log MUST have the same level of semantic consistency that we expect from other signals such as traces and metrics. The term that OpenTelemetry uses for these structured logs is "event." Any semantic convention that we define for the log signal MUST be defined as an event.
That's it. That's what an event is in OpenTelemetry. The structure used for creating semantic conventions for logs. Nothing more, nothing less.
OpenTelemetry Event API
What is the purpose of the Event API in OpenTelemetry? OpenTelemetry exposes an Event API, but does not expose a Log API. Why is this? To answer this question, we must divide logs into two categories: logs created by end users and logs created by shared instrumentation.
End users are encouraged to continue using their existing logger in their application, and to add a log appender that sends these logs to the log bridge API. End users are not required to use the Event API.
That said, end users may want to log events. If their logger is capable of emitting a structured log that matches the OpenTelemetry definition of an event, users MAY use their logger to create events, as events are just semantic conventions for logs. However, if their logger is not capable of emitting this kind of structured log, end users SHOULD use the OpenTelemetry Event API for this purpose.
Shared OpenTelemetry instrumentation – library instrumentation designed to be loaded into many applications – MUST use the OpenTelemetry API. This is for three reasons.
First, shared instrumentation packages should not emit unstructured logs, they should only emit fully structured and semantically rigorous logs designed for machine analysis, because these packages are only describing computer operations. If the computer operations being described are common, they should be added to our registry of semantic conventions so that they can be consistent across all of the libraries that emit the same event.
The second and more important reason for requiring the use of the Event API is that shared instrumentation must be loaded into many applications, and taking a dependency on a third party logger is incredibly problematic.
If an instrumentation package pulls in a third party logger, the chances that it select the exact logger selected by the end user is low. It is unreasonable to assume that all end users will select the same logger. This means that the end user must know of the existence of this additional logger, and must correctly configure it with a log appender to either send the data to the OpenTelemetry log bridge or to the end user's primary logger. Different shared instrumentation packages may choose different loggers. Determining how many loggers and what kind of loggers are present across all of the shared instrumentation packages pulled into their application is a huge burden to place on an end user. From a product perspective, this is a terrible experience.
Finally, and most importantly, shared instrumentation packages may in fact choose the same logger, but choose incompatible versions. This creates exactly the kind of unresolvable dependency conflict that OpenTelemetry works hard to avoid. For this reason alone, all shared instrumentation must use the Event API in order to record OpenTelemetry events. To create an OpenTelemetry API that explicitly avoids dependency conflicts, only to have all of that hard work undone by requiring shared instrumentation to depend upon a third party logger is a non-starter for OpenTelemetry. It violates a core tenant of OpenTelemetry API design and cannot be allowed.
OpenTelemetry Event SDK
Because OpenTelemetry defines events as logs with rigorous semantic conventions, there is no separate SDK for events. The SDK creates a log object from the Event API, and passes that object into the top of the log pipeline. All events contain an event.name
attribute, so it is easy to write log processors that only process events.
Okay, that's it. Those are the definitions and motivations that we have come to. Please let me know what you think in the comments.