Otel.Logs.Logger (otel v0.4.1)

Copy Markdown View Source

Log record emission entry points for the SDK.

Minikube has no plugin ecosystem and the spec's LoggerProvider/Logger entities collapse to a single hardcoded identity:

Scope and limits are compile-time literals; there is no Logger struct to thread through.

All functions are safe for concurrent use, satisfying spec logs/api.md L172-L176 (Status: Stable, #4885) — "Logger — all methods MUST be documented that implementations need to be safe for concurrent use by default."

Public API

FunctionRole
emit/2SDK (OTel API MUST) — logs/api.md L111-L131 + logs/sdk.md §Emit

LogRecord limits

build_log_record/2 composes the two Otel.Logs.LogRecordLimits helpers in order — truncate_attributes/2 first (so dropped count is taken on the post-truncation map), then drop_attributes/2. The dropped_attributes_count field on the record is the size delta across the drop step, satisfying mapping-to-non-otlp.md L73-79 ("OpenTelemetry dropped attributes count MUST be reported as a key-value pair ... otel.dropped_attributes_count").

Per logs/sdk.md L345-348, a single Logger.warning/1 is emitted per LogRecord whenever either limit took effect. The MUST "at most once per LogRecord" is satisfied structurally — build_log_record/2 runs once per emit/2 call.

Self-reference

The warning re-enters the OTel pipeline whenever Otel.LoggerHandler is installed. The re-entered record carries a single short-string attribute payload, well below the default limits, so it produces no additional warning — the recursion is bounded at depth 1. Matches opentelemetry-erlang: otel_log_handler.erl L233 emits ?LOG_WARNING(...) on exporter failure, and otel_exporter.erl / otel_configuration.erl use ?LOG_WARNING / ?LOG_INFO throughout — none filter their own warnings out of the OTel bridge.

References

  • OTel Logs SDK §Logger: opentelemetry-specification/specification/logs/sdk.md
  • OTel Logs API §Logger: opentelemetry-specification/specification/logs/api.md L99-L155
  • OTLP mapping-to-non-otlp.md §Dropped Attributes Count: L73-L79

Summary

Functions

Emit a LogRecord (logs/api.md L111-L131) with an explicit context.

Functions

emit(ctx, log_record)

@spec emit(ctx :: Otel.Ctx.t(), log_record :: Otel.Logs.LogRecord.t()) :: :ok

Emit a LogRecord (logs/api.md L111-L131) with an explicit context.

Dispatches the limited record to every registered processor. Per L119-L123 omitting ctx falls back to the implicit process-local context.