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 ¶
- type LogRecord
- type MetricRecord
- type SpanRecord
- type Store
- func (s *Store) Checkpoint(ctx context.Context) error
- func (s *Store) Close() error
- func (s *Store) IngestLogs(ctx context.Context, logs plog.Logs) error
- func (s *Store) IngestMetrics(ctx context.Context, metrics pmetric.Metrics) error
- func (s *Store) IngestTraces(ctx context.Context, traces ptrace.Traces) error
- func (s *Store) Prune(ctx context.Context, retention time.Duration) (int64, error)
- func (s *Store) QueryLogs(ctx context.Context, runID string, limit int) ([]LogRecord, error)
- func (s *Store) QuerySpans(ctx context.Context, runID string, limit int) ([]SpanRecord, error)
- func (s *Store) RecoverFromCorruption(ctx context.Context) (recovered int64, err error)
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 ¶
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 ¶
Checkpoint forces a WAL checkpoint (PASSIVE mode).
func (*Store) IngestLogs ¶
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 ¶
IngestMetrics stores OTLP metric data (pmetric.Metrics) into the database. All attribute values are redacted via logging.Redact before storage.
func (*Store) IngestTraces ¶
IngestTraces stores OTLP trace data (ptrace.Traces) into the database. All attribute values are redacted via logging.Redact before storage.
func (*Store) Prune ¶
Prune deletes OTel data older than the retention period. This ONLY prunes OTel tables - audit JSONL is NEVER pruned by this method.
func (*Store) QuerySpans ¶
QuerySpans returns spans matching the filter, ordered by start_time. limit <= 0 means no limit.
func (*Store) RecoverFromCorruption ¶
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).