otel

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package otel provides the in-process OpenTelemetry collector and SQLite WAL store for AgentPaaS observability data.

The store accepts OTLP trace, log, and metric data and persists it to a SQLite database in WAL mode for concurrent read access. All attribute values are redacted via internal/logging before storage. Audit JSONL records are NEVER stored here - they remain in the hash-chained audit trail managed by internal/audit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogRecord

type LogRecord struct {
	ID         int64     `json:"id"`
	Timestamp  time.Time `json:"timestamp"`
	TraceID    string    `json:"trace_id,omitempty"`
	SpanID     string    `json:"span_id,omitempty"`
	Severity   string    `json:"severity"`
	Body       string    `json:"body"`       // redacted
	Attributes string    `json:"attributes"` // JSON, redacted
	Resource   string    `json:"resource"`   // JSON, redacted
	Scope      string    `json:"scope"`      // JSON
}

LogRecord is a flattened OTel log stored in the otel_logs table.

type MetricRecord

type MetricRecord struct {
	ID         int64     `json:"id"`
	Name       string    `json:"name"`
	Type       string    `json:"type"` // gauge, sum, histogram
	Timestamp  time.Time `json:"timestamp"`
	Value      float64   `json:"value"`
	Attributes string    `json:"attributes"` // JSON, redacted
	Resource   string    `json:"resource"`   // JSON, redacted
}

MetricRecord is a flattened OTel metric data point stored in otel_metrics.

type SpanRecord

type SpanRecord struct {
	ID           int64     `json:"id"`
	TraceID      string    `json:"trace_id"`
	SpanID       string    `json:"span_id"`
	ParentSpanID string    `json:"parent_span_id,omitempty"`
	Name         string    `json:"name"`
	Kind         string    `json:"kind"`
	StartTime    time.Time `json:"start_time"`
	EndTime      time.Time `json:"end_time"`
	Attributes   string    `json:"attributes"` // JSON, redacted
	Status       string    `json:"status"`
	StatusCode   string    `json:"status_code"`
	Resource     string    `json:"resource"` // JSON, redacted
	Scope        string    `json:"scope"`    // JSON
}

SpanRecord is a flattened trace span stored in the otel_spans table.

type Store

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

Store is an in-process OTLP collector that persists traces, logs, and metrics to a SQLite WAL database. It is safe for concurrent use. Audit JSONL is NEVER stored here - only OTel telemetry data.

func NewStore

func NewStore(ctx context.Context, dbPath string) (*Store, error)

NewStore opens (or creates) the OTel SQLite store at dbPath. It enables WAL mode and sets busy_timeout for concurrent reader access.

func (*Store) Checkpoint

func (s *Store) Checkpoint(ctx context.Context) error

Checkpoint forces a WAL checkpoint (PASSIVE mode).

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying database connection.

func (*Store) IngestLogs

func (s *Store) IngestLogs(ctx context.Context, logs plog.Logs) error

IngestLogs stores OTLP log data (plog.Logs) into the database. All body and attribute values are redacted via logging.Redact before storage.

func (*Store) IngestMetrics

func (s *Store) IngestMetrics(ctx context.Context, metrics pmetric.Metrics) error

IngestMetrics stores OTLP metric data (pmetric.Metrics) into the database. All attribute values are redacted via logging.Redact before storage.

func (*Store) IngestTraces

func (s *Store) IngestTraces(ctx context.Context, traces ptrace.Traces) error

IngestTraces stores OTLP trace data (ptrace.Traces) into the database. All attribute values are redacted via logging.Redact before storage.

func (*Store) Prune

func (s *Store) Prune(ctx context.Context, retention time.Duration) (int64, error)

Prune deletes OTel data older than the retention period. This ONLY prunes OTel tables - audit JSONL is NEVER pruned by this method.

func (*Store) QueryLogs

func (s *Store) QueryLogs(ctx context.Context, runID string, limit int) ([]LogRecord, error)

QueryLogs returns logs matching the filter, ordered by timestamp.

func (*Store) QuerySpans

func (s *Store) QuerySpans(ctx context.Context, runID string, limit int) ([]SpanRecord, error)

QuerySpans returns spans matching the filter, ordered by start_time. limit <= 0 means no limit.

func (*Store) RecoverFromCorruption

func (s *Store) RecoverFromCorruption(ctx context.Context) (recovered int64, err error)

RecoverFromCorruption attempts to recover a corrupted database by creating a fresh database. It returns the number of records recovered (0 if the DB was unrecoverable and recreated empty).

Jump to

Keyboard shortcuts

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