go-cron icon indicating copy to clipboard operation
go-cron copied to clipboard

Feature Request: Expose Prometheus-Compatible Metrics Endpoint

Open 42m4n opened this issue 1 year ago • 1 comments

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.go to include a /metrics endpoint.
  • Implement a metrics collection system within go-cron that tracks relevant metrics during job execution.
  • Format the collected metrics using Prometheus exposition formats, making them available via the /metrics endpoint.

Benefits:

  • This feature would enable users to integrate go-cron monitoring 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-cron jobs, 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.

42m4n avatar Apr 19 '24 14:04 42m4n

Thanks for the suggestion @42m4n! Happy to extend the project to include that feature. I will keep you posted.

michaloo avatar Apr 21 '24 11:04 michaloo