SDK implementation of the Otel.API.Logs.Logger behaviour
(logs/sdk.md §Logger).
Emits log records by dispatching to all registered processors. Populates trace context from the resolved Context and sets observed_timestamp when not provided.
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
| Function | Role |
|---|---|
emit/3 | SDK (OTel API MUST) — logs/api.md L111-L131 + logs/sdk.md §Emit |
enabled?/2 | SDK (OTel API SHOULD) — logs/api.md L133-L154 + logs/sdk.md §Enabled |
LogRecord limits
build_log_record/3 composes the two
Otel.SDK.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/3 runs once per
emit/3 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.mdL99-L155 - OTLP
mapping-to-non-otlp.md§Dropped Attributes Count: L73-L79
Summary
Functions
SDK (OTel API MUST) — Emit a LogRecord
(logs/api.md L111-L131).
SDK (OTel API SHOULD) — Enabled
(logs/api.md L133-L154 + logs/sdk.md §Enabled L256-L268).
Functions
@spec emit( logger :: Otel.API.Logs.Logger.t(), ctx :: Otel.API.Ctx.t(), log_record :: Otel.API.Logs.LogRecord.t() ) :: :ok
SDK (OTel API MUST) — Emit a LogRecord
(logs/api.md L111-L131).
Dispatches the limited record to every registered processor.
@spec enabled?( logger :: Otel.API.Logs.Logger.t(), opts :: Otel.API.Logs.Logger.enabled_opts() ) :: boolean()
SDK (OTel API SHOULD) — Enabled
(logs/api.md L133-L154 + logs/sdk.md §Enabled L256-L268).
Returns false when no processors are registered, or when every
processor implementing enabled?/4 returns false. The
Development-status LoggerConfig filter legs (L259-L266 —
enabled / minimum_severity / trace_based) are deferred per the
project's Stable-only policy, mirroring how
Otel.SDK.Trace.Tracer.enabled?/2 defers TracerConfig.