Documentation
¶
Index ¶
- Variables
- func APIWrapper(handler http.Handler) apiWrapper
- func NewCallWrapper(opts ...Option) client.CallWrapper
- func NewClientWrapper(opts ...Option) client.Wrapper
- func NewHandlerWrapper(opts ...Option) server.HandlerWrapper
- func NewSubscriberWrapper(opts ...Option) server.SubscriberWrapper
- func WebWrapper(handlerID string, handler http.Handler) webWrapper
- type Config
- type Middleware
- type Option
- type Options
- type Reporter
Constants ¶
This section is empty.
Variables ¶
var ( // default metric prefix DefaultMetricPrefix = "micro_" // default label prefix DefaultLabelPrefix = "micro_" )
Functions ¶
func APIWrapper ¶
APIWrapper returns an measuring standard http.Handler for api related endpoints.
func NewCallWrapper ¶
func NewCallWrapper(opts ...Option) client.CallWrapper
func NewClientWrapper ¶
func NewHandlerWrapper ¶
func NewHandlerWrapper(opts ...Option) server.HandlerWrapper
func NewSubscriberWrapper ¶
func NewSubscriberWrapper(opts ...Option) server.SubscriberWrapper
func WebWrapper ¶
Types ¶
type Config ¶
type Config struct { // Recorder is the way the metrics will be recorder in the different backends. Recorder model.Recorder // Service is an optional identifier for the metrics, this can be useful if // a same service has multiple servers (e.g API, metrics and healthchecks). Service string // GroupedStatus will group the status label in the form of `\dxx`, for example, // 200, 201, and 203 will have the label `code="2xx"`. This impacts on the cardinality // of the metrics and also improves the performance of queries that are grouped by // status code because there are already aggregated in the metric. // By default will be false. GroupedStatus bool // DisableMeasureSize will disable the recording metrics about the response size, // by default measuring size is enabled (`DisableMeasureSize` is false). DisableMeasureSize bool // DisableMeasureInflight will disable the recording metrics about the inflight requests number, // by default measuring inflights is enabled (`DisableMeasureInflight` is false). DisableMeasureInflight bool }
Config is the configuration for the middleware factory.
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware is a service that knows how to measure an HTTP handler by wrapping another handler.
Depending on the framework/library we want to measure, this can change a lot, to abstract the way how we measure on the different libraries, Middleware will recieve a `Reporter` that knows how to get the data the Middleware service needs to measure.
func (Middleware) Measure ¶
func (m Middleware) Measure(handlerID string, reporter Reporter, next func())
Measure abstracts the HTTP handler implementation by only requesting a reporter, this reporter will return the required data to be measured. it accepts a next function that will be called as the wrapped logic before and after measurement actions.