Skip to content

Commit

Permalink
Improve reporting of some chunk errors (grafana#1789)
Browse files Browse the repository at this point in the history
%q is better than '%v' because it will show unprintable characters as escape sequences.

Signed-off-by: Bryan Boreham <bryan@weave.works>
  • Loading branch information
bboreham authored and gouthamve committed Nov 11, 2019
1 parent 4bed557 commit 213b8d1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion chunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func (c *Chunk) Decode(decodeContext *DecodeContext, input []byte) error {
metadataRead := len(input) - r.Len()
// Older versions of Cortex included the initial length word; newer versions do not.
if !(metadataRead == int(metadataLen) || metadataRead == int(metadataLen)+4) {
return ErrMetadataLength
return errors.Wrapf(ErrMetadataLength, "expected %d, got %d", metadataLen, metadataRead)
}

// Next, confirm the chunks matches what we expected. Easiest way to do this
Expand Down
2 changes: 1 addition & 1 deletion schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func parseRangeValueType(rangeValue []byte) (int, error) {
return SeriesRangeValue, nil

default:
return 0, fmt.Errorf("unrecognised range value type. version: '%v'", string(components[3]))
return 0, fmt.Errorf("unrecognised range value type. version: %q", string(components[3]))
}
}

Expand Down
6 changes: 3 additions & 3 deletions schema_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func parseMetricNameRangeValue(rangeValue []byte, value []byte) (model.LabelValu
return model.LabelValue(value), nil

default:
return "", fmt.Errorf("unrecognised metricNameRangeKey version: '%v'", string(components[3]))
return "", fmt.Errorf("unrecognised metricNameRangeKey version: %q", string(components[3]))
}
}

Expand All @@ -160,7 +160,7 @@ func parseSeriesRangeValue(rangeValue []byte, value []byte) (model.Metric, error
return series, nil

default:
return nil, fmt.Errorf("unrecognised seriesRangeKey version: '%v'", string(components[3]))
return nil, fmt.Errorf("unrecognised seriesRangeKey version: %q", string(components[3]))
}
}

Expand Down Expand Up @@ -232,7 +232,7 @@ func parseChunkTimeRangeValue(rangeValue []byte, value []byte) (
return

default:
err = fmt.Errorf("unrecognised chunkTimeRangeKey version: '%v'", string(components[3]))
err = fmt.Errorf("unrecognised chunkTimeRangeKey version: %q", string(components[3]))
return
}
}

0 comments on commit 213b8d1

Please sign in to comment.