metrics

package
v1.0.32 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: GPL-2.0, GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package metrics is a thin wrapper around github.com/cplieger/metrics/v2 holding the registry-stats-specific metric instances and the SetImageMetrics adapter (which converts a per-cycle slice of ImageMetric records into the equivalent labeled-gauge state). The registry prefix ("registrystats") is applied to every metric name by the library.

Index

Constants

This section is empty.

Variables

View Source
var (
	HTTPRequests = cm.NewLabeledCounter(
		"http_requests_total",
		"Total HTTP requests",
		[]string{"method", "path", "status"},
	)
	CollectsTotal = cm.NewLabeledCounter(
		"collects_total",
		"Total collection runs by source",
		[]string{"source"},
	)
	CollectErrors = cm.NewLabeledCounter(
		"collect_errors_total",
		"Total collection errors by source",
		[]string{"source"},
	)
	HTTPDuration = cm.NewHistogram(
		"http_request_duration_seconds",
		"HTTP request latency",
	)
	// CollectDuration uses APIBuckets (coarse, to 30s): a full Docker Hub +
	// GHCR collect cycle routinely exceeds 1s, which DefaultBuckets (max 1.0s)
	// would dump entirely into +Inf.
	CollectDuration = cm.NewHistogram(
		"collect_duration_seconds",
		"Collection cycle duration",
		cm.WithBuckets(cm.APIBuckets),
	)
)

Exported metric instances (names auto-prefixed with "registrystats_").

Functions

func Handler

func Handler() http.HandlerFunc

Handler returns an HTTP handler serving Prometheus text format.

func RecordHTTP added in v1.0.17

func RecordHTTP(method, path string, status int, d time.Duration)

RecordHTTP records one HTTP request into the package HTTP metrics via the library helper (caller-owned {method,path,status} label set).

func SetImageMetrics

func SetImageMetrics(images []ImageMetric)

SetImageMetrics replaces the current image gauge data atomically. Reset+Set rather than incremental update so images that disappear from the snapshot stop emitting.

Types

type ImageMetric

type ImageMetric struct {
	Registry string // "dockerhub" or "ghcr"
	Owner    string
	Repo     string
	Pulls    int64
	Tags     int
}

ImageMetric holds per-image gauge data set after each collect cycle. Image metrics are registry-stats-local (the library deliberately does not expose an image-metrics feature); this is layered on labeled gauges.

Jump to

Keyboard shortcuts

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