Documentation
¶
Index ¶
Constants ¶
View Source
const ( // EndpointFieldName is the Prometheus label for the request endpoint. EndpointFieldName = "endpoint" // CodeFieldName is the Prometheus label for the HTTP status code. CodeFieldName = "code" )
Variables ¶
View Source
var ( // RequestCountComponent is a Compogo component that provides // HTTP request count metrics middleware. RequestCountComponent = &component.Component{ Init: component.StepFunc(func(container container.Container) error { return container.Provide(NewRequestCount) }), } // DurationComponent is a Compogo component that provides // HTTP request duration metrics middleware. DurationComponent = &component.Component{ Init: component.StepFunc(func(container container.Container) error { return container.Provide(NewDuration) }), } )
Functions ¶
This section is empty.
Types ¶
type Duration ¶
type Duration struct {
// contains filtered or unexported fields
}
Duration is middleware that measures HTTP request duration. It exports a histogram metric: compogo_http_server_duration_seconds{app, endpoint}
func NewDuration ¶
NewDuration creates a new Duration middleware. The appConfig provides the application name for the metric label.
type RequestCount ¶
type RequestCount struct {
// contains filtered or unexported fields
}
RequestCount is middleware that counts HTTP requests by status code and endpoint. It exports a counter metric: compogo_http_server_requests_total{app, code, endpoint}
func NewRequestCount ¶
func NewRequestCount(appConfig *compogo.Config) *RequestCount
NewRequestCount creates a new RequestCount middleware. The appConfig provides the application name for the metric label.
func (*RequestCount) Middleware ¶
func (middleware *RequestCount) Middleware(next http.Handler) http.Handler
Middleware implements the http.Middleware interface. It increments the counter after the request completes.
Click to show internal directories.
Click to hide internal directories.