Skip to content

Commit

Permalink
Update 4290-logger-enabled.md
Browse files Browse the repository at this point in the history
  • Loading branch information
pellared authored Dec 16, 2024
1 parent 81bb7e0 commit 65683dd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions oteps/logs/4290-logger-enabled.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ by adding to the Logs SDK a `LogRecordProcessor` implementing `Enabled`.
## Internal details

Regarding (1) (2), the Logs API specification has already introduced `Logger.Enabled`:

- [Add Enabled method to Logger #4020](https://github.com/open-telemetry/opentelemetry-specification/pull/4020)
- [Define Enabled parameters for Logger #4203](https://github.com/open-telemetry/opentelemetry-specification/pull/4203)

Expand Down Expand Up @@ -84,6 +85,7 @@ as it means that there no processor does is going to process
the log record.
Pseudo-code:

<!-- markdownlint-disable no-hard-tabs -->
```go
func (l *logger) Enabled(ctx context.Context, param EnabledParameters) bool {
config := l.config()
Expand Down Expand Up @@ -111,6 +113,7 @@ func (l *logger) Enabled(ctx context.Context, param EnabledParameters) bool {
return false
}
```
<!-- markdownlint-enable no-hard-tabs -->

## Trade-offs and mitigations

Expand Down Expand Up @@ -172,11 +175,13 @@ who should know whether the log record should not be emitted
when the span is not sampled. For instrumentation libraries
it may make more sense to control it on the API level, e.g.:

<!-- markdownlint-disable no-hard-tabs -->
```go
if trace.SpanContextFromContext(ctx).IsSampled() && logger.Enabled(ctx, params) {
logger.Emit(ctx, createLogRecord(payload))
}
```
<!-- markdownlint-enable no-hard-tabs -->

## Future possibilities

Expand Down

0 comments on commit 65683dd

Please sign in to comment.