metrics

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package metrics provides Prometheus metrics for the application.

Index

Constants

View Source
const (
	StatusAllowed = "allowed"
	StatusDenied  = "denied"
	StatusInvalid = "invalid"
)

Status label values for the requests counter.

View Source
const (
	ResultSuccess = "success"
	ResultFailure = "failure"
)

Result label values for the config reload counter.

Variables

This section is empty.

Functions

This section is empty.

Types

type PrometheusCollector added in v0.5.2

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

PrometheusCollector implements the Collector interface using Prometheus metrics.

func NewCollector added in v0.5.2

func NewCollector() *PrometheusCollector

NewCollector creates a new PrometheusCollector with its own registry.

func (*PrometheusCollector) Handler added in v0.6.1

func (c *PrometheusCollector) Handler() http.Handler

Handler returns an HTTP handler for the metrics endpoint.

func (*PrometheusCollector) RecordConfigReload added in v0.5.2

func (c *PrometheusCollector) RecordConfigReload(success bool, rulesCount int)

RecordConfigReload records a config reload attempt.

func (*PrometheusCollector) RecordDBUpdate added in v0.5.2

func (c *PrometheusCollector) RecordDBUpdate(
	entries map[ipinfo.DBSource]uint64,
	duration time.Duration,
)

RecordDBUpdate records an IP database update.

func (*PrometheusCollector) RecordInvalidRequest added in v0.5.2

func (c *PrometheusCollector) RecordInvalidRequest(duration time.Duration)

RecordInvalidRequest records metrics for an invalid request.

func (*PrometheusCollector) RecordRequest added in v0.5.2

func (c *PrometheusCollector) RecordRequest(r RequestRecord)

RecordRequest records comprehensive metrics for a request.

type RequestCollector added in v0.5.7

type RequestCollector interface {
	RecordRequest(record RequestRecord)
	RecordInvalidRequest(duration time.Duration)
}

RequestCollector collects metrics for HTTP requests.

type RequestRecord added in v0.5.7

type RequestRecord struct {
	Status          string
	Country         string
	Method          string
	Duration        time.Duration
	RuleIndex       int
	Action          string
	IsDefaultPolicy bool
}

RequestRecord contains all data needed to record metrics for a single request.

Jump to

Keyboard shortcuts

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