vitessio/vitess · error
GaugesWithMultiLabels: wrong number of values in Set
Error message
GaugesWithMultiLabels: wrong number of values in Set
What it means
GaugesWithMultiLabels.Set panics when the names slice length doesn't match the number of labels the gauge was created with. The gauge joins names into a flat key (with no combined labels), so arity must match the declared labels exactly to produce a valid metric key.
Source
Thrown at go/stats/counters.go:392
labels: labels,
}
if name != "" {
publish(name, t)
}
return t
}
// GetLabelName returns a label name using the provided values.
func (mg *GaugesWithMultiLabels) GetLabelName(names ...string) string {
return safeJoinLabels(names, nil)
}
// Set sets the value of a named counter.
// len(names) must be equal to len(Labels).
func (mg *GaugesWithMultiLabels) Set(names []string, value int64) {
if len(names) != len(mg.labels) {
panic("GaugesWithMultiLabels: wrong number of values in Set")
}
mg.set(safeJoinLabels(names, nil), value)
}
// ResetKey resets a specific key.
//
// It is the equivalent of `Reset(names)` except that it expects the key to
// be obtained from the internal counters map.
//
// This is useful when you range over all internal counts and you want to reset
// specific keys.
func (mg *GaugesWithMultiLabels) ResetKey(key string) {
mg.set(key, 0)
}
// GaugesFuncWithMultiLabels is a wrapper around CountersFuncWithMultiLabels
// for values that go up/down for implementations (like Prometheus) that
// need to differ between Counters and Gauges.View on GitHub (pinned to 01a25a7d17)
Solutions
- Ensure the Set call passes exactly one value per declared label, in order
- Sync updateTableIndexMetrics (or your caller) with the gauge's label definition after any metric schema change
- Validate/skip with a warning when label values can't be fully populated instead of passing a short slice
Example fix
// before
mg.Set([]string{table}, 1) // gauge declares [keyspace, table] -> panics
// after
mg.Set([]string{keyspace, table}, 1) Defensive patterns
Strategy: validation
Validate before calling
if len(names) == len(mg.Labels()) {
mg.Set(names, value)
} Prevention
- Keep updateTableIndexMetrics and the gauge definition in the same file/PR scope
- Build label slices from the declared label list, not ad-hoc literals
- Skip-and-log when metadata can't supply all labels
When it happens
Trigger: Calling mg.Set(names, value) with len(names) != len(mg.labels). The known caller updateTableIndexMetrics passes label values derived from table metadata; if the gauge's label definition and that call site diverge, this panics.
Common situations: Vindex/table-governor metrics where the label set changed (e.g. adding a keyspace label) but one side wasn't updated; dynamic names built from optional metadata fields.
Related errors
- CountersWithMultiLabels: wrong number of values in Add
- CountersWithMultiLabels: wrong number of values in Reset
- You've already registered a function
- nil not allowed
- interval too small
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/2732e49c96e134d8.
Report an issue: GitHub.