observability

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 23, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRunQueryLimit   = 50
	MaxRunQueryLimit       = 200
	DefaultEventQueryLimit = 200
	MaxEventQueryLimit     = 1000
)

Variables

This section is empty.

Functions

func CloneEvent

func CloneEvent(event core.Event) core.Event

func CloneRawMessage

func CloneRawMessage(value json.RawMessage) json.RawMessage

func NewEventFanoutSink

func NewEventFanoutSink(sinks ...core.EventSink) core.EventSink

func NormalizeEvent

func NormalizeEvent(event core.Event, now time.Time) core.Event

func ParentSpanFromContext added in v0.2.2

func ParentSpanFromContext(ctx context.Context) string

ParentSpanFromContext returns the parent span ID stored in ctx, if any.

func TraceFromContext added in v0.1.1

func TraceFromContext(ctx context.Context) (traceID, spanID string)

TraceFromContext returns the trace and span IDs stored in ctx by WithTrace. Both values are empty strings when no trace context is present.

func WithTrace added in v0.1.1

func WithTrace(ctx context.Context, traceID, spanID string) context.Context

WithTrace returns a new context carrying the given trace and span IDs. The IDs are automatically copied into core.Event fields by the runtime's emit path when this context is propagated through Run / RunHybrid / Stream.

func WithTraceParent added in v0.2.2

func WithTraceParent(ctx context.Context, traceID, spanID, parentSpanID string) context.Context

WithTraceParent returns a context with trace, span, and optional parent span IDs.

Types

type Attribute

type Attribute struct {
	Key   string
	Value string
}

type EventHub

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

func NewEventHub

func NewEventHub() *EventHub

func (*EventHub) PublishEvent

func (hub *EventHub) PublishEvent(ctx context.Context, record EventRecord) error

func (*EventHub) Subscribe

type EventPublisher

type EventPublisher interface {
	PublishEvent(ctx context.Context, record EventRecord) error
}

type EventQuery

type EventQuery struct {
	AfterSequence int64
	Limit         int
}

func NormalizeEventQuery

func NormalizeEventQuery(query EventQuery) EventQuery

type EventRecord

type EventRecord struct {
	ID        int64      `json:"id"`
	Sequence  int64      `json:"sequence"`
	Event     core.Event `json:"event"`
	CreatedAt time.Time  `json:"created_at"`
}

func CloneEventRecord

func CloneEventRecord(record EventRecord) EventRecord

type EventStore

type EventStore interface {
	Append(ctx context.Context, event core.Event) (EventRecord, error)
	ListRuns(ctx context.Context, query RunQuery) ([]RunSummary, error)
	ListEvents(ctx context.Context, runID string, query EventQuery) ([]EventRecord, error)
}

type EventStoreSink

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

func NewEventStoreSink

func NewEventStoreSink(store EventStore, publishers ...EventPublisher) *EventStoreSink

func (*EventStoreSink) Emit

func (sink *EventStoreSink) Emit(ctx context.Context, event core.Event) error

type EventSubscription

type EventSubscription struct {
	Events <-chan EventRecord
	Cancel func()
}

type EventSubscriptionFilter

type EventSubscriptionFilter struct {
	RunID  string
	Buffer int
}

type MetricName

type MetricName string
const (
	MetricRuntimeEventsTotal         MetricName = "agentflow_runtime_events_total"
	MetricRunDurationSeconds         MetricName = "agentflow_run_duration_seconds"
	MetricToolDurationSeconds        MetricName = "agentflow_tool_duration_seconds"
	MetricQueueJobsTotal             MetricName = "agentflow_queue_jobs_total"
	MetricQueueJobsQueued            MetricName = "agentflow_queue_jobs_queued"
	MetricQueueJobsRunning           MetricName = "agentflow_queue_jobs_running"
	MetricQueueJobsDeadLetter        MetricName = "agentflow_queue_jobs_dead_letter"
	MetricMemoryTierRecords          MetricName = "agentflow_memory_tier_records"
	MetricMemoryTierMigrationsTotal  MetricName = "agentflow_memory_tier_migrations_total"
	MetricMemoryRecallLatencySeconds MetricName = "agentflow_memory_recall_latency_seconds"
)

type NoopRecorder

type NoopRecorder struct{}

func (NoopRecorder) IncCounter

func (NoopRecorder) IncCounter(context.Context, MetricName, ...Attribute)

func (NoopRecorder) ObserveHistogram

func (NoopRecorder) ObserveHistogram(context.Context, MetricName, float64, ...Attribute)

func (NoopRecorder) SetGauge

type NoopTracer

type NoopTracer struct{}

func (NoopTracer) Start

type Recorder

type Recorder interface {
	IncCounter(ctx context.Context, name MetricName, attrs ...Attribute)
	ObserveHistogram(ctx context.Context, name MetricName, value float64, attrs ...Attribute)
	SetGauge(ctx context.Context, name MetricName, value float64, attrs ...Attribute)
}

type RecorderFunc

type RecorderFunc func(ctx context.Context, name MetricName, attrs ...Attribute)

func (RecorderFunc) IncCounter

func (fn RecorderFunc) IncCounter(ctx context.Context, name MetricName, attrs ...Attribute)

func (RecorderFunc) ObserveHistogram

func (fn RecorderFunc) ObserveHistogram(context.Context, MetricName, float64, ...Attribute)

func (RecorderFunc) SetGauge

type RunQuery

type RunQuery struct {
	Status RunStatus
	Limit  int
	Offset int
}

func NormalizeRunQuery

func NormalizeRunQuery(query RunQuery) RunQuery

type RunStatus

type RunStatus string
const (
	RunStatusRunning   RunStatus = "running"
	RunStatusPaused    RunStatus = "paused"
	RunStatusCompleted RunStatus = "completed"
	RunStatusFailed    RunStatus = "failed"
)

func StatusAfterEvent

func StatusAfterEvent(current RunStatus, eventType core.EventType) RunStatus

type RunSummary

type RunSummary struct {
	RunID         string         `json:"run_id"`
	ScenarioName  string         `json:"scenario_name,omitempty"`
	Status        RunStatus      `json:"status"`
	EventCount    int64          `json:"event_count"`
	FirstSeenAt   time.Time      `json:"first_seen_at"`
	LastSeenAt    time.Time      `json:"last_seen_at"`
	LastEventType core.EventType `json:"last_event_type"`
}

type Span

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

type SpanName

type SpanName string
const (
	SpanRuntimeEvent      SpanName = "agentflow.runtime.event"
	SpanRun               SpanName = "agentflow.run"
	SpanToolCall          SpanName = "agentflow.tool.call"
	SpanQueueJob          SpanName = "agentflow.queue.job"
	SpanMemoryTierRecall  SpanName = "agentflow.memory.tier.recall"
	SpanMemoryTierMigrate SpanName = "agentflow.memory.tier.migrate"
)

type Tracer

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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