Skip to content

Commit

Permalink
expand EventLoggerProvider and EventLogger
Browse files Browse the repository at this point in the history
  • Loading branch information
martinkuba committed May 3, 2024
1 parent 95fc80a commit 5d3a8a1
Showing 1 changed file with 70 additions and 8 deletions.
78 changes: 70 additions & 8 deletions specification/logs/event-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,81 @@ From OpenTelemetry's perspective LogRecords and Events are both represented
using the same [data model](./event-api.md#data-model). Therefore, the default
implementation of an Event SDK MUST generate events using the [Logs Data Model](./data-model.md).

The SDK MAY be implemented on top of the [Logs Bridge API](./bridge-api.md).
The SDK MUST use the default [Logs SDK](./sdk.md) to generate, process and export `LogRecord`s.

## EventLoggerProvider

TODO
The `EventLoggerProvider` MUST be implemented as a proxy to an instance of `LoggerProvider`.

## EventLogger
All `LogRecord`s produced by any `EventLogger` from the `EventLoggerProvider` SHOULD be associated with the `Resource` from the provided `LoggerProvider`.

### EventLoggerProvider Creation

The SDK SHOULD allow the creation of multiple independent `EventLoggerProviders`s.

### EventLogger Creation

It SHOULD only be possible to create `EventLogger` instances through a `EventLoggerProvider`
(see [Events API](event-api.md)).

The `EventLoggerProvider` MUST implement the [Get an EventLogger API](event-api.md#get-an-eventlogger).

The input provided by the user MUST be used to create
an [`InstrumentationScope`](../glossary.md#instrumentation-scope) instance which
is associated with `Event`s emitted by the created `EventLogger`.

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.

### Configuration

The `EventLoggerProvider` MUST accept an instance of `LoggerProvider`. Any configuration
related to processing MUST be done by configuring the `LoggerProvider` directly.

### Shutdown

This method provides a way for provider to do any cleanup required.

TODO
`Shutdown` MUST be called only once for each `EventLoggerProvider` instance. After
the call to `Shutdown`, subsequent attempts to get an `EventLogger` are not allowed.
SDKs SHOULD return a valid no-op `EventLogger` for these calls, if possible.

`Shutdown` SHOULD provide a way to let the caller know whether it succeeded,
failed or timed out.

`Shutdown` SHOULD complete or abort within some timeout. `Shutdown` MAY be
implemented as a blocking API or an asynchronous API which notifies the caller
via a callback or an event. [OpenTelemetry SDK](../overview.md#sdk) authors MAY
decide if they want to make the shutdown timeout configurable.

`Shutdown` MUST be implemented at least by invoking `Shutdown` on the delegate
`LoggerProvider`, which in effect invokes `Shutdown` on all registered
registered [LogRecordProcessors](#logrecordprocessor).

### ForceFlush

This method provides a way for the provider to notify the delegate `LoggerProvider`
to force all registered [LogRecordProcessors](#logrecordprocessor) to immediately export all
`LogRecords` that have not yet been exported.

`ForceFlush` SHOULD provide a way to let the caller know whether it succeeded,
failed or timed out. `ForceFlush` SHOULD return some **ERROR** status if there
is an error condition; and if there is no error condition, it SHOULD return
some **NO ERROR** status, language implementations MAY decide how to model
**ERROR** and **NO ERROR**.

`ForceFlush` SHOULD complete or abort within some timeout. `ForceFlush` MAY be
implemented as a blocking API or an asynchronous API which notifies the caller
via a callback or an event. [OpenTelemetry SDK](../overview.md#sdk) authors MAY
decide if they want to make the flush timeout configurable.

`ForceFlush` MUST invoke `ForceFlush` on all
[LogRecordProcessors](#logrecordprocessor) that are registered with the delegate
`LoggerProvider`.

## EventLogger

### Emit Event

Expand Down Expand Up @@ -76,7 +142,3 @@ to [emit a logRecord](./bridge-api.md#emit-a-logrecord) as follows:
the [Attributes](./data-model.md#field-attributes). The user
provided `Attributes` MUST not take over the `event.name`
attribute previously discussed.

## Additional Interfaces

TODO

0 comments on commit 5d3a8a1

Please sign in to comment.