Fix off-by-one bug in NewFingerprintFromMetric().

This commit is contained in:
Julius Volz 2013-04-09 02:33:17 +02:00
parent ca2a31c48b
commit 0230dbf305
2 changed files with 9 additions and 2 deletions

View file

@ -94,7 +94,7 @@ func NewFingerprintFromMetric(metric Metric) (f Fingerprint) {
firstCharacterOfFirstLabelName = labelName[0:1]
}
if i == labelLength-1 {
lastCharacterOfLastLabelValue = string(labelValue[labelValueLength-2 : labelValueLength-1])
lastCharacterOfLastLabelValue = string(labelValue[labelValueLength-1 : labelValueLength])
}
summer.Write([]byte(labelName))

View file

@ -35,9 +35,16 @@ func testMetric(t test.Tester) {
"occupation": "robot",
"manufacturer": "westinghouse",
},
rowkey: "04776841610193542734-f-56-o",
rowkey: "04776841610193542734-f-56-t",
hash: 4776841610193542734,
},
{
input: map[string]string{
"x": "y",
},
rowkey: "01306929544689993150-x-2-y",
hash: 1306929544689993150,
},
}
for i, scenario := range scenarios {