Documentation
¶
Index ¶
- type DispatcherMetrics
- func (dm *DispatcherMetrics) EventProcessed()
- func (dm *DispatcherMetrics) IssueClaimed()
- func (dm *DispatcherMetrics) IssueRequeued()
- func (dm *DispatcherMetrics) IssueRouted()
- func (dm *DispatcherMetrics) IssueUnclaimed()
- func (dm *DispatcherMetrics) PollCompleted(d time.Duration)
- func (dm *DispatcherMetrics) Snapshot() DispatcherSnapshot
- type DispatcherSnapshot
- type PoolMetrics
- type PoolSnapshot
- type SystemCollector
- type SystemSnapshot
- type TaskResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DispatcherMetrics ¶
type DispatcherMetrics struct {
// contains filtered or unexported fields
}
DispatcherMetrics tracks live dispatcher statistics. It is safe for concurrent use.
func NewDispatcherMetrics ¶
func NewDispatcherMetrics() *DispatcherMetrics
NewDispatcherMetrics creates a DispatcherMetrics.
func (*DispatcherMetrics) EventProcessed ¶
func (dm *DispatcherMetrics) EventProcessed()
EventProcessed increments the event counter.
func (*DispatcherMetrics) IssueClaimed ¶
func (dm *DispatcherMetrics) IssueClaimed()
IssueClaimed increments the claimed issue count.
func (*DispatcherMetrics) IssueRequeued ¶
func (dm *DispatcherMetrics) IssueRequeued()
IssueRequeued increments the requeue counter.
func (*DispatcherMetrics) IssueRouted ¶
func (dm *DispatcherMetrics) IssueRouted()
IssueRouted increments the total routed counter.
func (*DispatcherMetrics) IssueUnclaimed ¶
func (dm *DispatcherMetrics) IssueUnclaimed()
IssueUnclaimed decrements the claimed issue count, floored at zero.
func (*DispatcherMetrics) PollCompleted ¶
func (dm *DispatcherMetrics) PollCompleted(d time.Duration)
PollCompleted records a poll cycle's latency and updates LastPollAt.
func (*DispatcherMetrics) Snapshot ¶
func (dm *DispatcherMetrics) Snapshot() DispatcherSnapshot
Snapshot returns a point-in-time copy of the dispatcher metrics.
type DispatcherSnapshot ¶
type DispatcherSnapshot struct {
// CollectedAt is the time the snapshot was taken.
CollectedAt time.Time
// ClaimedCount is the number of issues currently claimed by agents.
ClaimedCount int
// TotalRouted is the total issues routed since dispatcher start.
TotalRouted int64
// TotalRequeued is the total issues that failed and were requeued.
TotalRequeued int64
// TotalEventsProcessed is the total events processed since dispatcher start.
TotalEventsProcessed int64
// AvgPollLatency is the rolling average time between poll cycle completions.
// Zero if no cycles have completed.
AvgPollLatency time.Duration
// LastPollAt is the time the last poll cycle completed.
LastPollAt time.Time
}
DispatcherSnapshot captures dispatcher state at a point in time.
type PoolMetrics ¶
type PoolMetrics struct {
// contains filtered or unexported fields
}
PoolMetrics tracks live pool statistics. It is safe for concurrent use. The agent pool updates it via WorkerStarted, WorkerFinished, and SetQueueDepth.
func NewPoolMetrics ¶
func NewPoolMetrics(totalWorkers int) *PoolMetrics
NewPoolMetrics creates a PoolMetrics with the given total worker count.
func (*PoolMetrics) SetQueueDepth ¶
func (pm *PoolMetrics) SetQueueDepth(n int)
SetQueueDepth updates the current queue depth. Call this from the pool's Submit.
func (*PoolMetrics) Snapshot ¶
func (pm *PoolMetrics) Snapshot() PoolSnapshot
Snapshot returns a point-in-time copy of the pool metrics.
func (*PoolMetrics) WorkerFinished ¶
func (pm *PoolMetrics) WorkerFinished(d time.Duration, result TaskResult)
WorkerFinished decrements the active worker count and records the task result and duration.
func (*PoolMetrics) WorkerStarted ¶
func (pm *PoolMetrics) WorkerStarted()
WorkerStarted increments the active worker count.
type PoolSnapshot ¶
type PoolSnapshot struct {
// CollectedAt is the time the snapshot was taken.
CollectedAt time.Time
// TotalWorkers is the total worker goroutines configured.
TotalWorkers int
// ActiveWorkers is the number of workers currently processing a task.
ActiveWorkers int
// IdleWorkers is the number of workers currently idle (TotalWorkers - ActiveWorkers).
IdleWorkers int
// QueueDepth is the number of tasks waiting in the queue.
QueueDepth int
// TasksCompleted is the total tasks completed successfully since pool start.
TasksCompleted int64
// TasksFailed is the total tasks that failed since pool start.
TasksFailed int64
// AvgTaskDuration is the rolling average task duration over the last N completed tasks.
// Zero if no tasks have completed.
AvgTaskDuration time.Duration
// P95TaskDuration is the approximate P95 task duration over the last N tasks.
// Zero if fewer than 20 tasks have completed.
P95TaskDuration time.Duration
}
PoolSnapshot captures agent pool state at a point in time.
type SystemCollector ¶
type SystemCollector struct{}
SystemCollector collects system-level metrics on demand.
func NewSystemCollector ¶
func NewSystemCollector() *SystemCollector
NewSystemCollector creates a SystemCollector.
func (*SystemCollector) Collect ¶
func (s *SystemCollector) Collect() SystemSnapshot
Collect returns a fresh snapshot of system metrics.
type SystemSnapshot ¶
type SystemSnapshot struct {
// CollectedAt is the time the snapshot was taken.
CollectedAt time.Time
// Goroutines is the goroutine count from runtime.NumGoroutine().
Goroutines int
// HeapAllocBytes is bytes of allocated heap objects.
HeapAllocBytes uint64
// SysBytesTotal is total OS memory obtained by the Go runtime.
SysBytesTotal uint64
// GCCycles is the number of GC cycles since program start.
GCCycles uint32
// GCPauseTotalNs is total time in GC stop-the-world pauses.
GCPauseTotalNs uint64
// NextGCBytes is the target heap size for the next GC cycle.
NextGCBytes uint64
}
SystemSnapshot captures OS-level metrics at a point in time.
type TaskResult ¶
type TaskResult string
TaskResult represents the outcome of a single completed task.
const ( // TaskResultSuccess indicates the task completed without error. TaskResultSuccess TaskResult = "success" // TaskResultFailure indicates the task completed with an error. TaskResultFailure TaskResult = "failure" )