flexmetrics
About#
The package go-flexible/flexmetrics provides a default set of configuration for hosting prometheus and pprof metrics.
Install#
go get github.com/go-flexible/flexmetricsConfiguration#
The metric server can be configured through the environment to match setup in the infrastructure.
PROMETHEUS_ADDRdefault::2112PROMETHEUS_PATHdefault:/metrics
Example#
Starting the server and exposing metrics#
// Rely on the package defaultssrv := flexmetrics.New()srv.Run(ctx)
// Or bring your ownhttpServer := &http.Server{ Addr: ":8081",}srv := flexmetrics.New( flexmetrics.WithServer(httpServer), flexmetrics.WithPath("/__/metrics"),)srv.Run(ctx)pprof metrics will be exposed on:
/debug/pprof//debug/pprof/cmdline/debug/pprof/profile/debug/pprof/symbol/debug/pprof/trace