metrics

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler() http.Handler

Handler returns the Prometheus HTTP handler for /metrics endpoint

Types

type Collector

type Collector struct {
	// HTTP Metrics
	HTTPRequestsTotal   *prometheus.CounterVec
	HTTPRequestDuration *prometheus.HistogramVec
	HTTPRequestSize     *prometheus.HistogramVec
	HTTPResponseSize    *prometheus.HistogramVec

	// Business Metrics
	TransactionsTotal     *prometheus.CounterVec
	TransactionAmount     *prometheus.HistogramVec
	WalletOperationsTotal *prometheus.CounterVec
	LedgerEntriesTotal    *prometheus.CounterVec
	RiskEventsTotal       *prometheus.CounterVec

	// System Metrics
	DBConnectionsActive prometheus.Gauge
	DBQueryDuration     *prometheus.HistogramVec
	CacheHitsTotal      *prometheus.CounterVec
	CacheMissesTotal    *prometheus.CounterVec
}

Collector holds all Prometheus metrics for a service

func NewCollector

func NewCollector(serviceName string) *Collector

NewCollector creates a new metrics collector for a service

func (*Collector) Middleware

func (c *Collector) Middleware(serviceName string) func(http.Handler) http.Handler

Middleware returns an HTTP middleware that instruments requests

func (*Collector) RecordCacheHit

func (c *Collector) RecordCacheHit(serviceName, cacheName string)

RecordCacheHit records a cache hit

func (*Collector) RecordCacheMiss

func (c *Collector) RecordCacheMiss(serviceName, cacheName string)

RecordCacheMiss records a cache miss

func (*Collector) RecordDBQuery

func (c *Collector) RecordDBQuery(serviceName, queryType string, duration time.Duration)

RecordDBQuery records a database query duration

func (*Collector) RecordLedgerEntry

func (c *Collector) RecordLedgerEntry(serviceName, entryType, status string)

RecordLedgerEntry records a ledger entry metric

func (*Collector) RecordRiskEvent

func (c *Collector) RecordRiskEvent(serviceName, rule, action string)

RecordRiskEvent records a risk event metric

func (*Collector) RecordTransaction

func (c *Collector) RecordTransaction(serviceName, txType, status string, amountPaise int64)

RecordTransaction records a transaction metric

func (*Collector) RecordWalletOperation

func (c *Collector) RecordWalletOperation(serviceName, operation, status string)

RecordWalletOperation records a wallet operation metric

func (*Collector) UpdateDBConnections

func (c *Collector) UpdateDBConnections(count int)

UpdateDBConnections updates the active database connections gauge

Jump to

Keyboard shortcuts

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