From 4220737a52da7ab6c9346b12d5a5d7bedbcd641d Mon Sep 17 00:00:00 2001 From: Owen Diehl Date: Tue, 9 Jul 2024 14:41:26 -0700 Subject: [PATCH] feat(exporter): include boolean values in limit exporter (#13466) --- pkg/validation/exporter.go | 6 ++++++ pkg/validation/exporter_test.go | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/validation/exporter.go b/pkg/validation/exporter.go index 78cd13a1dad84..0a5ffc863d5ad 100644 --- a/pkg/validation/exporter.go +++ b/pkg/validation/exporter.go @@ -56,6 +56,12 @@ func (oe *OverridesExporter) Collect(ch chan<- prometheus.Metric) { return float64(val.Field(i).Uint()), true case float64: return val.Field(i).Float(), true + case bool: + v := 0.0 + if val.Field(i).Bool() { + v = 1.0 + } + return v, true default: return 0, false } diff --git a/pkg/validation/exporter_test.go b/pkg/validation/exporter_test.go index a7a51327599c1..59b4537533e53 100644 --- a/pkg/validation/exporter_test.go +++ b/pkg/validation/exporter_test.go @@ -35,12 +35,13 @@ func TestOverridesExporter_noConfig(t *testing.T) { func TestOverridesExporter_withConfig(t *testing.T) { tenantLimits := map[string]*Limits{ "tenant-a": { - MaxQueriersPerTenant: 5, + MaxQueriersPerTenant: 5, + BloomCompactorEnabled: true, }, } overrides, _ := NewOverrides(Limits{}, newMockTenantLimits(tenantLimits)) exporter := NewOverridesExporter(overrides) count := testutil.CollectAndCount(exporter, "loki_overrides") - assert.Greater(t, count, 0) + assert.Equal(t, 2, count) require.Greater(t, testutil.CollectAndCount(exporter, "loki_overrides_defaults"), 0) }