Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AttachEventBus ¶ added in v0.7.0
AttachEventBus wires the new events.EventBus into the crew's callback chain alongside the existing telemetry bridge. This provides dual-emit during migration. @sk-task event-bus#T3.3: AttachEventBus convenience for crew wiring (AC-014)
Types ¶
type CallbackBridge ¶
type CallbackBridge struct {
// contains filtered or unexported fields
}
CallbackBridge converts crew/task/agent callbacks into telemetry events.
func NewCallbackBridge ¶
func NewCallbackBridge(bus *EventBus) *CallbackBridge
NewCallbackBridge creates a new CallbackBridge that publishes to the given EventBus.
func (*CallbackBridge) Attach ¶
func (cb *CallbackBridge) Attach(c *crew.Crew)
Attach subscribes to the crew's StepCallback. Must be called before Kickoff.
type DurationHistogram ¶
type DurationHistogram struct {
Count int64
TotalDuration time.Duration
Buckets map[string]int64
// contains filtered or unexported fields
}
DurationHistogram records latency distributions with fixed buckets.
func (*DurationHistogram) ApproxP50 ¶
func (h *DurationHistogram) ApproxP50() time.Duration
ApproxP50 returns an approximate P50 latency.
func (*DurationHistogram) ApproxP90 ¶
func (h *DurationHistogram) ApproxP90() time.Duration
ApproxP90 returns an approximate P90 latency.
func (*DurationHistogram) ApproxP99 ¶
func (h *DurationHistogram) ApproxP99() time.Duration
ApproxP99 returns an approximate P99 latency.
type Event ¶
type Event struct {
ID string
Timestamp time.Time
EventType EventType
Payload map[string]any
Metadata Metadata
}
Event represents a single observable event in the system.
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
EventBus provides in-process publish/subscribe for telemetry events.
func NewEventBus ¶
func NewEventBus(cfg EventBusConfig) *EventBus
NewEventBus creates a new EventBus with the given configuration.
func (*EventBus) PublishAsync ¶
PublishAsync asynchronously delivers an event to all matching subscribers. Each subscriber runs in its own goroutine. Panics are recovered and routed to the ErrorHandler if configured.
func (*EventBus) Subscribe ¶
func (b *EventBus) Subscribe(eventType EventType, handler EventHandler)
Subscribe adds a handler for the given event type. Use "*" as eventType to receive all events.
type EventBusConfig ¶
type EventBusConfig struct {
ErrorHandler func(error)
}
EventBusConfig configures the EventBus behavior.
type EventHandler ¶
type EventHandler func(event Event)
EventHandler is a function type for EventBus subscribers.
type EventType ¶
type EventType string
EventType is a string identifying the type of telemetry event.
const ( EventPhaseTransition EventType = "phase_transition" EventLLMCall EventType = "llm_call" EventToolExecution EventType = "tool_execution" EventError EventType = "error" EventCheckpoint EventType = "checkpoint" // @sk-task training#T4.1: add training telemetry events (AC-014) EventTrainStarted EventType = "train_started" EventTrainIteration EventType = "train_iteration" EventTrainCompleted EventType = "train_completed" EventTrainFailed EventType = "train_failed" // @sk-task dashboard-v2#T1.3: dashboard telemetry events (AC-001, AC-003, AC-004) EventAgentState EventType = "agent_state" EventTokenUsage EventType = "token_usage" EventTokenStream EventType = "token_stream" EventErrorAggregate EventType = "error_aggregate" // @sk-task output-streaming#T5.2: stream event types (AC-014) EventStreamChunk EventType = "stream_chunk" EventStreamFrame EventType = "stream_frame" )
EventType constants.
type Metadata ¶
type Metadata struct {
Source string
ProcessType string
TaskID string
AgentRole string
CheckpointID string
}
Metadata provides source context for a telemetry event.
type MetricsCollector ¶
type MetricsCollector struct {
// contains filtered or unexported fields
}
MetricsCollector aggregates telemetry events into metrics.
func NewMetricsCollector ¶
func NewMetricsCollector() *MetricsCollector
NewMetricsCollector creates a new MetricsCollector.
func (*MetricsCollector) GetSnapshot ¶
func (mc *MetricsCollector) GetSnapshot() MetricsSnapshot
GetSnapshot returns a point-in-time copy of all metrics.
func (*MetricsCollector) HandleEvent ¶
func (mc *MetricsCollector) HandleEvent(event Event)
HandleEvent implements EventHandler. It updates counters and histograms.
type MetricsSnapshot ¶
type MetricsSnapshot struct {
EventCounts map[string]int64
PerAgentCounts map[string]map[string]int64
PerTaskCounts map[string]map[string]int64
LatencyHistograms map[string]*DurationHistogram
}
MetricsSnapshot contains a point-in-time copy of all collected metrics.
type OTELBridge ¶
type OTELBridge struct{}
OTELBridge is a no-op stub when the otel build tag is not set.
func NewOTELBridge ¶
func NewOTELBridge(_ any, _ any) *OTELBridge
NewOTELBridge returns nil when the otel build tag is not set.
func (*OTELBridge) Attach ¶
func (b *OTELBridge) Attach(_ *crew.Crew)
Attach is a no-op when OTEL is not available.