Documentation
¶
Index ¶
- func MeasureDBQuery(m *Metrics, operation, backend string) func()
- func RecordDBQuery(m *Metrics, operation, backend string, duration time.Duration)
- type Metrics
- func (m *Metrics) ObserveArchival(recordsDeleted int64)
- func (m *Metrics) ObserveCartCheckout(status string, itemCount int)
- func (m *Metrics) ObserveDBQuery(operation, backend string, duration time.Duration)
- func (m *Metrics) ObservePayment(method, resource string, success bool, duration time.Duration, ...)
- func (m *Metrics) ObservePaymentFailure(method, resource, reason string)
- func (m *Metrics) ObserveRPCCall(method, network string, duration time.Duration, err error)
- func (m *Metrics) ObserveRateLimit(limitType, identifier string)
- func (m *Metrics) ObserveRefund(status string, amountCents int64, token string, duration time.Duration, ...)
- func (m *Metrics) ObserveSettlement(network string, duration time.Duration)
- func (m *Metrics) ObserveWebhook(eventType, status string, duration time.Duration, attempt int, sentToDLQ bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MeasureDBQuery ¶
MeasureDBQuery wraps a database operation with timing instrumentation. Usage:
defer metrics.MeasureDBQuery(m, "get_product", "postgres")()
Or with explicit start time:
start := time.Now() // ... do database work ... metrics.RecordDBQuery(m, "get_product", "postgres", time.Since(start))
Types ¶
type Metrics ¶
type Metrics struct {
// Payment metrics
PaymentsTotal *prometheus.CounterVec
PaymentsSuccessTotal *prometheus.CounterVec
PaymentsFailedTotal *prometheus.CounterVec
PaymentAmountTotal *prometheus.CounterVec
PaymentDuration *prometheus.HistogramVec
SettlementDuration *prometheus.HistogramVec
// RPC call metrics
RPCCallsTotal *prometheus.CounterVec
RPCCallDuration *prometheus.HistogramVec
RPCErrorsTotal *prometheus.CounterVec
// Cart metrics
CartCheckoutsTotal *prometheus.CounterVec
CartItemsTotal prometheus.Counter
CartAverageValue prometheus.Gauge
// Refund metrics
RefundsTotal *prometheus.CounterVec
RefundAmountTotal *prometheus.CounterVec
RefundDuration *prometheus.HistogramVec
// Webhook metrics
WebhooksTotal *prometheus.CounterVec
WebhookRetriesTotal *prometheus.CounterVec
WebhookDLQTotal *prometheus.CounterVec
WebhookDuration *prometheus.HistogramVec
// Rate limiting metrics
RateLimitHitsTotal *prometheus.CounterVec
// Database metrics
DBQueryDuration *prometheus.HistogramVec
DBConnectionsActive prometheus.Gauge
// System metrics
ArchivalRunsTotal prometheus.Counter
ArchivalRecordsDeleted prometheus.Counter
}
Metrics holds all Prometheus metrics for Cedros Pay.
func New ¶
func New(registry prometheus.Registerer) *Metrics
New creates and registers all Prometheus metrics.
func (*Metrics) ObserveArchival ¶
ObserveArchival records an archival run.
func (*Metrics) ObserveCartCheckout ¶
ObserveCartCheckout records a cart checkout.
func (*Metrics) ObserveDBQuery ¶
ObserveDBQuery records a database query.
func (*Metrics) ObservePayment ¶
func (m *Metrics) ObservePayment(method, resource string, success bool, duration time.Duration, amountCents int64, token string)
ObservePayment records a payment attempt and its outcome.
func (*Metrics) ObservePaymentFailure ¶
ObservePaymentFailure records a failed payment with reason.
func (*Metrics) ObserveRPCCall ¶
ObserveRPCCall records an RPC call to the blockchain.
func (*Metrics) ObserveRateLimit ¶
ObserveRateLimit records a rate limit hit.
func (*Metrics) ObserveRefund ¶
func (m *Metrics) ObserveRefund(status string, amountCents int64, token string, duration time.Duration, method string)
ObserveRefund records a refund operation.
func (*Metrics) ObserveSettlement ¶
ObserveSettlement records blockchain settlement time.
Click to show internal directories.
Click to hide internal directories.