metrics

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package metrics provides observability interfaces and telemetry data structures for distlimit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithRoute

func ContextWithRoute(ctx context.Context, route string) context.Context

ContextWithRoute returns a copy of parent context carrying the given route pattern string.

func RouteFromContext

func RouteFromContext(ctx context.Context) string

RouteFromContext extracts the route pattern string from context if present.

Types

type Event

type Event struct {
	// Key is the rate limit key evaluated.
	Key string
	// Route is the HTTP/RPC route pattern associated with the request (if route labeling is enabled).
	Route string
	// Allowed indicates whether the request was permitted.
	Allowed bool
	// Limit is the configured maximum request capacity.
	Limit int64
	// Remaining is the remaining request quota available.
	Remaining int64
	// ResetIn specifies the duration until quota resets.
	ResetIn time.Duration
	// Driver is the storage driver identifier (e.g., "memory", "redis", "hybrid").
	Driver string
	// Algorithm is the strategy identifier (e.g., "sliding_counter", "token_bucket").
	Algorithm string
	// Duration is the internal execution latency of the rate limit evaluation.
	Duration time.Duration
}

Event represents a single rate limit evaluation telemetry snapshot.

type Observer

type Observer interface {
	// Observe receives rate limit evaluation events for recording metrics/telemetry.
	Observe(ctx context.Context, event Event)
}

Observer defines the interface for collecting telemetry metrics and traces.

func NewNoopObserver

func NewNoopObserver() Observer

NewNoopObserver creates an observer that discards all recorded events.

Directories

Path Synopsis
Package otel provides an OpenTelemetry metrics observer implementation for distlimit.
Package otel provides an OpenTelemetry metrics observer implementation for distlimit.
Package prometheus provides a Prometheus metrics observer implementation for distlimit.
Package prometheus provides a Prometheus metrics observer implementation for distlimit.

Jump to

Keyboard shortcuts

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