Documentation
¶
Overview ¶
Package metrics provides comprehensive metrics collection for Hockeypuck
Index ¶
- type Counter
- type Gauge
- type HTTPMetrics
- type HealthMetrics
- type Metrics
- func (m *Metrics) Collect() (map[string]interface{}, error)
- func (m *Metrics) DeleteCustomMetric(name string)
- func (m *Metrics) GetCustomMetric(name string) (interface{}, bool)
- func (m *Metrics) JSONHandler() http.HandlerFunc
- func (m *Metrics) PrometheusHandler() http.Handler
- func (m *Metrics) RegisterCollector(collector MetricsCollector) error
- func (m *Metrics) Registry() *prometheus.Registry
- func (m *Metrics) SetCustomMetric(name string, value interface{})
- func (m *Metrics) UnregisterCollector(name string) error
- type MetricsCollector
- type MetricsUpdater
- type PluginMetrics
- type RateLimitMetrics
- type ServerMetrics
- type StorageMetrics
- type Timer
- type UpdaterFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter provides a simple counter interface
type Gauge ¶
type Gauge struct {
// contains filtered or unexported fields
}
Gauge provides a simple gauge interface
type HTTPMetrics ¶
type HTTPMetrics struct {
RequestsInFlight prometheus.Gauge
RequestsTotal *prometheus.CounterVec
RequestDuration *prometheus.HistogramVec
RequestSize *prometheus.HistogramVec
ResponseSize *prometheus.HistogramVec
ResponseTime *prometheus.HistogramVec
// Status code metrics
StatusCodes *prometheus.CounterVec
// Endpoint metrics
EndpointCalls *prometheus.CounterVec
EndpointDuration *prometheus.HistogramVec
EndpointErrors *prometheus.CounterVec
// User agent metrics
UserAgents *prometheus.CounterVec
// Geographic metrics
RequestsByCountry *prometheus.CounterVec
}
HTTPMetrics contains HTTP-related metrics
func NewHTTPMetrics ¶
func NewHTTPMetrics(registry *prometheus.Registry) *HTTPMetrics
NewHTTPMetrics creates new HTTP metrics
type HealthMetrics ¶
type HealthMetrics struct {
HealthChecks *prometheus.GaugeVec
HealthCheckDuration *prometheus.HistogramVec
ComponentStatus *prometheus.GaugeVec
LastHealthCheck prometheus.Gauge
}
HealthMetrics contains health check metrics
func NewHealthMetrics ¶
func NewHealthMetrics() *HealthMetrics
NewHealthMetrics creates new health metrics
type Metrics ¶
type Metrics struct {
// Core server metrics
ServerMetrics *ServerMetrics
// Storage metrics
StorageMetrics *StorageMetrics
// Rate limiting metrics
RateLimitMetrics *RateLimitMetrics
// Plugin metrics
PluginMetrics *PluginMetrics
// HTTP metrics
HTTPMetrics *HTTPMetrics
// Custom metrics
CustomMetrics map[string]interface{}
// contains filtered or unexported fields
}
Metrics represents the main metrics system
func (*Metrics) DeleteCustomMetric ¶
DeleteCustomMetric deletes a custom metric
func (*Metrics) GetCustomMetric ¶
GetCustomMetric gets a custom metric value
func (*Metrics) JSONHandler ¶
func (m *Metrics) JSONHandler() http.HandlerFunc
JSONHandler returns a JSON metrics HTTP handler
func (*Metrics) PrometheusHandler ¶
PrometheusHandler returns a Prometheus metrics HTTP handler
func (*Metrics) RegisterCollector ¶
func (m *Metrics) RegisterCollector(collector MetricsCollector) error
RegisterCollector registers a custom metrics collector
func (*Metrics) Registry ¶
func (m *Metrics) Registry() *prometheus.Registry
Registry provides access to the Prometheus registry
func (*Metrics) SetCustomMetric ¶
SetCustomMetric sets a custom metric value
func (*Metrics) UnregisterCollector ¶
UnregisterCollector unregisters a metrics collector
type MetricsCollector ¶
type MetricsCollector interface {
Collect() (map[string]interface{}, error)
Name() string
Description() string
}
MetricsCollector interface for custom metrics collectors
type MetricsUpdater ¶
type MetricsUpdater struct {
// contains filtered or unexported fields
}
MetricsUpdater manages periodic metrics updates
func NewMetricsUpdater ¶
func NewMetricsUpdater(interval time.Duration) *MetricsUpdater
NewMetricsUpdater creates a new metrics updater
func (*MetricsUpdater) AddUpdater ¶
func (mu *MetricsUpdater) AddUpdater(updater UpdaterFunc)
AddUpdater adds a metrics updater function
type PluginMetrics ¶
type PluginMetrics struct {
PluginsLoaded prometheus.Gauge
PluginLoadTime *prometheus.HistogramVec
PluginErrors *prometheus.CounterVec
PluginInitTime *prometheus.HistogramVec
PluginMemoryUsage *prometheus.GaugeVec
PluginCPUUsage *prometheus.GaugeVec
// Plugin lifecycle
PluginLifecycle *prometheus.CounterVec
PluginDependencies *prometheus.GaugeVec
// Plugin performance
PluginExecution *prometheus.HistogramVec
PluginCalls *prometheus.CounterVec
}
PluginMetrics contains plugin-related metrics
func NewPluginMetrics ¶
func NewPluginMetrics(registry *prometheus.Registry) *PluginMetrics
NewPluginMetrics creates new plugin metrics
type RateLimitMetrics ¶
type RateLimitMetrics struct {
ViolationsTotal *prometheus.CounterVec
BannedIPs *prometheus.GaugeVec
TrackedIPs prometheus.Gauge
TorExitCount prometheus.Gauge
BackendDuration *prometheus.HistogramVec
BackendErrors *prometheus.CounterVec
// Connection metrics
ConnectionsRejected *prometheus.CounterVec
ConnectionsActive *prometheus.GaugeVec
// Request metrics
RequestsRejected *prometheus.CounterVec
RequestRate *prometheus.GaugeVec
// Error tracking
ErrorRate *prometheus.GaugeVec
ErrorsTotal *prometheus.CounterVec
}
RateLimitMetrics contains rate limiting metrics
func NewRateLimitMetrics ¶
func NewRateLimitMetrics(registry *prometheus.Registry) *RateLimitMetrics
NewRateLimitMetrics creates new rate limiting metrics
type ServerMetrics ¶
type ServerMetrics struct {
StartTime prometheus.Gauge
Uptime prometheus.Gauge
Version *prometheus.GaugeVec
BuildInfo *prometheus.GaugeVec
GoVersion prometheus.Gauge
GoRoutines prometheus.Gauge
MemoryUsage prometheus.Gauge
CPUUsage prometheus.Gauge
FileDescriptors prometheus.Gauge
// Request metrics
RequestsTotal *prometheus.CounterVec
RequestDuration *prometheus.HistogramVec
RequestSize *prometheus.HistogramVec
ResponseSize *prometheus.HistogramVec
// Connection metrics
ActiveConnections prometheus.Gauge
TotalConnections prometheus.Counter
}
ServerMetrics contains core server metrics
func NewServerMetrics ¶
func NewServerMetrics(registry *prometheus.Registry) *ServerMetrics
NewServerMetrics creates new server metrics
type StorageMetrics ¶
type StorageMetrics struct {
KeysTotal prometheus.Gauge
KeysInserted prometheus.Counter
KeysUpdated prometheus.Counter
KeysDeleted prometheus.Counter
KeysIgnored prometheus.Counter
KeysDuplicated prometheus.Counter
// Storage operations
OperationsTotal *prometheus.CounterVec
OperationDuration *prometheus.HistogramVec
OperationErrors *prometheus.CounterVec
// Database metrics
DatabaseConnections prometheus.Gauge
DatabaseConnectionsIdle prometheus.Gauge
DatabaseQueries *prometheus.CounterVec
DatabaseQueryDuration *prometheus.HistogramVec
DatabaseSize prometheus.Gauge
// Index metrics
IndexSize *prometheus.GaugeVec
IndexUsage *prometheus.CounterVec
IndexMaintenance *prometheus.CounterVec
}
StorageMetrics contains storage-related metrics
func NewStorageMetrics ¶
func NewStorageMetrics(registry *prometheus.Registry) *StorageMetrics
NewStorageMetrics creates new storage metrics
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
Timer provides timing functionality for metrics
func (*Timer) ObserveDuration ¶
func (t *Timer) ObserveDuration()
ObserveDuration observes the elapsed time since timer creation
type UpdaterFunc ¶
UpdaterFunc represents a function that updates metrics