Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Enabled method to Logger #4020

Merged
merged 14 commits into from
May 28, 2024
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

- Add the experimental `Enabled` API to the `Logger`.
([#4020](https://github.com/open-telemetry/opentelemetry-specification/pull/4020))

### Events

### Resource
Expand Down
1 change: 1 addition & 0 deletions spec-compliance-matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ Disclaimer: this list of features is still a work in progress, please refer to t
| LoggerProvider.Shutdown | | | + | | | | | + | | | - | |
| LoggerProvider.ForceFlush | | | + | | | | | + | | | - | |
| Logger.Emit(LogRecord) | | | + | | | | | + | | + | - | |
| Logger.Enabled | X | + | | | | | | | + | + | | |
| SimpleLogRecordProcessor | | | + | | | | | + | | + | | |
| BatchLogRecordProcessor | | | + | | | | | + | | + | | |
| Can plug custom LogRecordProcessor | | | + | | | | | + | | + | | |
Expand Down
28 changes: 27 additions & 1 deletion specification/logs/bridge-api.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Logs Bridge API

**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 @@
- [Logger](#logger)
* [Logger operations](#logger-operations)
+ [Emit a LogRecord](#emit-a-logrecord)
+ [Enabled](#enabled)
- [Optional and required parameters](#optional-and-required-parameters)
- [Concurrency requirements](#concurrency-requirements)
- [Artifact Naming](#artifact-naming)
Expand Down Expand Up @@ -108,6 +109,10 @@ The `Logger` MUST provide functions to:

- Emit a `LogRecord`

The `Logger` SHOULD provide functions to:

- Report if `Enabled` for a `LogRecord`

#### Emit a LogRecord

The effect of calling this API is to emit a `LogRecord` to the processing pipeline.
Expand All @@ -127,6 +132,27 @@ The API MUST accept the following parameters:

All parameters are optional.

#### Enabled

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

To help users avoid performing computationally expensive operations when
generating a `LogRecord`, a `Logger` SHOULD provide this `Enabled` API.

There are currently no required parameters for this API. Parameters can be
added in the future, therefore, the API MUST be structured in a way for
parameters to be added.

This API MUST return a language idiomatic boolean type.

Implementations of this API SHALL return `true` when logging is enabled or
pellared marked this conversation as resolved.
Show resolved Hide resolved
`false` when logging is disabled for the provided arguments. Implementations
designed for performance that cache the logging state MAY return stale values.
MrAlias marked this conversation as resolved.
Show resolved Hide resolved

MrAlias marked this conversation as resolved.
Show resolved Hide resolved
The returned value is not always static, it can change over time. The API
SHOULD be documented that users needs to call this API each time they generate
MrAlias marked this conversation as resolved.
Show resolved Hide resolved
a `LogRecord` to ensure they have the most up-to-date response.

## Optional and required parameters

The operations defined include various parameters, some of which are marked
Expand Down
Loading