|
| 1 | +package relay |
| 2 | + |
| 3 | +import ( |
| 4 | + "net/http" |
| 5 | + |
| 6 | + "github.com/prometheus/client_golang/prometheus" |
| 7 | + "github.com/prometheus/client_golang/prometheus/promauto" |
| 8 | + "github.com/prometheus/client_golang/prometheus/promhttp" |
| 9 | +) |
| 10 | + |
| 11 | +var ( |
| 12 | + tasksProcessed = promauto.NewCounterVec(prometheus.CounterOpts{ |
| 13 | + Namespace: "relay", |
| 14 | + Name: "tasks_processed_total", |
| 15 | + Help: "Number of tasks processed successfully.", |
| 16 | + }, []string{"queue", "type"}) |
| 17 | + |
| 18 | + tasksFailed = promauto.NewCounterVec(prometheus.CounterOpts{ |
| 19 | + Namespace: "relay", |
| 20 | + Name: "tasks_failed_total", |
| 21 | + Help: "Number of task executions that returned an error.", |
| 22 | + }, []string{"queue", "type"}) |
| 23 | + |
| 24 | + tasksRetried = promauto.NewCounterVec(prometheus.CounterOpts{ |
| 25 | + Namespace: "relay", |
| 26 | + Name: "tasks_retried_total", |
| 27 | + Help: "Number of tasks scheduled for retry.", |
| 28 | + }, []string{"queue", "type"}) |
| 29 | + |
| 30 | + tasksArchived = promauto.NewCounterVec(prometheus.CounterOpts{ |
| 31 | + Namespace: "relay", |
| 32 | + Name: "tasks_archived_total", |
| 33 | + Help: "Number of tasks moved to the archive after exhausting retries.", |
| 34 | + }, []string{"queue", "type"}) |
| 35 | + |
| 36 | + tasksInProgress = promauto.NewGaugeVec(prometheus.GaugeOpts{ |
| 37 | + Namespace: "relay", |
| 38 | + Name: "tasks_in_progress", |
| 39 | + Help: "Number of tasks currently being processed.", |
| 40 | + }, []string{"queue"}) |
| 41 | + |
| 42 | + processingDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{ |
| 43 | + Namespace: "relay", |
| 44 | + Name: "task_duration_seconds", |
| 45 | + Help: "Time spent processing a task.", |
| 46 | + Buckets: prometheus.DefBuckets, |
| 47 | + }, []string{"queue", "type"}) |
| 48 | +) |
| 49 | + |
| 50 | +func MetricsHandler() http.Handler { |
| 51 | + return promhttp.Handler() |
| 52 | +} |
0 commit comments