saveQueueMetrics observes metrics for each starr app queue request.
(size int, start time.Time, app starr.App, url string, err error)
| 77 | |
| 78 | // saveQueueMetrics observes metrics for each starr app queue request. |
| 79 | func (u *Unpackerr) saveQueueMetrics(size int, start time.Time, app starr.App, url string, err error) { |
| 80 | if err != nil { |
| 81 | u.Errorf("%s (%s): %v", app, url, err) |
| 82 | } |
| 83 | |
| 84 | if u.metrics == nil { |
| 85 | return |
| 86 | } |
| 87 | |
| 88 | if err != nil { |
| 89 | u.metrics.AppQueueErr.WithLabelValues(string(app), url).Inc() |
| 90 | } |
| 91 | |
| 92 | u.metrics.AppQueueGet.WithLabelValues(string(app), url).Inc() |
| 93 | u.metrics.AppQueues.WithLabelValues(string(app), url).Set(float64(size)) |
| 94 | u.metrics.AppRequests.WithLabelValues(string(app), url).Set(time.Since(start).Seconds()) |
| 95 | } |
| 96 | |
| 97 | // setupMetrics is called once on startup if metrics are enabled. |
| 98 | func (u *Unpackerr) setupMetrics() { |
no test coverage detected