log

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package log holds the logs signal's ingest model: the []byte-based, OTLP-shaped, zero-alloc batch accepted at the storage boundary (in place of OTel-Go plog.Logs), and its projection into the columnar log-record model the logs engine ingests.

It mirrors signal/metric: a resettable, pool-friendly Resource→Scope→Record hierarchy holding all identity as []byte (never string), so an embedder decoding OTLP can build it by aliasing the decode buffer, and projecting copies nothing. The difference from metrics is the data shape: a metric is a stream of (ts, float) samples, a log is a stream of rich records (time, severity, body, attributes, trace context). Identity (the stream labels: Resource+Scope) is indexed like a metric series; the per-record fields are columns the query filters by condition.

Index

Constants

View Source
const (
	ColObserved     = "observed"
	ColSeverity     = "severity"
	ColFlags        = "flags"
	ColDropped      = "dropped"
	ColSeverityText = "severity_text"
	ColBody         = "body"
	ColTraceID      = "trace_id"
	ColSpanID       = "span_id"
	ColAttrs        = "attrs"
)

Column names of the logs schema (the per-record columns; the primary timestamp and the stream id are implicit in the record engine).

Variables

Schema is the logs vertical's record-engine column schema: four small int columns, the body (full-text bloom), the trace/span ids, severity text, and the serialized per-record attributes (attribute bloom). The primary timestamp (the record's event time) is the implicit sort key.

Functions

func Project added in v0.2.0

func Project(ld Logs, emit func(*recordengine.Batch)) (accepted int)

Project iterates a Logs batch and calls emit once per stream (each Resource+Scope group) with a recordengine.Batch of that stream's records laid out in the logs Schema's column order. It returns how many records were emitted. The batch and its column buffers are reused across emit calls — do not retain them.

func PutLogs added in v0.2.0

func PutLogs(l *Logs)

PutLogs resets l and returns it to the pool. Do not use l after this call. The byte payloads l references are not owned by the pool; the caller must ensure they are no longer aliased.

Types

type Logs

type Logs struct {
	Resources []ResourceLogs
}

Logs is the internal logs ingest batch — the OTLP Resource→Scope→Record hierarchy with all identity as []byte. It is resettable and pool-friendly: Logs.Reset keeps every backing array, so a batch from GetLogs returned with PutLogs recycles across ingest calls with no allocation. Build it with the Add* helpers, which reuse the retained capacity.

func GetLogs added in v0.2.0

func GetLogs() *Logs

GetLogs returns a reset Logs from a shared pool. Pair it with PutLogs to recycle the batch (and its backing arrays) across ingest calls.

func (*Logs) AddResource added in v0.2.0

func (l *Logs) AddResource() *ResourceLogs

AddResource appends a fresh ResourceLogs and returns a pointer to it. The slot's Resource is zeroed and its Scopes emptied (capacity retained).

func (*Logs) Reset added in v0.2.0

func (l *Logs) Reset()

Reset clears the batch for reuse while retaining the capacity of all backing arrays.

type Record added in v0.2.0

type Record struct {
	// Attributes are the record's attributes. They must be sorted by key (use
	// [signal.NewAttributes]); the engine serializes them in order into the attrs column.
	Attributes        signal.Attributes
	Timestamp         int64 // unix nanos; the record's event time (the part sort key)
	ObservedTimestamp int64 // unix nanos; when the collector observed it (0 if unset)
	SeverityNumber    int32 // OTLP severity number (1..24; 0 unspecified)
	SeverityText      []byte
	Body              []byte
	TraceID           []byte // 16 bytes, or nil
	SpanID            []byte // 8 bytes, or nil
	Flags             uint32
	Dropped           uint32 // dropped_attributes_count
}

Record is a single OTLP log record. Body is the record body's text (a string AnyValue held as raw bytes; non-string bodies are rendered to text by the producer). TraceID/SpanID are the raw 16- and 8-byte ids (nil if unset). A record present in a Logs batch is well-formed by construction.

type ResourceLogs added in v0.2.0

type ResourceLogs struct {
	Resource signal.Resource
	Scopes   []ScopeLogs
}

ResourceLogs groups the log records emitted under one signal.Resource.

func (*ResourceLogs) AddScope added in v0.2.0

func (rl *ResourceLogs) AddScope() *ScopeLogs

AddScope appends a fresh ScopeLogs under the resource and returns a pointer to it. The slot's Scope is zeroed and its Records emptied (capacity retained).

type ScopeLogs added in v0.2.0

type ScopeLogs struct {
	Scope   signal.Scope
	Records []Record
}

ScopeLogs groups the log records emitted under one signal.Scope (InstrumentationScope). A (Resource, Scope) pair is one log **stream**.

func (*ScopeLogs) AddRecord added in v0.2.0

func (sl *ScopeLogs) AddRecord() *Record

AddRecord appends a fresh Record under the scope and returns a pointer to it for the caller to populate. The slot is fully zeroed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL