Slog record fields¶
otelcore.Slog writes one slog record per metric data point, per ended span, per span
event and per log record. The fields below appear in this order. The format is for
reading: it is documented here, but it is not a wire contract. For a machine-readable
format, use otelcore.Writer, which writes OTLP JSON lines.
A signal's own attributes always go in a group called attrs, so an attribute called
name or value can't collide with a field below. TextHandler prints them as
attrs.cache.name=orders, and JSONHandler as a nested object. A record with no
attributes has no group.
Metric data points¶
Message metric, level Info, timed at the data point's time. A zero time is passed
through, so most handlers leave the time out.
| Kind | Fields after name, unit, kind |
|---|---|
sum |
value, monotonic |
gauge |
value |
histogram |
count, sum, min, max, buckets |
exponential_histogram |
count, sum, min, max |
summary |
count, sum |
unknown |
none |
value,sum,minandmaxare integers for an integer instrument and floats for a float one.monotonicistruefor a counter andfalsefor an up-down counter.minandmaxare left out when the data point doesn't record them.bucketslists each non-empty bucket as its upper bound and its count, with the overflow bucket asinf:buckets="0.005=4 0.01=1 inf=2". Counts are per bucket, not cumulative.- Values are cumulative, so the latest line for a series is its running total.
Left out: exponential histogram buckets, scale and zero count, summary quantiles, and exemplars.
Spans¶
Message span, level Info, timed at the span's end.
| Field | Value |
|---|---|
name |
The span name |
kind |
internal, server, client, producer or consumer |
status |
Unset, Error or Ok |
status_message |
The status description, when there is one |
duration |
End time minus start time |
trace_id, span_id |
Hex |
parent_span_id |
Hex, when the span has a parent |
Left out: links.
Span events¶
Message span.event, level Info, timed at the event, written straight after its span.
Fields: name, trace_id, span_id. An exception recorded by spanerr carries its
exception.* attributes, listed in Exception attributes.
Log records¶
The message is the record's body, in its string form when it isn't a string. Timed at the record's timestamp, or its observed timestamp when that is unset.
| OTel severity | slog level |
|---|---|
| Unset | Info |
| Trace1 to Debug4 | Debug |
| Info1 to Info4 | Info |
| Warn1 to Warn4 | Warn |
| Error1 to Fatal4 | Error |
Fields: trace_id and span_id when the record was emitted inside a span, then
event_name when it has one.
Left off every record¶
The resource (service.name and the rest) and the instrumentation scope. Add what you
need with logger.With.