metrics

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 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.

Variables

This section is empty.

Functions

func Handler added in v0.5.2

func Handler() http.Handler

Handler returns an HTTP handler for the metrics endpoint.

func Reset added in v0.5.2

func Reset()

Reset resets all metrics. This is intended for use in tests only.

Types

type PrometheusCollector added in v0.5.2

type PrometheusCollector struct{}

PrometheusCollector implements the Collector interface using Prometheus metrics.

func NewCollector added in v0.5.2

func NewCollector() *PrometheusCollector

NewCollector creates a new PrometheusCollector.

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