middleware

package module
v0.0.0-...-f8fe7f9 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package middleware provides a collection of go-chi compatible custom middleware.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestMetrics

func RequestMetrics(
	service string,
	registry prometheus.Registerer,
	buckets ...float64,
) func(next http.Handler) http.Handler

RequestMetrics tracks request counts and latencies partitioned by response code, HTTP method and path.

The provided service should be unique to each tracked service. The registry is optional and will default to a process-level singleton.

Latency buckets, specified by upper bound, may be optionally be provided. If omitted they will be set to the following default values (in milliseconds): []float64{5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000}

For accuracy, buckets should mirror the distribution of the latencies of the service. See https://github.com/danielfm/prometheus-for-developers#quantile-estimation-errors

Types

This section is empty.

Jump to

Keyboard shortcuts

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