Skip to content

Commit

Permalink
Add prom metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizzadar committed Dec 19, 2023
1 parent 6f07f4d commit 43b5aac
Show file tree
Hide file tree
Showing 6 changed files with 602 additions and 1 deletion.
10 changes: 10 additions & 0 deletions cmd/registration_relay/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"github.com/beeper/registration-relay/internal/api"
"github.com/beeper/registration-relay/internal/config"
"github.com/beeper/registration-relay/internal/metrics"
)

var Commit,
Expand All @@ -27,6 +28,11 @@ func main() {
flagenv.StringEnvWithDefault("REGISTRATION_RELAY_LISTEN", ":8000"),
"Listen address",
)
metricsListenAddr := flag.String(
"metricsListen",
flagenv.StringEnvWithDefault("REGISTRATION_RELAY_METRICS_LISTEN", ":5000"),
"Metrics listen address",
)

flag.Parse()

Expand All @@ -45,6 +51,9 @@ func main() {

log.Info().Str("commit", Commit).Str("build_time", BuildTime).Msg("registration-relay starting")

metricsSrv := metrics.NewPrometheusMetricsHandler(*metricsListenAddr)
metricsSrv.Start()

srv := api.NewAPI(cfg)
srv.Start()

Expand All @@ -55,5 +64,6 @@ func main() {
log.Info().Msg("Going to stop...")

srv.Stop()
metricsSrv.Stop()
os.Exit(0)
}
9 changes: 9 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@ require (
github.com/beeper/libserv v0.0.0-20231201123829-f6b6f7efe7a7
github.com/go-chi/chi/v5 v5.0.10
github.com/gorilla/websocket v1.5.1
github.com/prometheus/client_golang v1.14.0
github.com/rs/zerolog v1.31.0
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/rs/xid v1.5.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
)
Loading

0 comments on commit 43b5aac

Please sign in to comment.