https://github.com/go-flexible/flexmetrics
The package go-flexible/flexmetrics provides a default set of configuration for hosting prometheus and pprof metrics.
https://github.com/go-flexible/flexmetrics
12-factor go golang golang-library metrics microservice prometheus
Last synced: 2 months ago
JSON representation
The package go-flexible/flexmetrics provides a default set of configuration for hosting prometheus and pprof metrics.
- Host: GitHub
- URL: https://github.com/go-flexible/flexmetrics
- Owner: go-flexible
- License: apache-2.0
- Created: 2021-08-07T21:32:58.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-01-11T11:37:37.000Z (about 3 years ago)
- Last Synced: 2024-06-21T01:39:17.645Z (almost 2 years ago)
- Topics: 12-factor, go, golang, golang-library, metrics, microservice, prometheus
- Language: Go
- Homepage:
- Size: 50.8 KB
- Stars: 2
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Metrics Server
[](https://github.com/go-flexible/flexmetrics/actions/workflows/go.yml)
The package `go-flexible/flexmetrics` provides a default set of configuration for hosting prometheus and `pprof` metrics.
## Configuration
The metric server can be configured through the environment to match setup in the infrastructure.
- `PROMETHEUS_ADDR` default: `:9090`
- `PROMETHEUS_PATH` default: `/metrics`
## Examples
### Starting server and exposing metrics
```go
// Rely on the package defaults
srv := flexmetrics.New()
srv.Run(ctx)
// Or bring your own
httpServer := &http.Server{
Addr: ":8081",
}
srv := flexmetrics.New(
flexmetrics.WithServer(httpServer),
flexmetrics.WithPath("/__/metrics"),
)
srv.Run(ctx)
```
`pprof` metrics will be exposed on:
```text
/debug/pprof/
/debug/pprof/cmdline
/debug/pprof/profile
/debug/pprof/symbol
/debug/pprof/trace
```