Skip to content

Commit 49eb959

Browse files
authored
Merge pull request #258 from j-gourdon/queue-max-length
Fix: panic when max-length metrics are excluded
2 parents 0012bdd + 3aec9c2 commit 49eb959

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

exporter_queue.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,16 @@ func (e exporterQueue) Collect(ctx context.Context, ch chan<- prometheus.Metric)
215215
}
216216
e.stateMetric.WithLabelValues(append(labelValues, state)...).Set(1)
217217

218-
if f := collectLowerMetric("arguments.x-max-length", "effective_policy_definition.max-length", queue); f >= 0 {
219-
limitsGaugeVec["max-length"].WithLabelValues(labelValues...).Set(f)
218+
if _, ok := limitsGaugeVec["max-length"]; ok {
219+
if f := collectLowerMetric("arguments.x-max-length", "effective_policy_definition.max-length", queue); f >= 0 {
220+
limitsGaugeVec["max-length"].WithLabelValues(labelValues...).Set(f)
221+
}
220222
}
221-
if f := collectLowerMetric("arguments.x-max-length-bytes", "effective_policy_definition.max-length-bytes", queue); f >= 0 {
222-
limitsGaugeVec["max-length-bytes"].WithLabelValues(labelValues...).Set(f)
223+
224+
if _, ok := limitsGaugeVec["max-length-bytes"]; ok {
225+
if f := collectLowerMetric("arguments.x-max-length-bytes", "effective_policy_definition.max-length-bytes", queue); f >= 0 {
226+
limitsGaugeVec["max-length-bytes"].WithLabelValues(labelValues...).Set(f)
227+
}
223228
}
224229

225230
}

0 commit comments

Comments
 (0)