Skip to content

Commit 0c81a7a

Browse files
committed
Fixes
1 parent 32f5245 commit 0c81a7a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

coderd/prometheusmetrics/insights/metricscollector.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
)
1717

1818
var (
19-
activeUsersDesc = prometheus.NewDesc("coderd_insights_active_users", "The number of active users of the template.", []string{"template_name"}, nil)
19+
templatesActiveUsersDesc = prometheus.NewDesc("coderd_insights_templates_active_users", "The number of active users of the template.", []string{"template_name"}, nil)
2020
)
2121

2222
type MetricsCollector struct {
@@ -101,6 +101,7 @@ func (mc *MetricsCollector) Run(ctx context.Context) (func(), error) {
101101

102102
templateNames := onlyTemplateNames(templates)
103103

104+
// Refresh the collector state
104105
mc.data.Store(&insightsData{
105106
templates: templateInsights,
106107

@@ -127,7 +128,7 @@ func (mc *MetricsCollector) Run(ctx context.Context) (func(), error) {
127128
}
128129

129130
func (*MetricsCollector) Describe(descCh chan<- *prometheus.Desc) {
130-
descCh <- activeUsersDesc
131+
descCh <- templatesActiveUsersDesc
131132
}
132133

133134
func (mc *MetricsCollector) Collect(metricsCh chan<- prometheus.Metric) {
@@ -139,7 +140,7 @@ func (mc *MetricsCollector) Collect(metricsCh chan<- prometheus.Metric) {
139140
}
140141

141142
for _, templateRow := range data.templates {
142-
metricsCh <- prometheus.MustNewConstMetric(activeUsersDesc, prometheus.GaugeValue, float64(templateRow.ActiveUsers), data.templateNames[templateRow.TemplateID])
143+
metricsCh <- prometheus.MustNewConstMetric(templatesActiveUsersDesc, prometheus.GaugeValue, float64(templateRow.ActiveUsers), data.templateNames[templateRow.TemplateID])
143144
}
144145
}
145146

@@ -155,6 +156,7 @@ func uniqueTemplateIDs(templateInsights []database.GetTemplateInsightsByTemplate
155156
var i int
156157
for t := range tids {
157158
uniqueUUIDs[i] = t
159+
i++
158160
}
159161
return uniqueUUIDs
160162
}

0 commit comments

Comments
 (0)