observability

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmitWorkerEvent

func EmitWorkerEvent(evt WorkerEvent)

EmitWorkerEvent notifies the active listener of worker lifecycle events.

func RecordAskMetrics

func RecordAskMetrics(callerKind, calleeKind, command string, duration time.Duration, err error)

RecordAskMetrics emits metrics for ask-style cross-actor commands.

func RecordCommandMetrics

func RecordCommandMetrics(kind, command string, duration time.Duration, err error)

RecordCommandMetrics emits histogram/counter data for a command execution.

func RecordQueryMetrics

func RecordQueryMetrics(callerKind, calleeKind, query string, duration time.Duration, err error)

RecordQueryMetrics emits metrics for cross-actor queries.

func SetListener

func SetListener(l Listener)

SetListener configures the lifecycle listener used by the runtime.

func SetMeter

func SetMeter(m Meter)

SetMeter configures the meter used by the runtime.

func SetTracer

func SetTracer(t Tracer)

SetTracer configures the tracer used by the runtime.

Types

type AskEvent

type AskEvent struct {
	CallerKind      string
	CallerID        string
	CallerWorkflow  string
	CallerRunID     string
	CallerTaskQueue string
	TargetKind      string
	TargetID        string
	Command         string
	CorrelationID   string
	Attributes      []Attribute
}

AskEvent describes cross-actor ask executions.

type Attribute

type Attribute struct {
	Key   string
	Value any
}

Attribute describes a key/value pair passed to tracers or meters.

func Bool

func Bool(key string, value bool) Attribute

Bool returns an Attribute with a boolean value.

func Duration

func Duration(key string, value time.Duration) Attribute

Duration returns an Attribute with a duration value.

func Int

func Int(key string, value int) Attribute

Int returns an Attribute with an integer value.

func String

func String(key, value string) Attribute

String returns an Attribute with a string value.

type CommandEvent

type CommandEvent struct {
	ActorKind     string
	Command       string
	WorkflowID    string
	RunID         string
	TaskQueue     string
	MessageID     string
	CorrelationID string
	CallerKind    string
	CallerID      string
	Attributes    []Attribute
}

CommandEvent describes command execution attempts.

type Listener

type Listener interface {
	CommandStart(ctx context.Context, evt CommandEvent)
	CommandFinish(ctx context.Context, evt CommandEvent, err error, duration time.Duration)
	AskStart(ctx context.Context, evt AskEvent)
	AskFinish(ctx context.Context, evt AskEvent, err error, duration time.Duration)
	QueryStart(ctx context.Context, evt QueryEvent)
	QueryFinish(ctx context.Context, evt QueryEvent, err error, duration time.Duration)
}

Listener receives deterministic lifecycle hooks emitted by the runtime.

func ActiveListener

func ActiveListener() Listener

ActiveListener returns the currently configured lifecycle listener.

type ListenerAdapter

type ListenerAdapter struct{}

ListenerAdapter provides no-op implementations so callers can embed it.

func (ListenerAdapter) AskFinish

func (ListenerAdapter) AskStart

func (ListenerAdapter) CommandFinish

func (ListenerAdapter) CommandStart

func (ListenerAdapter) QueryFinish

func (ListenerAdapter) QueryStart

func (ListenerAdapter) WorkerEvent

type Meter

type Meter interface {
	RecordHistogram(ctx context.Context, name string, value time.Duration, attrs ...Attribute)
	AddCounter(ctx context.Context, name string, value int64, attrs ...Attribute)
}

Meter emits metrics such as counters or histograms.

type QueryEvent

type QueryEvent struct {
	CallerKind      string
	CallerID        string
	CallerWorkflow  string
	CallerRunID     string
	CallerTaskQueue string
	TargetKind      string
	TargetID        string
	Query           string
	CorrelationID   string
	Attributes      []Attribute
}

QueryEvent describes cross-actor queries.

type Span

type Span interface {
	End(err error)
	SetAttributes(attrs ...Attribute)
	RecordError(err error)
}

Span wraps an in-flight trace span.

type Tracer

type Tracer interface {
	Start(ctx context.Context, name string, attrs ...Attribute) (context.Context, Span)
}

Tracer creates spans for commands and other actor events.

func ActiveTracer

func ActiveTracer() Tracer

ActiveTracer returns the currently configured tracer.

type WorkerEvent

type WorkerEvent struct {
	Queue      string
	Role       WorkerRole
	Type       WorkerEventType
	Error      error
	Reason     string
	ActorKinds []string
}

WorkerEvent describes lifecycle changes for workflow or activity workers.

type WorkerEventType

type WorkerEventType string

WorkerEventType categorizes worker lifecycle events.

const (
	WorkerEventStart    WorkerEventType = "start"
	WorkerEventStop     WorkerEventType = "stop"
	WorkerEventError    WorkerEventType = "error"
	WorkerEventDisabled WorkerEventType = "disabled"
)

type WorkerLifecycleListener

type WorkerLifecycleListener interface {
	WorkerEvent(ctx context.Context, evt WorkerEvent)
}

WorkerLifecycleListener observes worker start/stop/failure events. Listener implementations can optionally satisfy this interface to receive worker events.

type WorkerRole

type WorkerRole string

WorkerRole identifies the worker category emitting events.

const (
	WorkerRoleWorkflow WorkerRole = "workflow"
	WorkerRoleActivity WorkerRole = "activity"
)

Jump to

Keyboard shortcuts

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