Skip to content

Commit a2d06cf

Browse files
authored
Split out Event API from Log API (open-telemetry#2941)
Resolves open-telemetry#2917. Depends on open-telemetry#2940.
1 parent dd6272f commit a2d06cf

File tree

6 files changed

+88
-38
lines changed

6 files changed

+88
-38
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ release.
1818
- Move `event.domain` from InstrumentationScope attributes to LogRecord
1919
attributes.
2020
([#2940](https://github.com/open-telemetry/opentelemetry-specification/pull/2940))
21+
- Split out Event API from Log API
22+
([#2941](https://github.com/open-telemetry/opentelemetry-specification/pull/2941))
2123

2224
### Resource
2325

specification/logs/README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,10 @@ Given the above state of the logging space we took the following approach:
157157
features than what is defined in OpenTelemetry. It is NOT a goal of
158158
OpenTelemetry to ship a feature-rich logging library.
159159

160-
- OpenTelemetry defines an API for [emitting Events](./api.md#emit-event).
161-
Application developers are encouraged to call this API directly.
160+
- OpenTelemetry defines an API for [emitting Events](./event-api.md). The API
161+
consists of convenience methods which delegate to the API
162+
for [emitting LogRecords](./api.md#emit-logrecord). Application developers are
163+
encouraged to call this API directly.
162164

163165
- OpenTelemetry defines an [SDK](./sdk.md) implementation of the [API](./api.md),
164166
which enables configuration of [processing](./sdk.md#logrecordprocessor)

specification/logs/api.md

+11-34
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Events and Logs API Interface
1+
# Logs API Interface
22

33
**Status**: [Experimental](../document-status.md)
44

@@ -14,7 +14,6 @@
1414
+ [Get a Logger](#get-a-logger)
1515
- [Logger](#logger)
1616
* [Logger operations](#logger-operations)
17-
+ [Emit Event](#emit-event)
1817
+ [Emit LogRecord](#emit-logrecord)
1918
- [LogRecord](#logrecord)
2019
- [Usage](#usage)
@@ -26,20 +25,19 @@
2625

2726
</details>
2827

29-
The Events and Logs API consist of these main classes:
28+
The Logs API consist of these main classes:
3029

3130
* LoggerProvider is the entry point of the API. It provides access to Loggers.
3231
* Logger is the class responsible for
33-
creating [Events](./semantic_conventions/events.md)
34-
and [Logs](./data-model.md#log-and-event-record-definition) as LogRecords.
32+
emitting [Logs](./data-model.md#log-and-event-record-definition) as
33+
LogRecords.
3534

3635
LoggerProvider/Logger are analogous to TracerProvider/Tracer.
3736

3837
```mermaid
3938
graph TD
4039
A[LoggerProvider] -->|Get| B(Logger)
41-
B --> C(Event)
42-
B --> D(Log)
40+
B --> C(Log)
4341
```
4442

4543
## LoggerProvider
@@ -91,12 +89,9 @@ produced by this library.
9189
the scope has a version (e.g. a library version). Example value: 1.0.0.
9290
- `schema_url` (optional): Specifies the Schema URL that should be recorded in
9391
the emitted telemetry.
94-
- `event_domain` (optional): Specifies the domain for the Events emitted, which
95-
MUST be added as an attribute with the key `event.domain`
96-
to [emitted Events](#emit-event).
9792
- `include_trace_context` (optional): Specifies whether the Trace Context should
98-
automatically be passed on to the Events and Logs emitted by the Logger. This
99-
SHOULD be true by default.
93+
automatically be passed on to the LogRecords emitted by the Logger. This
94+
SHOULD be true by default.
10095
- `attributes` (optional): Specifies the instrumentation scope attributes to
10196
associate with emitted telemetry.
10297

@@ -111,7 +106,7 @@ identifying fields are equal. The term *distinct* applied to Loggers describes
111106
instances where at least one identifying field has a different value.
112107

113108
Implementations MUST NOT require users to repeatedly obtain a Logger again with
114-
the same name+version+schema_url+event_domain+include_trace_context+attributes
109+
the same name+version+schema_url+include_trace_context+attributes
115110
to pick up configuration changes. This can be achieved either by allowing to
116111
work with an outdated configuration or by ensuring that new configuration
117112
applies also to previously returned Loggers.
@@ -120,7 +115,7 @@ Note: This could, for example, be implemented by storing any mutable
120115
configuration in the `LoggerProvider` and having `Logger` implementation objects
121116
have a reference to the `LoggerProvider` from which they were obtained.
122117
If configuration must be stored per-Logger (such as disabling a certain `Logger`),
123-
the `Logger` could, for example, do a look-up with its name+version+schema_url+event_domain+include_trace_context+attributes
118+
the `Logger` could, for example, do a look-up with its name+version+schema_url+include_trace_context+attributes
124119
in a map in the `LoggerProvider`, or the `LoggerProvider` could maintain a registry
125120
of all returned `Logger`s and actively update their configuration if it changes.
126121

@@ -130,7 +125,7 @@ the emitted data format is capable of representing such association.
130125

131126
## Logger
132127

133-
The `Logger` is responsible for emitting Events and Logs.
128+
The `Logger` is responsible for emitting `LogRecord`s
134129

135130
Note that `Logger`s should not be responsible for configuration. This should be
136131
the responsibility of the `LoggerProvider` instead.
@@ -139,24 +134,6 @@ the responsibility of the `LoggerProvider` instead.
139134

140135
The Logger MUST provide functions to:
141136

142-
#### Emit Event
143-
144-
Emit a `LogRecord` representing an Event to the processing pipeline.
145-
146-
This function MAY be named `logEvent`.
147-
148-
**Parameters:**
149-
150-
* `name` - the Event name. This argument MUST be recorded as a `LogRecord`
151-
attribute with the key `event.name`. Care MUST be taken by the implementation
152-
to not override or delete this attribute while the Event is emitted to
153-
preserve its identity.
154-
* `logRecord` - the [LogRecord](#logrecord) representing the Event.
155-
156-
Events require the `event.domain` attribute. The API MUST not allow creating an
157-
Event if `event_domain` was not specified when
158-
the [Logger was obtained](#get-a-logger).
159-
160137
#### Emit LogRecord
161138

162139
Emit a `LogRecord` to the processing pipeline.
@@ -173,7 +150,7 @@ by end users or other instrumentation.
173150

174151
## LogRecord
175152

176-
The API emits [Events](#emit-event) and [LogRecords](#emit-logrecord) using
153+
The API emits [LogRecords](#emit-logrecord) using
177154
the `LogRecord` [data model](data-model.md).
178155

179156
A function receiving this as an argument MUST be able to set the following

specification/logs/event-api.md

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Events API Interface
2+
3+
**Status**: [Experimental](../document-status.md)
4+
5+
<details>
6+
<summary>Table of Contents</summary>
7+
8+
<!-- Re-generate TOC with `markdown-toc --no-first-h1 -i` -->
9+
10+
<!-- toc -->
11+
12+
- [EventLogger](#eventlogger)
13+
* [EventLogger Operations](#eventlogger-operations)
14+
+ [Create EventLogger](#create-eventlogger)
15+
+ [Emit Event](#emit-event)
16+
17+
<!-- tocstop -->
18+
19+
</details>
20+
21+
The Event API offers convenience methods
22+
for [emitting LogRecords](./api.md#emit-logrecord) that conform
23+
to the [semantic conventions for Events](./semantic_conventions/events.md).
24+
25+
## EventLogger
26+
27+
The `EventLogger` is the entrypoint of the Event API, and is responsible for
28+
emitting `Events` as `LogRecords`.
29+
30+
### EventLogger Operations
31+
32+
The `EventLogger` MUST provide functions to:
33+
34+
#### Create EventLogger
35+
36+
New `EventLogger` instances are created though a constructor or factory method
37+
on `EventLogger`.
38+
39+
**Parameters:**
40+
41+
* `logger` - the delegate [Logger](./api.md#logger) used to emit `Events`
42+
as `LogRecords`.
43+
* `event_domain` - the domain of emitted events, used to set the `event.domain`
44+
attribute.
45+
46+
#### Emit Event
47+
48+
Emit a `LogRecord` representing an `Event` to the delegate `Logger`.
49+
50+
This function MAY be named `logEvent`.
51+
52+
**Parameters:**
53+
54+
* `event_name` - the Event name. This argument MUST be recorded as a `LogRecord`
55+
attribute with the key `event.name`. Care MUST be taken by the implementation
56+
to not override or delete this attribute while the Event is emitted to
57+
preserve its identity.
58+
* `logRecord` - the [LogRecord](./api.md#logrecord) representing the Event.
59+
60+
**Implementation Requirements:**
61+
62+
The implementation MUST [emit](./api.md#emit-logrecord) the `logRecord` to
63+
the `logger` specified when [creating the EventLogger](#create-eventlogger)
64+
after making the following changes:
65+
66+
* The `event_domain` specified
67+
when [creating the EventLogger](#create-eventlogger) MUST be set as
68+
the `event.domain` attribute on the `logRecord`.
69+
* The `event_name` MUST be set as the `event.name` attribute on the `logRecord`.
10.3 KB
Loading

specification/logs/semantic_conventions/exceptions.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
**Status**: [Experimental](../../document-status.md)
44

55
This document defines semantic conventions for recording exceptions on
6-
[logs](../api.md#emit-logrecord) and [events](../api.md#emit-event) emitted
7-
through the [Logger API](../api.md#logger).
6+
[logs](../api.md#emit-logrecord) and [events](../event-api.md#emit-event)
7+
emitted through the [Logger API](../api.md#logger).
88

99
<!-- toc -->
1010

0 commit comments

Comments
 (0)