Skip to content
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

Make it easier to expose Prometheus metrics on custom endpints #1079

Merged

Conversation

ivantopo
Copy link
Contributor

@ivantopo ivantopo commented Nov 15, 2021

It often happens that people want to expose the Prometheus scrape data on their own HTTP server and the only way to do it so far is to:

  1. Prevent Kamon from auto-starting the Prometheus reporter via settings with kamon.modules.prometheus-reporter.enabled=false
  2. Create an instance of the reporter programmatically and add it to Kamon via Kamon.addReporter(...), and keep a reference to the reporter
  3. Use the reference to call prometheusReporter.scrapeData() and return that on the HTTP server

It is kind of annoying. Since we know that in most cases there is only one PrometheusReporter instance created automatically by Kamon, this PR ensures that we keep a reference to that instance and expose it's scrape data via PrometheusReporter.latestScrapeData(), so that users can skip all the above when they need to.

@ivantopo
Copy link
Contributor Author

Let me modify this. Now that I think about it, there is no reason for users to access the entire PrometheusReporter instance, since what they want all the time is the scrape data. Let's expose that alone.

@ivantopo
Copy link
Contributor Author

Validated this locally. Works fine.

@ivantopo ivantopo merged commit b38b68c into kamon-io:master Nov 17, 2021
@ivantopo ivantopo deleted the easier-access-to-prometheus-reporter branch November 17, 2021 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant