@@ -24,10 +24,12 @@ import (
24
24
"github.com/coder/coder/v2/tailnet"
25
25
)
26
26
27
+ const defaultRefreshRate = time .Minute
28
+
27
29
// ActiveUsers tracks the number of users that have authenticated within the past hour.
28
30
func ActiveUsers (ctx context.Context , registerer prometheus.Registerer , db database.Store , duration time.Duration ) (func (), error ) {
29
31
if duration == 0 {
30
- duration = 5 * time . Minute
32
+ duration = defaultRefreshRate
31
33
}
32
34
33
35
gauge := prometheus .NewGauge (prometheus.GaugeOpts {
@@ -74,7 +76,7 @@ func ActiveUsers(ctx context.Context, registerer prometheus.Registerer, db datab
74
76
// Workspaces tracks the total number of workspaces with labels on status.
75
77
func Workspaces (ctx context.Context , logger slog.Logger , registerer prometheus.Registerer , db database.Store , duration time.Duration ) (func (), error ) {
76
78
if duration == 0 {
77
- duration = 5 * time . Minute
79
+ duration = defaultRefreshRate
78
80
}
79
81
80
82
workspaceStatuses := prometheus .NewGaugeVec (prometheus.GaugeOpts {
@@ -193,7 +195,7 @@ func Workspaces(ctx context.Context, logger slog.Logger, registerer prometheus.R
193
195
// Agents tracks the total number of workspaces with labels on status.
194
196
func Agents (ctx context.Context , logger slog.Logger , registerer prometheus.Registerer , db database.Store , coordinator * atomic.Pointer [tailnet.Coordinator ], derpMapFn func () * tailcfg.DERPMap , agentInactiveDisconnectTimeout , duration time.Duration ) (func (), error ) {
195
197
if duration == 0 {
196
- duration = 1 * time . Minute
198
+ duration = defaultRefreshRate
197
199
}
198
200
199
201
agentsGauge := NewCachedGaugeVec (prometheus .NewGaugeVec (prometheus.GaugeOpts {
@@ -382,7 +384,7 @@ func Agents(ctx context.Context, logger slog.Logger, registerer prometheus.Regis
382
384
383
385
func AgentStats (ctx context.Context , logger slog.Logger , registerer prometheus.Registerer , db database.Store , initialCreateAfter time.Time , duration time.Duration , aggregateByLabels []string ) (func (), error ) {
384
386
if duration == 0 {
385
- duration = 1 * time . Minute
387
+ duration = defaultRefreshRate
386
388
}
387
389
388
390
if len (aggregateByLabels ) == 0 {
0 commit comments