gofr icon indicating copy to clipboard operation
gofr copied to clipboard

Support emitting metrics from CLI applications

Open aryanmehrotra opened this issue 3 months ago • 1 comments

Description

Currently, GoFr provides native support for exposing metrics in long-running services via /metrics endpoints. However, CLI applications or CronJobs (short-lived batch jobs) don’t have a persistent process, making it impossible to expose metrics directly.

To support observability for such workloads, GoFr should provide a mechanism to emit metrics from CLI applications in a way that integrates cleanly with Prometheus (or other monitoring systems).

Proposed Solution

  • Add built-in support for Pushgateway integration:

    • Allow GoFr CLI applications to push job-level metrics (success, failure, duration, custom counters/gauges).
  • Allow configuration through environment variables/flags (e.g., GOFR_METRICS_PUSHGATEWAY_URL).

  • Support cleanup (optional) so old metrics don’t pile up.

Use Cases

  • Kubernetes CronJobs that use GoFr CLI applications.
  • CI/CD pipelines running GoFr-based tools.
  • One-off admin scripts that need to report metrics.

Benefits

  • Consistent observability across services and batch jobs.
  • No need for custom logging → parsing pipelines.
  • First-class Prometheus compatibility.

aryanmehrotra avatar Sep 03 '25 03:09 aryanmehrotra

Observabilty in CLI applications is not very updated. This needs refactoring. Sure will pick this up soon.

coolwednesday avatar Sep 05 '25 09:09 coolwednesday