Documentation
¶
Overview ¶
Package metrics provides Prometheus metrics for the tunnel library.
This package implements optional Prometheus metrics export for monitoring tunnel performance and health.
Example ¶
metrics := metrics.NewCollector("go_tunnel")
metrics.Register()
// In your tunnel handler
metrics.IncConnections()
metrics.AddBytesSent(1024)
Index ¶
- type Collector
- func (c *Collector) AddBackpressureYieldTime(seconds float64)
- func (c *Collector) AddBytesReceived(n float64)
- func (c *Collector) AddBytesSent(n float64)
- func (c *Collector) DecActive()
- func (c *Collector) IncActive()
- func (c *Collector) IncBackpressurePauses()
- func (c *Collector) IncConnections()
- func (c *Collector) IncConnectionsBy(n float64)
- func (c *Collector) IncErrors()
- func (c *Collector) IncErrorsBy(n float64)
- func (c *Collector) IncPoolClosed()
- func (c *Collector) IncPoolCreated()
- func (c *Collector) IncPoolReused()
- func (c *Collector) ObserveConnectionDuration(seconds float64)
- func (c *Collector) ObserveForwardLatency(seconds float64)
- func (c *Collector) ObservePoolWait(seconds float64)
- func (c *Collector) SetActive(n float64)
- func (c *Collector) SetPoolActive(n float64)
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector holds Prometheus metrics for a tunnel.
func DefaultCollector ¶
DefaultCollector returns a collector with default configuration.
func NewCollector ¶
NewCollector creates a new metrics collector.
func (*Collector) AddBackpressureYieldTime ¶
AddBackpressureYieldTime adds to the backpressure yield time counter.
func (*Collector) AddBytesReceived ¶
AddBytesReceived adds n bytes to the bytes received counter.
func (*Collector) AddBytesSent ¶
AddBytesSent adds n bytes to the bytes sent counter.
func (*Collector) DecActive ¶
func (c *Collector) DecActive()
DecActive decrements the active connections gauge.
func (*Collector) IncActive ¶
func (c *Collector) IncActive()
IncActive increments the active connections gauge.
func (*Collector) IncBackpressurePauses ¶
func (c *Collector) IncBackpressurePauses()
IncBackpressurePauses increments the backpressure pauses counter.
func (*Collector) IncConnections ¶
func (c *Collector) IncConnections()
IncConnections increments the total connections counter.
func (*Collector) IncConnectionsBy ¶
IncConnectionsBy increments the total connections counter by n.
func (*Collector) IncErrors ¶
func (c *Collector) IncErrors()
IncErrors increments the errors counter.
func (*Collector) IncErrorsBy ¶
IncErrorsBy increments the errors counter by n.
func (*Collector) IncPoolClosed ¶
func (c *Collector) IncPoolClosed()
IncPoolClosed increments the pool connections closed counter.
func (*Collector) IncPoolCreated ¶
func (c *Collector) IncPoolCreated()
IncPoolCreated increments the pool connections created counter.
func (*Collector) IncPoolReused ¶
func (c *Collector) IncPoolReused()
IncPoolReused increments the pool connections reused counter.
func (*Collector) ObserveConnectionDuration ¶
ObserveConnectionDuration observes a connection duration.
func (*Collector) ObserveForwardLatency ¶
ObserveForwardLatency observes a forward latency.
func (*Collector) ObservePoolWait ¶
ObservePoolWait observes a pool wait duration.
func (*Collector) SetPoolActive ¶
SetPoolActive sets the active pool connections.
type Config ¶
type Config struct {
// Namespace is the prefix for all metrics.
Namespace string
// Subsystem is an optional subsystem prefix.
Subsystem string
// Registry is the Prometheus registerer to use.
// If nil, the default registerer is used.
Registry prometheus.Registerer
// EnableConnectionDuration enables connection duration histogram.
EnableConnectionDuration bool
// EnableForwardLatency enables forward latency histogram.
EnableForwardLatency bool
// EnablePoolMetrics enables connection pool metrics.
EnablePoolMetrics bool
// EnableBackpressureMetrics enables backpressure metrics.
EnableBackpressureMetrics bool
}
Config holds configuration for the metrics collector.