vitessio/vitess · error
MultiTimings: wrong number of values in Record
Error message
MultiTimings: wrong number of values in Record
What it means
Like Add, MultiTimings.Record derives the histogram key from the tuple of label values, so it validates that names has exactly one entry per declared label and panics otherwise. Record is the time.Time-based variant used when the caller captured a start time earlier.
Source
Thrown at go/stats/timings.go:242
// Labels returns descriptions of the parts of each compound category name.
func (mt *MultiTimings) Labels() []string {
return mt.labels
}
// Add will add a new value to the named histogram.
func (mt *MultiTimings) Add(names []string, elapsed time.Duration) {
if len(names) != len(mt.labels) {
panic("MultiTimings: wrong number of values in Add")
}
mt.Timings.Add(safeJoinLabels(names, mt.combinedLabels), elapsed)
}
// Record is a convenience function that records completion
// timing data based on the provided start time of an event.
func (mt *MultiTimings) Record(names []string, startTime time.Time) {
if len(names) != len(mt.labels) {
panic("MultiTimings: wrong number of values in Record")
}
mt.Timings.Record(safeJoinLabels(names, mt.combinedLabels), startTime)
}
// Cutoffs returns the cutoffs used in the component histograms.
// Do not change the returned slice.
func (mt *MultiTimings) Cutoffs() []int64 {
return bucketCutoffs
}
View on GitHub (pinned to 01a25a7d17)
Solutions
- Pass exactly one string per declared label: mt.Record([]string{keyspace, table}, start).
- Grep all Record call sites when changing the number of labels in NewMultiTimings.
- Build the names slice where the dimensions are known, and assert len(names) == len(mt.labels) in tests.
Example fix
// before (labels = ["Keyspace", "Table"])
mt.Record([]string{ks}, start) // panics: wrong number of values
// after
mt.Record([]string{ks, table}, start) Defensive patterns
Strategy: validation
Validate before calling
if len(labelValues) != len(mt.Labels()) {
return fmt.Errorf("MultiTimings.Record expects %d values, got %d", len(mt.Labels()), len(labelValues))
}
mt.Record(labelValues, start) Prevention
- Keep Record and Add call sites using one shared helper that builds the label tuple.
- Grep for Record when adding a dimension to a MultiTimings.
- Cover both Record and Add in unit tests after label changes.
When it happens
Trigger: Calling mt.Record(names, startTime) where len(names) != len(mt.labels), typically after adding a dimension to the MultiTimings without updating Record call sites.
Common situations: Refactoring Timings.Record to MultiTimings.Record while keeping a single-element slice; label count changed at construction (new dimension added) but Record callers not updated; forgetting that Record requires the same arity as Add.
Related errors
- MultiTimings: wrong number of values in Add
- CountersWithMultiLabels: wrong number of values in Add
- CountersWithMultiLabels: wrong number of values in Reset
- GaugesWithMultiLabels: wrong number of values in Set
- You've already registered a function
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/098ad862c28958e2.
Report an issue: GitHub.