feat: Add Prometheus metrics and health endpoints #100
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello
I'm not sure if this will be useful for anyone else, but I've added a few Prometheus metrics to the relay and thought I'd share. I'm pretty sure there are other ways to get these same metrics by adding external services but I prefer to just expose them internally. Feel free to reject the PR if it's not useful to anyone else, or if it is just horrendous.
Quick disclaimer: I'm not a developer by trade, I've just been messing around with Go on weekends, so please go easy on me. 😄
I borrowed/copied some of the code from Thanos, but I'm not 100% sure if what I did makes sense, or if there are better ways of doing it. I would be very happy to receive feedback for improvement.
What I Did:
I'd also like to add metrics for the machinery task queue, for example, how many tasks are in the queue, how many succeeded/failed, how many tasks are actively being processed, and average completion times.
Plus, I want to expose some general relay stats (e.g., how many instances are subscribed, how many are still alive/failed, etc.). I haven't figured out how to do that yet.