metrics

package
v0.1.36 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

metrics/metrics.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPMetrics

func HTTPMetrics(next http.Handler) http.Handler

HTTPMetrics is a middleware that records request duration into the http_request_duration_seconds histogram.

It uses the chi route pattern (e.g., "/users/{id}") instead of the actual request path (e.g., "/users/123") to prevent label cardinality explosion. Paths longer than 256 characters are truncated with "..." to prevent unbounded memory growth in the metrics registry.

func Handler

func Handler() http.Handler

Handler returns an http.Handler that exposes the Prometheus metrics.

func RegisterDefault

func RegisterDefault(logger *zap.Logger)

RegisterDefault registers the default Go runtime and process collectors, plus the HTTP request duration histogram. It is safe (and intended) to call this once at startup.

This function will panic if registration fails for reasons other than the collector already being registered. This ensures configuration errors are caught early rather than silently ignored.

Types

This section is empty.

Jump to

Keyboard shortcuts

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