http_prometheus

package
v0.0.0-...-a464bf5 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultResponseSizeHistogram are the default (if enabled) buckets for response size histograms.
	DefaultResponseSizeHistogram = []float64{32.0, 256.0, 2048.0, 16384.0, 131072.0, 1048576}
	// DefaultLatencyHistogram defines the default (if enabled) buckets for latency histograms.
	DefaultLatencyHistogram = prometheus.DefBuckets
)

Functions

func Middleware

func Middleware(opts ...Option) httpwares.Middleware

Middleware is a server-side http ware for monitoring handlers using Prometheus counters and histograms.

Handlers are labeled by the http_ctxtags `TagForHandlerGroup` and `TagForHandlerName` applied using the http_ctxtags Middleware and HandlerName methods. These values are used as labels for all requests.

The following monitoring variables can be created if opted in using options:

http_server_requests_total
http_server_response_size_bytes
http_server_response_headers_duration_seconds
http_server_request_duration_seconds

Please note that the instantiation of this Middleware can panic if it has been previously instantiated with other options due to clashes in Prometheus metric names.

func Tripperware

func Tripperware(opts ...Option) httpwares.Tripperware

Tripperware is a client-side http ware for monitoring calls to http services.

Calls are labeled by the http_ctxtags `TagForCallService` http_ctxtags.Tripperware. By default, these are inferred from hostnames.

The following monitoring variables can be created if opted in using options:

http_client_requests_total
http_client_response_headers_duration_seconds

Please note: errors in handled respo

Please note that the instantiation of this Tripperware can panic if it has been previously instantiated with other options due to clashes in Prometheus metric names.

Types

type Option

type Option func(*options)

func WithNamespace

func WithNamespace(prometheusNamespace string) Option

WithNamespace customizes the Prometheus namespace (first component before first underscore) of all the metrics.

func WithRequestCompletionLatencyHistogram

func WithRequestCompletionLatencyHistogram(bucketValues ...float64) Option

WithRequestCompletionLatencyHistogram enables the middleware to record the latency to completion of request.

Optionally, you can provide your own histogram buckets for the measurements. If not provided DefaultLatencyHistogram is used.

func WithResponseHeadersLatencyHistogram

func WithResponseHeadersLatencyHistogram(bucketValues ...float64) Option

WithResponseHeadersLatencyHistogram enables the middleware to record the latency to headers response in seconds.

Optionally, you can provide your own histogram buckets for the measurements. If not provided DefaultLatencyHistogram is used.

func WithResponseSizeHistogram

func WithResponseSizeHistogram(bucketValues ...float64) Option

WithResponseSizeHistogram enables the middleware to record the sizes of response messages in bytes.

Optionally, you can provide your own histogram buckets for the measurements. If not provided DefaultResponseSizeHistogram is used.

Jump to

Keyboard shortcuts

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