Documentation
¶
Index ¶
- Constants
- func CloneEvent(event core.Event) core.Event
- func CloneRawMessage(value json.RawMessage) json.RawMessage
- func DeleteEventsForRun(ctx context.Context, store EventStore, runID string) (int64, error)
- func EventAllowedByPreset(typ core.EventType, preset core.EventFilterPreset) bool
- func NewEventFanoutSink(sinks ...core.EventSink) core.EventSink
- func NormalizeEvent(event core.Event, now time.Time) core.Event
- func ParentSpanFromContext(ctx context.Context) string
- func PurgeEventsBefore(ctx context.Context, store EventStore, cutoff time.Time) (int64, error)
- func StampEventTenant(ctx context.Context, event *core.Event)
- func TenantIDFromContext(ctx context.Context) string
- func TraceFromContext(ctx context.Context) (traceID, spanID string)
- func WithTrace(ctx context.Context, traceID, spanID string) context.Context
- func WithTraceParent(ctx context.Context, traceID, spanID, parentSpanID string) context.Context
- type Attribute
- type EventHub
- type EventPublisher
- type EventQuery
- type EventRecord
- type EventRunPurger
- type EventStore
- type EventStorePurger
- type EventStoreSink
- type EventSubscription
- type EventSubscriptionFilter
- type MetricName
- type NoopRecorder
- func (NoopRecorder) AddCounter(context.Context, MetricName, float64, ...Attribute)
- func (NoopRecorder) IncCounter(context.Context, MetricName, ...Attribute)
- func (NoopRecorder) ObserveHistogram(context.Context, MetricName, float64, ...Attribute)
- func (NoopRecorder) SetGauge(context.Context, MetricName, float64, ...Attribute)
- type NoopTracer
- type Recorder
- type RecorderFunc
- func (fn RecorderFunc) AddCounter(ctx context.Context, name MetricName, value float64, attrs ...Attribute)
- func (fn RecorderFunc) IncCounter(ctx context.Context, name MetricName, attrs ...Attribute)
- func (fn RecorderFunc) ObserveHistogram(context.Context, MetricName, float64, ...Attribute)
- func (fn RecorderFunc) SetGauge(context.Context, MetricName, float64, ...Attribute)
- type RunQuery
- type RunStatus
- type RunSummary
- type ScopedEventQuery
- type SequencedEventStore
- type Span
- type SpanName
- type Tracer
Constants ¶
const ( DefaultRunQueryLimit = 50 MaxRunQueryLimit = 200 DefaultEventQueryLimit = 200 MaxEventQueryLimit = 1000 )
Variables ¶
This section is empty.
Functions ¶
func CloneRawMessage ¶
func CloneRawMessage(value json.RawMessage) json.RawMessage
func DeleteEventsForRun ¶ added in v0.3.1
DeleteEventsForRun deletes all stored events of runID when the store implements EventRunPurger; otherwise it is a no-op reporting 0, so retention callers work unchanged against stores without purge support.
func EventAllowedByPreset ¶ added in v0.3.0
func EventAllowedByPreset(typ core.EventType, preset core.EventFilterPreset) bool
EventAllowedByPreset reports whether an event type belongs in the query view.
func ParentSpanFromContext ¶ added in v0.2.2
ParentSpanFromContext returns the parent span ID stored in ctx, if any.
func PurgeEventsBefore ¶ added in v0.3.1
PurgeEventsBefore deletes events older than cutoff when the store implements EventStorePurger; otherwise it is a no-op reporting 0.
func StampEventTenant ¶ added in v0.4.4
StampEventTenant binds an unstamped event to the authenticated tenant. Principal-less local/CLI execution keeps the legacy empty tenant.
func TenantIDFromContext ¶ added in v0.4.4
TenantIDFromContext returns the authenticated tenant carried by ctx.
func TraceFromContext ¶ added in v0.1.1
TraceFromContext returns the trace and span IDs stored in ctx by WithTrace. Both values are empty strings when no trace context is present.
Types ¶
type EventHub ¶
type EventHub struct {
// contains filtered or unexported fields
}
func NewEventHub ¶
func NewEventHub() *EventHub
func (*EventHub) DroppedEvents ¶ added in v0.3.0
DroppedEvents reports how many event deliveries were dropped because a subscriber's buffer was full. A growing value means consumers are falling behind and events are being lost.
func (*EventHub) PublishEvent ¶
func (hub *EventHub) PublishEvent(ctx context.Context, record EventRecord) error
func (*EventHub) Subscribe ¶
func (hub *EventHub) Subscribe(ctx context.Context, filter EventSubscriptionFilter) EventSubscription
type EventPublisher ¶
type EventPublisher interface {
PublishEvent(ctx context.Context, record EventRecord) error
}
type EventQuery ¶
type EventQuery struct {
TenantID string
AfterSequence int64
Limit int
// Preset selects a read-side event view (product_ui or diagnostic).
// Empty defaults to diagnostic (full stream). Filtering is projection-only;
// Append always stores every event.
Preset core.EventFilterPreset
}
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 EventRunPurger ¶ added in v0.3.1
type EventRunPurger interface {
EventStore
DeleteEventsForRun(ctx context.Context, runID string) (int64, error)
}
EventRunPurger is an optional EventStore extension for the retention cascade: DeleteEventsForRun removes every stored event of a run when the run itself is deleted, so event history does not outlive its run.
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)
ListScopedEvents(ctx context.Context, query ScopedEventQuery) ([]EventRecord, error)
}
type EventStorePurger ¶ added in v0.3.1
type EventStorePurger interface {
EventStore
PurgeEventsBefore(ctx context.Context, cutoff time.Time) (int64, error)
}
EventStorePurger is an optional EventStore extension for age-based retention: PurgeEventsBefore removes events that occurred before cutoff, bounding the otherwise append-only event table.
type EventStoreSink ¶
type EventStoreSink struct {
// contains filtered or unexported fields
}
func NewEventStoreSink ¶
func NewEventStoreSink(store EventStore, publishers ...EventPublisher) *EventStoreSink
type EventSubscription ¶
type EventSubscription struct {
Events <-chan EventRecord
Cancel func()
}
type EventSubscriptionFilter ¶
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" MetricLLMTokensTotal MetricName = "agentflow_llm_tokens_total" MetricLLMDurationSeconds MetricName = "agentflow_llm_duration_seconds" MetricLLMErrorsTotal MetricName = "agentflow_llm_errors_total" MetricToolErrorsTotal MetricName = "agentflow_tool_errors_total" )
type NoopRecorder ¶
type NoopRecorder struct{}
func (NoopRecorder) AddCounter ¶ added in v0.5.0
func (NoopRecorder) AddCounter(context.Context, MetricName, float64, ...Attribute)
func (NoopRecorder) IncCounter ¶
func (NoopRecorder) IncCounter(context.Context, MetricName, ...Attribute)
func (NoopRecorder) ObserveHistogram ¶
func (NoopRecorder) ObserveHistogram(context.Context, MetricName, float64, ...Attribute)
func (NoopRecorder) SetGauge ¶
func (NoopRecorder) SetGauge(context.Context, MetricName, float64, ...Attribute)
type NoopTracer ¶
type NoopTracer struct{}
type Recorder ¶
type Recorder interface {
IncCounter(ctx context.Context, name MetricName, attrs ...Attribute)
// AddCounter adds a non-negative delta in one operation. Token and byte
// totals must use this instead of issuing one IncCounter call per unit.
AddCounter(ctx context.Context, name MetricName, value float64, 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, value float64, attrs ...Attribute)
func (RecorderFunc) AddCounter ¶ added in v0.5.0
func (fn RecorderFunc) AddCounter(ctx context.Context, name MetricName, value float64, 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 ¶
func (fn RecorderFunc) SetGauge(context.Context, MetricName, float64, ...Attribute)
type RunQuery ¶
func NormalizeRunQuery ¶
type RunSummary ¶
type RunSummary struct {
RunID string `json:"run_id"`
TenantID string `json:"tenant_id,omitempty"`
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 ScopedEventQuery ¶ added in v0.3.0
type ScopedEventQuery struct {
TenantID string
EpisodeID string
SessionID string
AfterID int64
Limit int
Preset core.EventFilterPreset
}
ScopedEventQuery lists events across runs that share an Episode or Session. Exactly one of EpisodeID or SessionID must be set. AfterID is a global store cursor (EventRecord.ID), not a per-run sequence.
func NormalizeScopedEventQuery ¶ added in v0.3.0
func NormalizeScopedEventQuery(query ScopedEventQuery) ScopedEventQuery
type SequencedEventStore ¶ added in v0.3.1
type SequencedEventStore interface {
EventStore
AppendSequenced(ctx context.Context, sequence int64, event core.Event) (EventRecord, error)
}
SequencedEventStore is an optional EventStore extension used by the framework outbox relay: AppendSequenced inserts an event with a per-run sequence minted earlier (when the event was parked in the outbox), instead of assigning a fresh one. Delivery is idempotent: when (run_id, sequence) is already present the store returns the existing record and a nil error, so relay retries and concurrent relays never duplicate an event.
type SpanName ¶
type SpanName string
const ( SpanRuntimeEvent SpanName = "agentflow.runtime.event" SpanRun SpanName = "agentflow.run" SpanToolCall SpanName = "agentflow.tool.call" SpanLLMCall SpanName = "agentflow.llm.call" SpanMCPRPC SpanName = "agentflow.mcp.rpc" SpanContextPrepare SpanName = "agentflow.context.prepare" SpanQueueJob SpanName = "agentflow.queue.job" SpanMemoryTierRecall SpanName = "agentflow.memory.tier.recall" SpanMemoryTierMigrate SpanName = "agentflow.memory.tier.migrate" )