logread

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package logread is the thin pure-Go function-log reader (ADR-0084): it merges the compacted Parquet (ADR-0083) with the recent raw OTLP-JSONL tail (ADR-0081) over the blob.Bucket port, filters by time/severity/limit, and returns a tenant's function logs time-ordered. No DuckDB, no cgo, lakehouse-independent. Tenant scoping is the caller's concern (the control-plane PEP authorizes the namespace before calling Read); this package just reads the namespace it is given.

Index

Constants

View Source
const (
	// DefaultLimit caps a read when Query.Limit is unset.
	DefaultLimit = 1000
	// MaxLimit hard-caps a read (≈ a few MB of lines — bounds a runaway scan).
	MaxLimit = 10000
)

Variables

This section is empty.

Functions

func SeverityNumber

func SeverityNumber(level string) (int32, bool)

SeverityNumber maps a level name (trace|debug|info|warn|error|fatal, case-insensitive) to its OTLP SeverityNumber threshold (the lowest number at that level); ok=false for an unknown name. "" ⇒ (0, true) = no filter.

Types

type BlobReader

type BlobReader struct {
	// contains filtered or unexported fields
}

BlobReader is the blob-backed Reader (compacted Parquet + raw OTLP-JSONL tail over blob.Bucket).

func NewBlobReader

func NewBlobReader(b blob.Bucket) *BlobReader

NewBlobReader builds the reader over the funcd-system observability bucket.

func (*BlobReader) Read

func (r *BlobReader) Read(ctx context.Context, q Query) ([]Line, error)

Read merges the compacted Parquet and the raw OTLP-JSONL tail for (Namespace, Function), filters by Since/MinSeverityNumber, sorts ascending by time, and returns the most-recent Limit (the tail).

type Line

type Line struct {
	Time           time.Time       `json:"time"`
	Severity       string          `json:"severity"`
	SeverityNumber int32           `json:"severityNumber"`
	Body           string          `json:"body"`
	Namespace      string          `json:"namespace"`
	Function       string          `json:"function"`
	Replica        string          `json:"replica"`
	Source         string          `json:"source"`
	Invocation     string          `json:"inv,omitempty"`
	TraceID        string          `json:"traceId,omitempty"`
	SpanID         string          `json:"spanId,omitempty"`
	Attrs          json.RawMessage `json:"attrs,omitempty"`
}

Line is one log record returned to a caller (the wire + CLI DTO; a friendlier view of compact.Row).

type Query

type Query struct {
	Namespace         string
	Function          string
	Since             time.Time // zero ⇒ no lower bound
	MinSeverityNumber int32     // 0 ⇒ all severities
	Limit             int       // <= 0 ⇒ DefaultLimit; capped at MaxLimit
	// TraceID scopes the read to one run's trace (ADR-0106): "" ⇒ no trace filter (ADR-0084 per-function
	// behavior). When Function == "" && TraceID != "", Read scans the whole logs/<ns>/ prefix (namespace-wide,
	// run-scoped) — every step function's lines for that run, incl. sub-workflow children (same trace, ADR-0104).
	TraceID string
}

Query selects + bounds a read. Namespace is required; Function OR TraceID must be set (a bare namespace scan with no trace filter is rejected — see Read's guard). The rest are optional filters.

type Reader

type Reader interface {
	Read(ctx context.Context, q Query) ([]Line, error)
}

Reader returns a function's logs, newest-bounded by Query.

Jump to

Keyboard shortcuts

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