Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustNew ¶
func MustNew(c Config) endpoint.Middleware
MustNew returns a new metrics middleware but panics in case of error.
Types ¶
type Config ¶
type Config struct { // Metrifier is the metrifier configuration Metrifier metrifier.Config // LabelsDecoder extracts labels from the request, response or error. // This is optional, can be nil LabelsDecoder LabelsDecoder // ExternalMetrics is executed after the main metrifier is called. // This is intended to calculate custom metrics. // This is optional, can be nil. ExternalMetrics ExternalMetrics }
Config is used to configure a metrics middleware.
func NewDefaultConfig ¶
NewDefaultConfig returns a new Config with sane defaults.
func (Config) WithExternalMetrics ¶
func (c Config) WithExternalMetrics(m ExternalMetrics) Config
WithExternalMetrics adds ExternalMetrics to the metrics middleware.
func (Config) WithLabelsDecoder ¶
func (c Config) WithLabelsDecoder(d LabelsDecoder) Config
WithLabelsDecoder adds a LabelsDecoder to the metrics middleware.
type ExternalMetrics ¶
ExternalMetrics is called after the internal metrifier is called. This functions should compute other metrics that are not computed by the internal metrifier (request latency and count).
type LabelsDecoder ¶
type LabelsDecoder interface { // Labels return the complete list of all available labels that will be // returned by the Decoder. This is called once during setup of the middleware. Labels() []string // Decode extracts a map of labels considering the request, response and error. // The map returned must contain only labels returned by the Labels() function. Decode(ctx context.Context, req, resp interface{}, err error) map[string]string }
LabelsDecoder defines an interface to decode labels for the internal metrifier.
Click to show internal directories.
Click to hide internal directories.