Documentation ¶
Overview ¶
Package otelmetric provides middleware to add opentelemetry metrics and OtelMetrics exporter.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MiddlewareConfig ¶
type MiddlewareConfig struct { // Skipper defines a function to skip middleware. Skipper middleware.Skipper // Namespace is components of the fully-qualified name of the Metric (created by joining Namespace and Name components with "_") // Optional Namespace string ServiceVersion string MetricsPath string ScopeInfo bool RequestCounterURLLabelMappingFunc RequestCounterLabelMappingFunc RequestCounterHostLabelMappingFunc RequestCounterLabelMappingFunc // Registry is the prometheus registry that will be used as the default Registerer and // Gatherer if these are not specified. Registry *realprometheus.Registry // Registerer sets the prometheus.Registerer instance the middleware will register these metrics with. // Defaults to: prometheus.DefaultRegisterer Registerer realprometheus.Registerer // Gatherer is the prometheus gatherer to gather metrics with. // If not specified the Registry will be used as default. Gatherer realprometheus.Gatherer }
MiddlewareConfig contains the configuration for creating prometheus middleware collecting several default metrics.
type OtelMetrics ¶ added in v2.0.1
type OtelMetrics struct { *MiddlewareConfig // contains filtered or unexported fields }
OtelMetrics contains the metrics gathered by the instance and its path
func New ¶ added in v2.0.1
func New(config MiddlewareConfig) *OtelMetrics
New generates a new set of metrics with a certain subsystem name
func (*OtelMetrics) NewHandler ¶ added in v2.0.3
func (p *OtelMetrics) NewHandler() echo.HandlerFunc
func (*OtelMetrics) NewMiddleware ¶ added in v2.0.3
func (p *OtelMetrics) NewMiddleware() echo.MiddlewareFunc
NewMiddleware defines handler function for middleware
type RequestCounterLabelMappingFunc ¶
type RequestCounterLabelMappingFunc func(c echo.Context) string
RequestCounterLabelMappingFunc is a function which can be supplied to the middleware to control the cardinality of the request counter's "url" label, which might be required in some contexts. For instance, if for a "/customer/:name" route you don't want to generate a time series for every possible customer name, you could use this function:
func(c echo.Context) string { url := c.Request.URL.Path for _, p := range c.Params { if p.Key == "name" { url = strings.Replace(url, p.Value, ":name", 1) break } } return url }
which would map "/customer/alice" and "/customer/bob" to their template "/customer/:name". It can also be applied for the "Host" label