Documentation
¶
Overview ¶
Package metrics provides centralized metrics collection for the dashboard. It aggregates data from various components like WriteBatcher, WorkerPool, CachePreload, and Go runtime statistics.
Index ¶
- func FormatBytes(b uint64) string
- func FormatBytesInt64(b int64) string
- func FormatDuration(d time.Duration) string
- type CacheBatchLoadMetrics
- type CacheBatchLoadSource
- type CachePreloadMetrics
- type CachePreloadSnapshot
- type CachePreloadSource
- type Collector
- func (c *Collector) Collect(ctx context.Context) Snapshot
- func (c *Collector) GetModuleStatuses() []ModuleStatus
- func (c *Collector) RecordModuleActivity(name string, isActive bool)
- func (c *Collector) SetCacheBatchLoad(src CacheBatchLoadSource)
- func (c *Collector) SetCachePreload(src CachePreloadSource)
- func (c *Collector) SetFileProcessor(src FileProcessorSource)
- func (c *Collector) SetHTTPCache(src HTTPCacheSource)
- func (c *Collector) SetQueueInfo(length func() int, capacity int)
- func (c *Collector) SetWorkerPool(src WorkerPoolSource)
- func (c *Collector) SetWriteBatcher(src WriteBatcherSource)
- type FileProcessingMetrics
- type FileProcessorSource
- type HTTPCacheConfig
- type HTTPCacheMetrics
- type HTTPCacheSource
- type ModuleStatus
- type RuntimeMetrics
- type Snapshot
- type WorkerPoolMetrics
- type WorkerPoolSource
- type WorkerPoolStats
- type WriteBatcherMetrics
- type WriteBatcherSource
- type WriteBatcherStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatBytes ¶
FormatBytes returns a human-readable byte string using IEC units (e.g., "1.5 KiB").
func FormatBytesInt64 ¶
FormatBytesInt64 is like FormatBytes but takes an int64.
func FormatDuration ¶
FormatDuration returns a human-readable duration string.
Types ¶
type CacheBatchLoadMetrics ¶ added in v0.3.0
type CacheBatchLoadMetrics struct {
TargetsTotal int64 `json:"targets_total"`
TargetsScheduled int64 `json:"targets_scheduled"`
TargetsCompleted int64 `json:"targets_completed"`
TargetsFailed int64 `json:"targets_failed"`
TargetsSkipped int64 `json:"targets_skipped"`
InFlight int64 `json:"in_flight"`
IsRunning bool `json:"is_running"`
LastStartedAt time.Time `json:"last_started_at"`
LastFinishedAt time.Time `json:"last_finished_at"`
}
CacheBatchLoadMetrics holds statistics from the cache batch load manager.
type CacheBatchLoadSource ¶ added in v0.3.0
type CacheBatchLoadSource interface {
GetMetrics() CacheBatchLoadMetrics
}
CacheBatchLoadSource provides metrics from the cache batch load manager.
type CachePreloadMetrics ¶
type CachePreloadMetrics struct {
TasksScheduled int64 `json:"tasks_scheduled"`
TasksCompleted int64 `json:"tasks_completed"`
TasksFailed int64 `json:"tasks_failed"`
TasksCancelled int64 `json:"tasks_cancelled"`
TasksSkipped int64 `json:"tasks_skipped"`
TotalDuration time.Duration `json:"total_duration"`
IsEnabled bool `json:"is_enabled"`
}
CachePreloadMetrics holds statistics from the cache preload manager.
type CachePreloadSnapshot ¶
type CachePreloadSnapshot struct {
TasksScheduled int64
TasksCompleted int64
TasksFailed int64
TasksCancelled int64
TasksSkipped int64
TotalDuration time.Duration
}
CachePreloadSnapshot holds a snapshot of cache preload metrics.
type CachePreloadSource ¶
type CachePreloadSource interface {
GetMetrics() CachePreloadSnapshot
IsEnabled() bool
}
CachePreloadSource provides metrics from the cache preload manager.
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector aggregates metrics from various sources.
func (*Collector) GetModuleStatuses ¶
func (c *Collector) GetModuleStatuses() []ModuleStatus
GetModuleStatuses returns the current status of all tracked modules.
func (*Collector) RecordModuleActivity ¶
RecordModuleActivity records activity for a module.
func (*Collector) SetCacheBatchLoad ¶ added in v0.3.0
func (c *Collector) SetCacheBatchLoad(src CacheBatchLoadSource)
SetCacheBatchLoad sets the CacheBatchLoad source.
func (*Collector) SetCachePreload ¶
func (c *Collector) SetCachePreload(src CachePreloadSource)
SetCachePreload sets the CachePreload source.
func (*Collector) SetFileProcessor ¶
func (c *Collector) SetFileProcessor(src FileProcessorSource)
SetFileProcessor sets the FileProcessor source.
func (*Collector) SetHTTPCache ¶
func (c *Collector) SetHTTPCache(src HTTPCacheSource)
SetHTTPCache sets the HTTP cache source.
func (*Collector) SetQueueInfo ¶
SetQueueInfo sets the queue information functions.
func (*Collector) SetWorkerPool ¶
func (c *Collector) SetWorkerPool(src WorkerPoolSource)
SetWorkerPool sets the WorkerPool source.
func (*Collector) SetWriteBatcher ¶
func (c *Collector) SetWriteBatcher(src WriteBatcherSource)
SetWriteBatcher sets the WriteBatcher source.
type FileProcessingMetrics ¶
type FileProcessingMetrics struct {
TotalFound uint64 `json:"total_found"`
AlreadyExisting uint64 `json:"already_existing"`
NewlyInserted uint64 `json:"newly_inserted"`
SkippedInvalid uint64 `json:"skipped_invalid"`
InFlight int64 `json:"in_flight"`
}
FileProcessingMetrics holds statistics from the file processor.
type FileProcessorSource ¶
type FileProcessorSource interface {
GetStats() FileProcessingMetrics
}
FileProcessorSource provides metrics from the file processor.
type HTTPCacheConfig ¶
HTTPCacheConfig holds HTTP cache configuration for metrics.
type HTTPCacheMetrics ¶
type HTTPCacheMetrics struct {
Enabled bool `json:"enabled"`
SizeBytes int64 `json:"size_bytes"`
MaxEntrySize int64 `json:"max_entry_size"`
MaxTotalSize int64 `json:"max_total_size"`
EntryCount int64 `json:"entry_count"`
}
HTTPCacheMetrics holds HTTP cache statistics.
type HTTPCacheSource ¶
type HTTPCacheSource interface {
IsEnabled() bool
GetSizeBytes() int64
GetEntryCount() int64
GetConfig() HTTPCacheConfig
}
HTTPCacheSource provides metrics from the HTTP cache.
type ModuleStatus ¶
type ModuleStatus struct {
Name string `json:"name"`
Status string `json:"status"` // "active", "idle", "recent"
LastActiveAt time.Time `json:"last_active_at"`
ActivityCount int64 `json:"activity_count"`
}
ModuleStatus represents the status of a module.
type RuntimeMetrics ¶
type RuntimeMetrics struct {
NumGoroutine int `json:"num_goroutine"`
NumCPU int `json:"num_cpu"`
NumCgoCall int64 `json:"num_cgo_call"`
MemAlloc uint64 `json:"mem_alloc"`
MemTotalAlloc uint64 `json:"mem_total_alloc"`
MemSys uint64 `json:"mem_sys"`
MemHeapAlloc uint64 `json:"mem_heap_alloc"`
MemHeapSys uint64 `json:"mem_heap_sys"`
MemHeapInuse uint64 `json:"mem_heap_inuse"`
MemHeapReleased uint64 `json:"mem_heap_released"`
MemHeapObjects uint64 `json:"mem_heap_objects"`
GCSys uint64 `json:"gc_sys"`
LastGC time.Time `json:"last_gc"`
NextGC uint64 `json:"next_gc"`
GCCPUFraction float64 `json:"gc_cpu_fraction"`
Uptime time.Duration `json:"uptime"`
}
RuntimeMetrics holds Go runtime statistics.
type Snapshot ¶
type Snapshot struct {
Timestamp time.Time `json:"timestamp"`
Runtime RuntimeMetrics `json:"runtime"`
WriteBatcher WriteBatcherMetrics `json:"writebatcher"`
WorkerPool WorkerPoolMetrics `json:"worker_pool"`
CachePreload CachePreloadMetrics `json:"cache_preload"`
CacheBatchLoad CacheBatchLoadMetrics `json:"cache_batch_load"`
FileProcessing FileProcessingMetrics `json:"file_processing"`
HTTPCache HTTPCacheMetrics `json:"http_cache"`
Modules []ModuleStatus `json:"modules"`
QueueLength int `json:"queue_length"`
QueueCapacity int `json:"queue_capacity"`
}
Snapshot holds a complete snapshot of all metrics.
type WorkerPoolMetrics ¶
type WorkerPoolMetrics struct {
RunningWorkers int64 `json:"running_workers"`
SubmittedTasks uint64 `json:"submitted_tasks"`
WaitingTasks uint64 `json:"waiting_tasks"`
SuccessfulTasks uint64 `json:"successful_tasks"`
FailedTasks uint64 `json:"failed_tasks"`
CompletedTasks uint64 `json:"completed_tasks"`
DroppedTasks uint64 `json:"dropped_tasks"`
MaxWorkers int `json:"max_workers"`
MinWorkers int `json:"min_workers"`
}
WorkerPoolMetrics holds statistics from the worker pool.
type WorkerPoolSource ¶
type WorkerPoolSource interface {
GetStats() WorkerPoolStats
}
WorkerPoolSource provides metrics from a worker pool.
type WorkerPoolStats ¶
type WorkerPoolStats struct {
RunningWorkers int64
SubmittedTasks uint64
WaitingTasks uint64
SuccessfulTasks uint64
FailedTasks uint64
CompletedTasks uint64
DroppedTasks uint64
MaxWorkers int
MinWorkers int
}
WorkerPoolStats holds internal stats from WorkerPool.
type WriteBatcherMetrics ¶
type WriteBatcherMetrics struct {
PendingCount int64 `json:"pending_count"`
ChannelSize int `json:"channel_size"`
MaxBatchSize int `json:"max_batch_size"`
FlushInterval string `json:"flush_interval"`
IsClosed bool `json:"is_closed"`
LastFlushTime time.Time `json:"last_flush_time"`
TotalFlushed int64 `json:"total_flushed"`
TotalErrors int64 `json:"total_errors"`
DQueEnabled bool `json:"dque_enabled"`
DQueSize int `json:"dque_size"`
OverflowCount int64 `json:"overflow_count"`
}
WriteBatcherMetrics holds statistics from the WriteBatcher.
type WriteBatcherSource ¶
type WriteBatcherSource interface {
PendingCount() int64
GetStats() WriteBatcherStats
}
WriteBatcherSource provides metrics from a WriteBatcher.