Status: Development
Table of Contents
Users of OpenTelemetry need a way for instrumentation interactions with the OpenTelemetry API to actually produce telemetry. The OpenTelemetry SDK (henceforth referred to as the SDK) is an implementation of the OpenTelemetry API that provides users with this functionally.
All implementations of the OpenTelemetry API MUST provide an SDK.
From OpenTelemetry's perspective LogRecords and Events are both represented using the same data model. Therefore, the default implementation of an Event SDK MUST generate events using the Logs Data Model.
The SDK MUST use the Logs SDK to generate, process and export LogRecords.
The EventLoggerProvider MUST be implemented as a proxy to an instance of LoggerProvider.
All LogRecords produced by any EventLogger from the EventLoggerProvider SHOULD be associated with the Resource from the provided LoggerProvider.
The SDK SHOULD allow the creation of multiple independent EventLoggerProviders.
It SHOULD only be possible to create EventLogger instances through an EventLoggerProvider
(see Events API).
The EventLoggerProvider MUST implement the Get an EventLogger API.
In the case where an invalid name (null or empty string) is specified, a
working EventLogger MUST be returned as a fallback rather than returning null or
throwing an exception. Its name SHOULD keep the original invalid value, and a
message reporting that the specified value is invalid SHOULD be logged.
The EventLoggerProvider MUST accept an instance of LoggerProvider. Any configuration
related to processing MUST be done by configuring the LoggerProvider directly.
This method provides a way for the provider to notify the delegate LoggerProvider
to force all registered LogRecordProcessors to immediately export all
LogRecords that have not yet been exported.
The EventLogger MUST be implemented as a proxy to an instance of Logger.
Emit a LogRecord representing an Event.
Implementation Requirements:
The implementation MUST use the parameters to emit a logRecord as follows:
- The
NameMUST be used to set theevent.nameAttribute. If theAttributesprovided by the user contain anevent.nameattribute the value provided in theNametakes precedence. - If provided by the user, the
BodyMUST be used to set the Body. If not provided,BodyMUST not be set. - If provided by the user, the
TimestampMUST be used to set the Timestamp. If not provided,TimestampMUST be set to the current time when emit was called. - The Observed Timestamp MUST not be
set. (NOTE: emit a logRecord will
set
ObservedTimestampto the current time when unset.) - If provided by the user, the
ContextMUST be used to set the Context. If not provided,ContextMUST be set to the current Context. - If provided by the user, the
SeverityNumberMUST be used to set the Severity Number when emitting the logRecord. If not provided,SeverityNumberMUST be set toSEVERITY_NUMBER_INFO=9. - The Severity Text MUST not be set.
- If provided by the user, the
AttributesMUST be used to set the Attributes. The user providedAttributesMUST not take over theevent.nameattribute previously discussed.