mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-14 06:06:38 +01:00
Session report collection and report templates (#981)
* wip: notification stats * make report notifications optional * linting/documentation fixes * linting/documentation fixes * merge types.Container and container.Interface * smaller naming/format fixes * use typed image/container IDs * simplify notifier and update tests * add missed doc comments * lint fixes * remove unused constructors * rename old/new current/latest
This commit is contained in:
parent
d0ecc23d72
commit
e3dd8d688a
32 changed files with 853 additions and 598 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package metrics
|
||||
|
||||
import (
|
||||
"github.com/containrrr/watchtower/pkg/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
)
|
||||
|
|
@ -24,6 +25,16 @@ type Metrics struct {
|
|||
skipped prometheus.Counter
|
||||
}
|
||||
|
||||
// NewMetric returns a Metric with the counts taken from the appropriate types.Report fields
|
||||
func NewMetric(report types.Report) *Metric {
|
||||
return &Metric{
|
||||
Scanned: len(report.Scanned()),
|
||||
// Note: This is for backwards compatibility. ideally, stale containers should be counted separately
|
||||
Updated: len(report.Updated()) + len(report.Stale()),
|
||||
Failed: len(report.Failed()),
|
||||
}
|
||||
}
|
||||
|
||||
// QueueIsEmpty checks whether any messages are enqueued in the channel
|
||||
func (metrics *Metrics) QueueIsEmpty() bool {
|
||||
return len(metrics.channel) == 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue