Versions in this module Expand all Collapse all v0 v0.0.22 Dec 20, 2024 v0.0.21 Dec 19, 2024 Changes in this version + var DefaultThresholds = Thresholds + type Collector interface + Counter func(name string) Counter + Gauge func(name string) Gauge + Handler func() http.Handler + Histogram func(name string) Histogram + RecordGoroutineCount func() + RecordHTTPRequest func(method, path string, duration time.Duration, statusCode int) + RecordMemStats func() + type Config struct + CollectionInterval time.Duration + EnablePprof bool + MetricsPath string + type Counter interface + Add func(delta float64) + Inc func() + Value func() float64 + type Gauge interface + Add func(delta float64) + Set func(value float64) + Sub func(delta float64) + Value func() float64 + type Histogram interface + Count func() uint64 + Observe func(value float64) + Sum func() float64 + type Labels map[string]string + type MemoryStatus struct + Current float64 + Level ThresholdLevel + Reason string + Threshold float64 + TrendInfo string + type Module struct + func NewModule(collector Collector, config *Config) *Module + func (m *Module) ID() string + func (m *Module) Init() error + func (m *Module) Middleware() route.Middleware + func (m *Module) RegisterRoutes(router *route.Mux) + func (m *Module) Start(ctx context.Context) error + func (m *Module) Stop(ctx context.Context) error + type StandardCollector struct + func NewStandardCollector(opts ...StandardCollectorOption) *StandardCollector + func (c *StandardCollector) Counter(name string) Counter + func (c *StandardCollector) Gauge(name string) Gauge + func (c *StandardCollector) Handler() http.Handler + func (c *StandardCollector) Histogram(name string) Histogram + func (c *StandardCollector) RecordCPUStats() + func (c *StandardCollector) RecordDiskStats() + func (c *StandardCollector) RecordGoroutineCount() + func (c *StandardCollector) RecordHTTPRequest(method, path string, duration time.Duration, statusCode int) + func (c *StandardCollector) RecordMemStats() + type StandardCollectorOption func(*StandardCollector) + func WithServerName(name string) StandardCollectorOption + func WithThresholds(thresholds Thresholds) StandardCollectorOption + type ThresholdLevel int + const ThresholdCritical + const ThresholdInfo + const ThresholdOK + const ThresholdWarning + type Thresholds struct + CPUPercent float64 + ClientErrorRatePercent float64 + DiskPercent float64 + GCPauseMs float64 + GoroutineCount int + MaxGCFrequency float64 + MemoryGrowthRatePercent float64 + MemoryPercent float64 + ServerErrorRatePercent float64