metrics

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Metric type constants
	MetricTypeGauge = "gauge"
)

Variables

This section is empty.

Functions

func HTTPMetrics

func HTTPMetrics(mc *Collector) func(http.Handler) http.Handler

HTTPMetrics middleware for tracking HTTP requests

Types

type Collector

type Collector struct {
	// contains filtered or unexported fields
}

Collector handles Prometheus-style metrics

func NewCollector

func NewCollector() *Collector

NewCollector creates a new metrics collector

func (*Collector) Export

func (mc *Collector) Export() string

Export formats metrics in Prometheus text format

func (*Collector) Handler

func (mc *Collector) Handler() http.HandlerFunc

Handler returns an HTTP handler for the metrics endpoint

func (*Collector) IncrementCounter

func (mc *Collector) IncrementCounter(name string, value float64)

IncrementCounter increments a counter metric

func (*Collector) InitDefaultMetrics

func (mc *Collector) InitDefaultMetrics()

DefaultMetrics initializes common metrics

func (*Collector) ObserveHistogram

func (mc *Collector) ObserveHistogram(name string, value float64)

ObserveHistogram records a value in a histogram

func (*Collector) RecordContainerEvent

func (mc *Collector) RecordContainerEvent()

RecordContainerEvent records a container event received

func (*Collector) RecordContainerMonitorFallback

func (mc *Collector) RecordContainerMonitorFallback()

RecordContainerMonitorFallback records a fallback to polling

func (*Collector) RecordContainerMonitorMethod

func (mc *Collector) RecordContainerMonitorMethod(usingEvents bool)

RecordContainerMonitorMethod records the monitoring method being used

func (*Collector) RecordContainerWaitDuration

func (mc *Collector) RecordContainerWaitDuration(seconds float64)

RecordContainerWaitDuration records the time spent waiting for a container

func (*Collector) RecordDockerError

func (mc *Collector) RecordDockerError(operation string)

RecordDockerError records a Docker API error

func (*Collector) RecordDockerOperation

func (mc *Collector) RecordDockerOperation(operation string)

RecordDockerOperation records a Docker API operation

func (*Collector) RecordJobRetry

func (mc *Collector) RecordJobRetry(jobName string, attempt int, success bool)

RecordJobRetry records a job retry attempt

func (*Collector) RegisterCounter

func (mc *Collector) RegisterCounter(name, help string)

RegisterCounter registers a new counter metric

func (*Collector) RegisterGauge

func (mc *Collector) RegisterGauge(name, help string)

RegisterGauge registers a new gauge metric

func (*Collector) RegisterHistogram

func (mc *Collector) RegisterHistogram(name, help string, buckets []float64)

RegisterHistogram registers a new histogram metric

func (*Collector) SetGauge

func (mc *Collector) SetGauge(name string, value float64)

SetGauge sets a gauge metric value

type Histogram

type Histogram struct {
	Count  int64
	Sum    float64
	Bucket map[float64]int64 // bucket threshold -> count
}

Histogram for tracking distributions

type JobMetrics

type JobMetrics struct {
	// contains filtered or unexported fields
}

JobMetrics tracks job execution metrics

func NewJobMetrics

func NewJobMetrics(collector *Collector) *JobMetrics

NewJobMetrics creates a job metrics tracker

func (*JobMetrics) JobCompleted

func (jm *JobMetrics) JobCompleted(jobID string, success bool)

JobCompleted records job completion

func (*JobMetrics) JobStarted

func (jm *JobMetrics) JobStarted(jobID string)

JobStarted records job start

type Metric

type Metric struct {
	Name        string
	Type        string // counter, gauge, histogram
	Help        string
	Value       float64
	Labels      map[string]string
	Histogram   *Histogram
	LastUpdated time.Time
}

Metric represents a single metric with its type and values

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL