Skip to content

Commit

Permalink
Define how SDK implements Logger.Enabled (#4381)
Browse files Browse the repository at this point in the history
  • Loading branch information
pellared authored Jan 23, 2025
1 parent 7116ef8 commit c55ed5c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ release.

### Logs

- Define how SDK implements `Logger.Enabled`.
([#4381](https://github.com/open-telemetry/opentelemetry-specification/pull/4381))

### Baggage

### Resource
Expand Down
9 changes: 8 additions & 1 deletion specification/logs/noop.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ linkTitle: No-Op

# Logs API No-Op Implementation

**Status**: [Stable](../document-status.md)
**Status**: [Stable](../document-status.md), except where otherwise specified

<details>
<summary> Table of Contents </summary>
Expand All @@ -15,6 +15,7 @@ linkTitle: No-Op
* [Logger Creation](#logger-creation)
- [Logger](#logger)
* [Emit LogRecord](#emit-logrecord)
* [Enabled](#enabled)

<!-- tocstop -->

Expand Down Expand Up @@ -55,3 +56,9 @@ return the same `Logger` instances to all creation requests.

The No-Op `Logger` MUST allow
for [emitting LogRecords](./api.md#emit-a-logrecord).

### Enabled

**Status**: [Development](../document-status.md)

MUST always return `false`.
13 changes: 13 additions & 0 deletions specification/logs/sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* [ForceFlush](#forceflush)
- [Logger](#logger)
* [LoggerConfig](#loggerconfig)
* [Enabled](#enabled)
- [Additional LogRecord interfaces](#additional-logrecord-interfaces)
* [ReadableLogRecord](#readablelogrecord)
* [ReadWriteLogRecord](#readwritelogrecord)
Expand Down Expand Up @@ -190,6 +191,18 @@ It consists of the following parameters:
necessary for implementations to ensure that changes to `disabled` are
immediately visible to callers of `Enabled`.

### Enabled

**Status**: [Development](../document-status.md)

`Enabled` MUST return `false` when:

- there are no registered [`LogRecordProcessors`](#logrecordprocessor),
- `Logger` is disabled ([`LoggerConfig.disabled`](#loggerconfig) is `true`).

Otherwise, it SHOULD return `true`.
It MAY return `false` to support additional optimizations and features.

## Additional LogRecord interfaces

In this document we refer to `ReadableLogRecord` and `ReadWriteLogRecord`, defined as follows.
Expand Down

0 comments on commit c55ed5c

Please sign in to comment.