otel

package
v0.37.1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package otel provides in-process OTLP telemetry storage and a receiver.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogQuery

type LogQuery struct {
	Service  string
	Severity string
	Search   string
	TraceID  string
	Limit    int
	Offset   int
	Since    *time.Time
}

type LogRecordPayload

type LogRecordPayload struct {
	TraceID  *string `json:"trace_id"`
	Severity string  `json:"severity"`
	Body     string  `json:"body"`
	Service  string  `json:"service"`
}

type LogSeverity

type LogSeverity string
const (
	SeverityTrace LogSeverity = "Trace"
	SeverityDebug LogSeverity = "Debug"
	SeverityInfo  LogSeverity = "Info"
	SeverityWarn  LogSeverity = "Warn"
	SeverityError LogSeverity = "Error"
	SeverityFatal LogSeverity = "Fatal"
)

func SeverityFromNumber

func SeverityFromNumber(n int32) LogSeverity

func SeverityFromString

func SeverityFromString(s string) LogSeverity

func (LogSeverity) Rank

func (s LogSeverity) Rank() int

Rank orders severities for minimum-level filtering (Trace < … < Fatal).

type MetricPoint

type MetricPoint struct {
	Timestamp time.Time `json:"timestamp"`
	Value     float64   `json:"value"`
}

MetricPoint is a time-series datapoint.

type MetricQuery

type MetricQuery struct {
	Service    string
	MetricName string
	Limit      int
	Offset     int
}

type MetricSeriesQuery

type MetricSeriesQuery struct {
	Service    string
	MetricName string
}

type MetricType

type MetricType string
const (
	MetricGauge     MetricType = "Gauge"
	MetricCounter   MetricType = "Counter"
	MetricHistogram MetricType = "Histogram"
)

type MetricUpdatePayload

type MetricUpdatePayload struct {
	Name    string  `json:"name"`
	Value   float64 `json:"value"`
	Service string  `json:"service"`
}

type Receiver

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

Receiver holds an in-process OTLP HTTP + gRPC listener.

func NewReceiver

func NewReceiver(store *Store, events chan<- WSEvent) *Receiver

NewReceiver creates an OTLP receiver that ingests into store and publishes WSEvents to eventsCh.

func (*Receiver) StartGRPC

func (r *Receiver) StartGRPC(ctx context.Context, port uint16) error

StartGRPC starts the OTLP gRPC receiver on the given port.

func (*Receiver) StartHTTP

func (r *Receiver) StartHTTP(ctx context.Context, port uint16) error

StartHTTP starts the OTLP HTTP receiver on the given port.

type ServiceStatusChangePayload

type ServiceStatusChangePayload struct {
	Service string `json:"service"`
	Status  string `json:"status"`
}

type SpanEvent

type SpanEvent struct {
	Name       string      `json:"name"`
	Timestamp  time.Time   `json:"timestamp"`
	Attributes [][2]string `json:"attributes"`
}

type SpanKind

type SpanKind string
const (
	SpanKindInternal SpanKind = "Internal"
	SpanKindServer   SpanKind = "Server"
	SpanKindClient   SpanKind = "Client"
	SpanKindProducer SpanKind = "Producer"
	SpanKindConsumer SpanKind = "Consumer"
)

type SpanQuery

type SpanQuery struct {
	Service       string
	TraceID       string
	OnlyError     bool
	OnlyOk        bool
	Search        string
	MinDurationMs float64
	Limit         int
	Offset        int
}

type SpanStatus

type SpanStatus string
const (
	SpanStatusOk    SpanStatus = "Ok"
	SpanStatusError SpanStatus = "Error"
	SpanStatusUnset SpanStatus = "Unset"
)

type Store

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

Store is an in-memory ring-buffer telemetry store with secondary indexes.

func NewStore

func NewStore(maxSpans, maxLogs, maxMetrics int, retention time.Duration) *Store

NewStore creates a store with given limits and retention.

func (*Store) GetMetricSeries

func (s *Store) GetMetricSeries(q *MetricSeriesQuery) []MetricPoint

func (*Store) GetRelated

func (s *Store) GetRelated(traceID string) ([]StoredLog, []StoredMetric)

func (*Store) GetTrace

func (s *Store) GetTrace(traceID string) (TraceDetail, bool)

func (*Store) InsertLog

func (s *Store) InsertLog(log StoredLog)

func (*Store) InsertMetric

func (s *Store) InsertMetric(m StoredMetric)

func (*Store) InsertSpan

func (s *Store) InsertSpan(span StoredSpan)

func (*Store) QueryLogs

func (s *Store) QueryLogs(q *LogQuery) []StoredLog

func (*Store) QueryMetrics

func (s *Store) QueryMetrics(q *MetricQuery) []StoredMetric

func (*Store) QueryTraces

func (s *Store) QueryTraces(q *SpanQuery) []TraceSummary

func (*Store) Status

func (s *Store) Status() SystemStatus

func (*Store) SweepRetention

func (s *Store) SweepRetention()

SweepRetention removes records older than the retention window.

type StoredLog

type StoredLog struct {
	RecordID    uint64      `json:"record_id"`
	Timestamp   time.Time   `json:"timestamp"`
	ServiceName string      `json:"service_name"`
	Severity    LogSeverity `json:"severity"`
	Body        string      `json:"body"`
	TraceID     *string     `json:"trace_id"`
	SpanID      *string     `json:"span_id"`
	Attributes  [][2]string `json:"attributes"`
}

type StoredMetric

type StoredMetric struct {
	RecordID    uint64      `json:"record_id"`
	Timestamp   time.Time   `json:"timestamp"`
	ServiceName string      `json:"service_name"`
	MetricName  string      `json:"metric_name"`
	MetricType  MetricType  `json:"metric_type"`
	Value       float64     `json:"value"`
	Attributes  [][2]string `json:"attributes"`
	Unit        *string     `json:"unit"`
}

type StoredSpan

type StoredSpan struct {
	RecordID      uint64      `json:"record_id"`
	TraceID       string      `json:"trace_id"`
	SpanID        string      `json:"span_id"`
	ParentSpanID  *string     `json:"parent_span_id"`
	ServiceName   string      `json:"service_name"`
	OperationName string      `json:"operation_name"`
	StartTime     time.Time   `json:"start_time"`
	EndTime       time.Time   `json:"end_time"`
	DurationMs    uint64      `json:"duration_ms"`
	Status        SpanStatus  `json:"status"`
	StatusMessage *string     `json:"status_message"`
	Attributes    [][2]string `json:"attributes"`
	Kind          SpanKind    `json:"kind"`
	Events        []SpanEvent `json:"events"`
}

type SystemStatus

type SystemStatus struct {
	TraceCount  int      `json:"trace_count"`
	SpanCount   int      `json:"span_count"`
	LogCount    int      `json:"log_count"`
	MetricCount int      `json:"metric_count"`
	Services    []string `json:"services"`
}

SystemStatus summarises the store counts.

type TraceDetail

type TraceDetail struct {
	TraceID string       `json:"trace_id"`
	Spans   []StoredSpan `json:"spans"`
}

TraceDetail is the full expanded trace.

type TraceSummary

type TraceSummary struct {
	TraceID       string    `json:"trace_id"`
	Services      []string  `json:"services"`
	RootOperation string    `json:"root_operation"`
	DurationMs    uint64    `json:"duration_ms"`
	SpanCount     int       `json:"span_count"`
	HasError      bool      `json:"has_error"`
	StartTime     time.Time `json:"start_time"`
	HTTPStatus    *int      `json:"http_status,omitempty"`
}

TraceSummary is the list-view for a single trace.

type TraceUpdatePayload

type TraceUpdatePayload struct {
	TraceID    string `json:"trace_id"`
	Service    string `json:"service"`
	DurationMs uint64 `json:"duration_ms"`
	HasError   bool   `json:"has_error"`
}

type WSEvent

type WSEvent struct {
	Type    string          `json:"type"`
	Payload json.RawMessage `json:"payload"`
}

func MakeLogRecordEvent

func MakeLogRecordEvent(p LogRecordPayload) WSEvent

func MakeMetricUpdateEvent

func MakeMetricUpdateEvent(p MetricUpdatePayload) WSEvent

func MakeServiceStatusEvent

func MakeServiceStatusEvent(p ServiceStatusChangePayload) WSEvent

func MakeTraceUpdateEvent

func MakeTraceUpdateEvent(p TraceUpdatePayload) WSEvent

Jump to

Keyboard shortcuts

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