Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Metrics ¶
type Metrics struct {
ReqCntURLLabelMappingFn RequestCounterURLLabelMappingFn
}
Metrics contains the metrics gathered by the instance
func NewMetrics ¶
NewMetrics generates a new set of metrics
func (*Metrics) HandlerFunc ¶
func (m *Metrics) HandlerFunc(metricsPrefix []string, ignoreURLs []string, replaceSlashWithUnderscore bool) gin.HandlerFunc
HandlerFunc is a function which should be used as middleware to count requests stats such as request processing time, request and response size and store it in rcrowley/go-metrics.DefaultRegistry.
type RequestCounterURLLabelMappingFn ¶
RequestCounterURLLabelMappingFn 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 *gin.Context) string { url := c.Request.URL.String() 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".