metrics

package
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package metrics provides Prometheus metrics instrumentation for confd. Metrics are optional and only initialized when --metrics-addr is specified.

Index

Constants

This section is empty.

Variables

View Source
var (
	BackendRequestDuration *prometheus.HistogramVec
	BackendRequestTotal    *prometheus.CounterVec
	BackendErrorsTotal     *prometheus.CounterVec
	BackendHealthy         *prometheus.GaugeVec
)

Backend metrics

View Source
var (
	TemplateProcessDuration *prometheus.HistogramVec
	TemplateProcessTotal    *prometheus.CounterVec
	TemplateCacheHits       prometheus.Counter
	TemplateCacheMisses     prometheus.Counter
	TemplateStatCacheHits   prometheus.Counter
	TemplatesLoaded         prometheus.Gauge
	WatchedKeys             prometheus.Gauge
)

Template metrics

View Source
var (
	BatchProcessTotal              prometheus.Counter
	BatchProcessFailed             prometheus.Counter
	BatchProcessTemplatesSucceeded prometheus.Counter
	BatchProcessTemplatesFailed    prometheus.Counter
)

Batch processing metrics

View Source
var (
	CommandDuration  *prometheus.HistogramVec
	CommandTotal     *prometheus.CounterVec
	CommandExitCodes *prometheus.CounterVec
)

Command metrics

View Source
var (
	FileSyncTotal    *prometheus.CounterVec
	FileChangedTotal prometheus.Counter
)

File sync metrics

Registry holds all confd metrics. It is nil when metrics are disabled.

Functions

func Enabled

func Enabled() bool

Enabled returns true if metrics are enabled.

func HealthHandler

func HealthHandler(_ backends.StoreClient) http.HandlerFunc

HealthHandler returns HTTP 200 if the process is alive. This is a liveness probe - it always returns OK if the process is running.

func Initialize

func Initialize()

Initialize creates and registers all metrics with a new registry. Call this only when metrics are enabled (--metrics-addr is set).

func ReadyDetailedHandler

func ReadyDetailedHandler(client backends.StoreClient) http.HandlerFunc

ReadyDetailedHandler returns detailed health check information as JSON. Returns HTTP 200 with detailed health info if backend is healthy, 503 otherwise.

func ReadyHandler

func ReadyHandler(client backends.StoreClient) http.HandlerFunc

ReadyHandler returns HTTP 200 if the backend is reachable, 503 otherwise. This is a readiness probe - it checks backend connectivity.

func WrapStoreClient

func WrapStoreClient(client backends.StoreClient, backendType string) backends.StoreClient

WrapStoreClient wraps a StoreClient with metrics instrumentation. If metrics are not enabled (Registry is nil), returns the original client.

Types

type InstrumentedClient

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

InstrumentedClient wraps a StoreClient with metrics instrumentation.

func (*InstrumentedClient) Close

func (c *InstrumentedClient) Close() error

Close closes the wrapped backend client.

func (*InstrumentedClient) GetValues

func (c *InstrumentedClient) GetValues(ctx context.Context, keys []string) (map[string]string, error)

GetValues retrieves values from the backend and records metrics.

func (*InstrumentedClient) HealthCheck

func (c *InstrumentedClient) HealthCheck(ctx context.Context) error

HealthCheck verifies backend health and records metrics.

func (*InstrumentedClient) HealthCheckDetailed

func (c *InstrumentedClient) HealthCheckDetailed(ctx context.Context) (*types.HealthResult, error)

HealthCheckDetailed provides detailed health information if the backend supports it.

func (*InstrumentedClient) WatchPrefix

func (c *InstrumentedClient) WatchPrefix(ctx context.Context, prefix string, keys []string, waitIndex uint64, stopChan chan bool) (uint64, error)

WatchPrefix watches for changes on a prefix and records metrics.

Jump to

Keyboard shortcuts

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