Skip to content

Commit

Permalink
Merge pull request #331 from xmidt-org/denopink/patch/fx-prometheus
Browse files Browse the repository at this point in the history
Bug: Fix Metric Server
  • Loading branch information
denopink authored Nov 8, 2022
2 parents b988bda + fdf4a95 commit 703d725
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]

- [No Prom Metrics Being Produced #329](https://github.com/xmidt-org/tr1d1um/issues/329)

## [v0.7.10]
- Remove several unused build files and update the docker images to work. [#325](https://github.com/xmidt-org/tr1d1um/pull/325)
Expand Down
15 changes: 14 additions & 1 deletion routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ type metricMiddlewareOut struct {
Health alice.Chain `name:"middleware_health_metrics"`
}

type metricsRoutesIn struct {
fx.In
Router *mux.Router `name:"server_metrics"`
Handler touchhttp.Handler
}

func provideServers() fx.Option {
return fx.Options(
arrange.ProvideKey(reqMaxRetriesKey, 0),
Expand Down Expand Up @@ -171,11 +177,12 @@ func provideServers() fx.Option {
}.Provide(),
arrangehttp.Server{
Name: "server_metrics",
Key: "servers.metric",
Key: "servers.metrics",
}.Provide(),
fx.Invoke(
handlePrimaryEndpoint,
handleWebhookRoutes,
buildMetricsRoutes,
),
)
}
Expand Down Expand Up @@ -385,3 +392,9 @@ func v2ErrEncode(w http.ResponseWriter, logger log.Logger, err error, code int)
"message": err.Error(),
})
}

func buildMetricsRoutes(in metricsRoutesIn) {
if in.Router != nil && in.Handler != nil {
in.Router.Handle("/metrics", in.Handler).Methods("GET")
}
}

0 comments on commit 703d725

Please sign in to comment.