metrics

package
v4.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Recorder Recorder
	// func that allows you to provide a strategy to identify/group metrics
	// you can group metrics by request host/url/... or app name ...
	// by default, we group metrics by request url
	IdentifierProvider func(req *http.Request) string
	// if set to true, each response status will be represented by a metrics
	// if set to false, response status codes will be grouped by first digit (204/201/200/... -> 2xx; 404/403/... -> 4xx)
	SplitStatus bool
	// if set to true, recorder will add a responseSize metric
	ObserveResponseSize bool
	// if set to true, recorder will add a metric representing the number of inflight requests
	MeasureInflightRequests bool
}

func NewConfig

func NewConfig(recorder Recorder, options ...Option) *Config

NewConfig returns a new metrics configuration with all options applied

type Option

type Option func(*Config)

Option defines a metrics middleware/tripperware configuration option

func WithIdentifierProvider

func WithIdentifierProvider(identifierProvider func(req *http.Request) string) Option

WithIdentifierProvider will configure IdentifierProvider metrics option

func WithMeasureInflightRequests

func WithMeasureInflightRequests(measureInflightRequests bool) Option

WithMeasureInflightRequests will configure MeasureInflightRequests metrics option

func WithObserveResponseSize

func WithObserveResponseSize(observeResponseSize bool) Option

WithObserveResponseSize will configure ObserveResponseSize metrics option

func WithSplitStatus

func WithSplitStatus(splitStatus bool) Option

WithSplitStatus will configure SplitStatus metrics option

type Recorder

type Recorder interface {
	ObserveHTTPRequestDuration(ctx context.Context, id string, duration time.Duration, method, code string)
	ObserveHTTPResponseSize(ctx context.Context, id string, responseSize int64, method, code string)
	AddInflightRequests(ctx context.Context, id string, quantity int)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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