echoprometheus package - github.com/labstack/echo-prometheus - Go Packages
Package echoprometheus provides middleware to add Prometheus metrics.
- func NewHandler() echo.HandlerFunc
- func NewHandlerWithConfig(config HandlerConfig) echo.HandlerFunc
- func NewMiddleware(subsystem string) echo.MiddlewareFunc
- func NewMiddlewareWithConfig(config MiddlewareConfig) echo.MiddlewareFunc
- func RunPushGatewayGatherer(ctx context.Context, config PushGatewayConfig) error
- func WriteGatheredMetrics(writer io.Writer, gatherer prometheus.Gatherer) error
- type HandlerConfig
- type LabelValueFunc
- type MiddlewareConfig
- type PushGatewayConfig
This section is empty.
This section is empty.
func NewHandler ¶
NewHandler creates new instance of Handler using Prometheus default registry.
func NewHandlerWithConfig ¶
NewHandlerWithConfig creates new instance of Handler using given configuration.
NewMiddleware creates new instance of middleware using Prometheus default registry.
NewMiddlewareWithConfig creates new instance of middleware using given configuration.
RunPushGatewayGatherer starts pushing collected metrics and waits for it context to complete or ErrorHandler to return error.
Example: ```
go func() {
config := echoprometheus.PushGatewayConfig{
PushGatewayURL: "https://host:9080",
PushInterval: 10 * time.Millisecond,
}
if err := echoprometheus.RunPushGatewayGatherer(context.Background(), config); !errors.Is(err, context.Canceled) {
log.Fatal(err)
}
}()
```
WriteGatheredMetrics gathers collected metrics and writes them to given writer
type HandlerConfig ¶
HandlerConfig contains the configuration for creating HTTP handler for metrics.
LabelValueFunc is a function that returns a label value for a given context and error.
MiddlewareConfig contains the configuration for creating prometheus middleware collecting several default metrics.
ToMiddleware converts configuration to middleware or returns an error.
PushGatewayConfig contains the configuration for pushing to a Prometheus push gateway.