go-cron
go-cron copied to clipboard
Feature Request: Expose Prometheus-Compatible Metrics Endpoint
Feature Request
Summary:
It would be highly beneficial for go-cron to include functionality to expose metrics in a format that Prometheus can scrape. This would allow users to monitor the performance and health of go-cron jobs within their Prometheus monitoring ecosystem.
Detail:
Currently, go-cron opens an HTTP port that can be used as a health check, as described in the README and implemented in gocron/httpserver.go. Building on this, I propose adding a new endpoint, /metrics, that serves metrics in a Prometheus-compatible format. This would involve metrics such as job execution times, success/failure counts, and other relevant runtime metrics.
Suggested Implementation:
- Extend the HTTP server functionality in
gocron/httpserver.goto include a/metricsendpoint. - Implement a metrics collection system within
go-cronthat tracks relevant metrics during job execution. - Format the collected metrics using Prometheus exposition formats, making them available via the
/metricsendpoint.
Benefits:
- This feature would enable users to integrate
go-cronmonitoring with their existing Prometheus setups, providing a unified view of system health and performance. - It would also allow for alerting on specific conditions related to
go-cronjobs, enhancing the ability to respond to issues promptly.
Considerations:
- Care should be taken to ensure that the metrics collection and exposition have minimal impact on the performance of
go-cron. - It would be useful to make the metrics feature configurable, allowing users to enable or disable it as per their requirements.
Thank you for considering this feature request. I believe it would significantly enhance the utility and observability of go-cron in production environments.
Thanks for the suggestion @42m4n! Happy to extend the project to include that feature. I will keep you posted.