Skip to content

Commit

Permalink
feat(exporter): include boolean values in limit exporter (#13466)
Browse files Browse the repository at this point in the history
  • Loading branch information
owen-d committed Jul 9, 2024
1 parent e08b4a7 commit 4220737
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions pkg/validation/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/validation/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 4220737

Please sign in to comment.