observe

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KindExecuted     = "executed"
	KindError        = "error"
	KindRetry        = "retry"
	KindCacheHit     = "cache_hit"
	KindCacheMiss    = "cache_miss"
	KindCanceled     = "canceled"
	KindPanic        = "panic"
	KindCoalesced    = "coalesced"
	KindDeduplicated = "deduplicated"
)

Variables

This section is empty.

Functions

func Hook

func Hook(sink Sink) action.AnyHook

Types

type Event

type Event struct {
	Time        time.Time
	Duration    time.Duration
	Kind        string
	Action      string
	RequestID   string
	ExecutionID string
	TraceID     string
	SpanID      string
	TenantID    string
	UserID      string
	Request     any
	Response    any
	Error       error
	Recovered   any
	Attempt     int
}

type JSONLSink

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

func NewJSONLSink

func NewJSONLSink(writer io.Writer, maxBytes int) *JSONLSink

func (*JSONLSink) Emit

func (s *JSONLSink) Emit(_ context.Context, event Event)

type MemorySink

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

func NewMemorySink

func NewMemorySink(capacity int) *MemorySink

func (*MemorySink) Emit

func (s *MemorySink) Emit(_ context.Context, event Event)

func (*MemorySink) Events

func (s *MemorySink) Events() []Event

type MetricKey

type MetricKey struct {
	Action string
	Kind   string
}

MetricKey uniquely identifies a lifecycle event counter.

type MetricsSink

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

MetricsSink aggregates lifecycle event counts in memory.

func NewMetricsSink

func NewMetricsSink() *MetricsSink

NewMetricsSink creates an empty metrics sink.

func (*MetricsSink) Emit

func (s *MetricsSink) Emit(_ context.Context, event Event)

func (*MetricsSink) Snapshot

func (s *MetricsSink) Snapshot() map[MetricKey]uint64

Snapshot returns an isolated thread-safe copy of all counters.

type PrometheusSink

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

func NewPrometheusSink

func NewPrometheusSink() *PrometheusSink

func (*PrometheusSink) Emit

func (s *PrometheusSink) Emit(ctx context.Context, event Event)

func (*PrometheusSink) Snapshot

func (s *PrometheusSink) Snapshot() map[MetricKey]uint64

func (*PrometheusSink) WritePrometheus

func (s *PrometheusSink) WritePrometheus(w io.Writer) error

type Sink

type Sink interface {
	Emit(context.Context, Event)
}

type SlogSink

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

SlogSink writes structured lifecycle events to a standard-library slog.Logger.

func NewSlogSink

func NewSlogSink(logger *slog.Logger) *SlogSink

NewSlogSink creates a sink using logger. If logger is nil, slog.Default() is used.

func (*SlogSink) Emit

func (s *SlogSink) Emit(ctx context.Context, event Event)

Jump to

Keyboard shortcuts

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