Skip to content

Commit 7e0c8f0

Browse files
committed
Linting
Signed-off-by: Danny Kopping <danny@coder.com>
1 parent 60edab9 commit 7e0c8f0

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

coderd/prometheusmetrics/aggregator.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ import (
77
"strings"
88
"time"
99

10-
"github.com/coder/coder/v2/coderd/agentmetrics"
1110
"github.com/prometheus/client_golang/prometheus"
1211
"github.com/prometheus/common/model"
1312
"golang.org/x/xerrors"
1413

14+
"github.com/coder/coder/v2/coderd/agentmetrics"
15+
1516
"cdr.dev/slog"
1617

1718
agentproto "github.com/coder/coder/v2/agent/proto"
@@ -253,7 +254,6 @@ func newLabelAggregator(size int) *labelAggregator {
253254
func (a *labelAggregator) aggregate(am annotatedMetric, labels []string) error {
254255
// Use a LabelSet because it can give deterministic fingerprints of label combinations regardless of map ordering.
255256
labelSet := make(model.LabelSet, len(labels))
256-
labelValues := make([]string, 0, len(labels))
257257

258258
for _, label := range labels {
259259
val, err := am.getFieldByLabel(label)
@@ -262,7 +262,6 @@ func (a *labelAggregator) aggregate(am annotatedMetric, labels []string) error {
262262
}
263263

264264
labelSet[model.LabelName(label)] = model.LabelValue(val)
265-
labelValues = append(labelValues, val)
266265
}
267266

268267
// Memoize based on the metric name & the unique combination of labels.
@@ -286,11 +285,12 @@ func (a *labelAggregator) aggregate(am annotatedMetric, labels []string) error {
286285
return nil
287286
}
288287

289-
func (a *labelAggregator) toMetrics() (out []annotatedMetric) {
288+
func (a *labelAggregator) listMetrics() []annotatedMetric {
289+
var out []annotatedMetric
290290
for _, am := range a.metrics {
291291
out = append(out, am)
292292
}
293-
return
293+
return out
294294
}
295295

296296
func (ma *MetricsAggregator) Run(ctx context.Context) func() {
@@ -337,7 +337,7 @@ func (ma *MetricsAggregator) Run(ctx context.Context) func() {
337337

338338
// If custom aggregation labels have not been chosen, generate Prometheus metrics without any pre-aggregation.
339339
// This results in higher cardinality, but may be desirable in larger deployments.
340-
// Default behaviour.
340+
// Default behavior.
341341
if len(ma.aggregateByLabels) == 0 {
342342
for _, m := range ma.store {
343343
// Aggregate by all available metrics.
@@ -355,7 +355,7 @@ func (ma *MetricsAggregator) Run(ctx context.Context) func() {
355355
}
356356
}
357357

358-
input = la.toMetrics()
358+
input = la.listMetrics()
359359
}
360360

361361
for _, m := range input {

codersdk/deployment.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ import (
1212
"strings"
1313
"time"
1414

15-
"github.com/coder/coder/v2/coderd/agentmetrics"
1615
"golang.org/x/mod/semver"
1716
"golang.org/x/xerrors"
1817

18+
"github.com/coder/coder/v2/coderd/agentmetrics"
19+
1920
"github.com/coreos/go-oidc/v3/oidc"
2021

2122
"github.com/coder/coder/v2/buildinfo"
@@ -954,7 +955,7 @@ when required by your organization's security policy.`,
954955
},
955956
{
956957
Name: "Prometheus Aggregate Agent Stats By",
957-
Description: fmt.Sprintf("When collecting agent stats, aggregate metrics by a given set of comma-separated labels to reduce cardinality. Accepted values are %q", AcceptedMetricAggregationLabels),
958+
Description: fmt.Sprintf("When collecting agent stats, aggregate metrics by a given set of comma-separated labels to reduce cardinality. Accepted values are %q.", AcceptedMetricAggregationLabels),
958959
Flag: "prometheus-aggregate-agent-stats-by",
959960
Env: "CODER_PROMETHEUS_AGGREGATE_AGENT_STATS_BY",
960961
Value: clibase.Validate(&c.Prometheus.AggregateAgentStatsBy, func(value *clibase.StringArray) error {

0 commit comments

Comments
 (0)