-
Notifications
You must be signed in to change notification settings - Fork 791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Prometheus middleware usage example #3279
Conversation
Show how the PrometheusExportService can be used to expose the metrics for scraping. I spent a long time trying to figure it out, would like to pay it forward.
fixes #3278 |
docs/src/main/tut/middleware.md
Outdated
``` | ||
```tut:book | ||
implicit val clock = Clock.create[IO] | ||
|
||
val meteredRoutes: Resource[IO, HttpRoutes[IO]] = | ||
def meteredRouter(routes: HttpRoutes[IO]): Resource[IO, HttpRoutes[IO]] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be called somewhere with the apiService
now its just a function that is not used in this example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I guess I thought getting the reader to a Resource[IO, HttpRoutes[IO]] would be sufficient (without writing an entire sample server).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is better, but we should still call this method with apiService
to show use.
or we can change this back to use the apiService
directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean. I'll make that change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 looks reasonable to me but it would be good to get feedback from someone more familiar with prometheus usage.
for { | ||
registry <- Prometheus.collectorRegistry[IO] | ||
metrics <- Prometheus.metricsOps[IO](registry, "server") | ||
} yield Metrics[IO](metrics)(apiService) | ||
metricsSvc <- PrometheusExportService.build[IO] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this require the registry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ChristopherDavenport The apply method requires the registry, the build
methods creates a new registry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In which case this would need to be first and be the registry used for metering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally missed the difference between build and apply. I can fix that up.
Thanks! Test failures are unrelated. |
Show how the PrometheusExportService can be used to expose the metrics for scraping. I spent a long time trying to figure it out, would like to pay it forward.