Skip to content

Commit 29a8702

Browse files
committed
Address PR comments
1 parent b7011ae commit 29a8702

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

cli/server.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,10 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
733733
defer cancelMetricsAggregator()
734734

735735
options.UpdateAgentMetrics = metricsAggregator.Update
736-
options.PrometheusRegistry.MustRegister(metricsAggregator)
736+
err = options.PrometheusRegistry.Register(metricsAggregator)
737+
if err != nil {
738+
return xerrors.Errorf("can't register metrics aggregator as collector: %w", err)
739+
}
737740
}
738741

739742
//nolint:revive

coderd/prometheusmetrics/aggregator.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const (
1717
// messages. This is because a registry cannot have conflicting
1818
// help messages for the same metric in a "gather". If our coder agents are
1919
// on different versions, this is a possible scenario.
20-
metricHelpForAgent = "Metric is forwarded from workspace agent connected to this instance of coderd."
20+
metricHelpForAgent = "Metrics are forwarded from workspace agents connected to this instance of coderd."
2121
)
2222

2323
const (
@@ -172,14 +172,13 @@ func (ma *MetricsAggregator) Run(ctx context.Context) func() {
172172

173173
if hasExpiredMetrics {
174174
var j int
175-
fresh := make([]annotatedMetric, len(ma.queue))
175+
fresh := make([]annotatedMetric, 0, len(ma.queue))
176176
for _, m := range ma.queue {
177177
if m.expiryDate.After(now) {
178178
fresh[j] = m
179179
j++
180180
}
181181
}
182-
fresh = fresh[:j]
183182
ma.queue = fresh
184183
}
185184

0 commit comments

Comments
 (0)