Skip to content

Commit c31b498

Browse files
committed
Change default refresh rates of Agent and Workspaces calls which seemed inappropriately slow
Signed-off-by: Danny Kopping <danny@coder.com>
1 parent 2ed42a3 commit c31b498

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

coderd/prometheusmetrics/prometheusmetrics.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ import (
2424
"github.com/coder/coder/v2/tailnet"
2525
)
2626

27+
const defaultRefreshRate = time.Minute
28+
2729
// ActiveUsers tracks the number of users that have authenticated within the past hour.
2830
func ActiveUsers(ctx context.Context, registerer prometheus.Registerer, db database.Store, duration time.Duration) (func(), error) {
2931
if duration == 0 {
30-
duration = 5 * time.Minute
32+
duration = defaultRefreshRate
3133
}
3234

3335
gauge := prometheus.NewGauge(prometheus.GaugeOpts{
@@ -74,7 +76,7 @@ func ActiveUsers(ctx context.Context, registerer prometheus.Registerer, db datab
7476
// Workspaces tracks the total number of workspaces with labels on status.
7577
func Workspaces(ctx context.Context, logger slog.Logger, registerer prometheus.Registerer, db database.Store, duration time.Duration) (func(), error) {
7678
if duration == 0 {
77-
duration = 5 * time.Minute
79+
duration = defaultRefreshRate
7880
}
7981

8082
workspaceStatuses := prometheus.NewGaugeVec(prometheus.GaugeOpts{
@@ -193,7 +195,7 @@ func Workspaces(ctx context.Context, logger slog.Logger, registerer prometheus.R
193195
// Agents tracks the total number of workspaces with labels on status.
194196
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) {
195197
if duration == 0 {
196-
duration = 1 * time.Minute
198+
duration = defaultRefreshRate
197199
}
198200

199201
agentsGauge := NewCachedGaugeVec(prometheus.NewGaugeVec(prometheus.GaugeOpts{
@@ -382,7 +384,7 @@ func Agents(ctx context.Context, logger slog.Logger, registerer prometheus.Regis
382384

383385
func AgentStats(ctx context.Context, logger slog.Logger, registerer prometheus.Registerer, db database.Store, initialCreateAfter time.Time, duration time.Duration, aggregateByLabels []string) (func(), error) {
384386
if duration == 0 {
385-
duration = 1 * time.Minute
387+
duration = defaultRefreshRate
386388
}
387389

388390
if len(aggregateByLabels) == 0 {

0 commit comments

Comments
 (0)