prommetrics

package
v0.0.0-...-8c930d8 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package prommetrics provides Prometheus metrics for the application; the name avoids conflicting with standard library or common "metrics" package names.

Index

Constants

View Source
const (
	NAMESPACE = "gst"
	SUBSYSTEM = "backend"
)

NAMESPACE and SUBSYSTEM prefix every metric of the framework; Prometheus joins them and the name with underscores, so a metric of the backend is named gst_backend_<name> and one of the process gst_process_<name>.

Variables

View Source
var (
	State                   prometheus.Gauge
	Uptime                  prometheus.Gauge
	HTTPRequestsTotal       *prometheus.CounterVec
	HTTPRequestDuration     *prometheus.HistogramVec
	ResponseTime            prometheus.Histogram
	ErrorRate               prometheus.Counter
	MemoryTotal             prometheus.Gauge
	MemoryUsed              prometheus.Gauge
	MemoryUsedPercent       prometheus.Gauge
	CPUCount                prometheus.Gauge
	CPUUsedPercent          prometheus.Gauge
	ConcurrentConnections   prometheus.Gauge
	CacheHit                *prometheus.CounterVec
	CacheMiss               *prometheus.CounterVec
	QueueSize               prometheus.Gauge
	AuthzPolicyDiverged     prometheus.Gauge
	AuthzDecisionsTotal     *prometheus.CounterVec
	AuditWriteFailuresTotal prometheus.Counter
)

Functions

func Init

func Init() error

func RegisterDBStats

func RegisterDBStats(db *sql.DB, dbName string) error

RegisterDBStats exposes one database handle's connection pool to the default Prometheus registry under dbName (the collector's db_name label). The standard collector reads sql.DB.Stats at scrape time, so registration adds no background work.

Registering a name again replaces that name's previous collector, which keeps re-initialization idempotent: a test harness that reopens the database re-registers instead of failing, and the collector never outlives the handle it reads. It does not require Init to have run — collectors on the default registry simply stay unserved until a metrics endpoint is up.

Types

This section is empty.

Jump to

Keyboard shortcuts

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