@@ -1264,32 +1264,36 @@ func TestConvertOpenTSDBResultsToSeriesResponse(t *testing.T) {
12641264
12651265func TestGetMatchingMetricNames (t * testing.T ) {
12661266 testCases := []struct {
1267- input storepb.LabelMatcher
1268- expectedOutput []string
1267+ input storepb.LabelMatcher
1268+ expectedOutput []string
1269+ periodCharacter string
12691270 }{
12701271 {
12711272 input : storepb.LabelMatcher {
12721273 Name : "tagk" ,
12731274 Type : storepb .LabelMatcher_EQ ,
12741275 Value : "tagv" ,
12751276 },
1276- expectedOutput : nil ,
1277+ expectedOutput : nil ,
1278+ periodCharacter : ":" ,
12771279 },
12781280 {
12791281 input : storepb.LabelMatcher {
12801282 Name : "__name__" ,
12811283 Type : storepb .LabelMatcher_NEQ ,
12821284 Value : "value" ,
12831285 },
1284- expectedOutput : nil ,
1286+ expectedOutput : nil ,
1287+ periodCharacter : ":" ,
12851288 },
12861289 {
12871290 input : storepb.LabelMatcher {
12881291 Name : "__name__" ,
12891292 Type : storepb .LabelMatcher_NRE ,
12901293 Value : "value" ,
12911294 },
1292- expectedOutput : nil ,
1295+ expectedOutput : nil ,
1296+ periodCharacter : ":" ,
12931297 },
12941298 {
12951299 input : storepb.LabelMatcher {
@@ -1300,6 +1304,7 @@ func TestGetMatchingMetricNames(t *testing.T) {
13001304 expectedOutput : []string {
13011305 "metric.name" ,
13021306 },
1307+ periodCharacter : ":" ,
13031308 },
13041309 {
13051310 input : storepb.LabelMatcher {
@@ -1314,6 +1319,7 @@ func TestGetMatchingMetricNames(t *testing.T) {
13141319 "tsd.rpc.received" ,
13151320 "tsd.rpc.unauthorized" ,
13161321 },
1322+ periodCharacter : ":" ,
13171323 },
13181324 {
13191325 input : storepb.LabelMatcher {
@@ -1326,6 +1332,41 @@ func TestGetMatchingMetricNames(t *testing.T) {
13261332 "cpu.irq" ,
13271333 "cpu.nice" ,
13281334 },
1335+ periodCharacter : ":" ,
1336+ },
1337+ {
1338+ input : storepb.LabelMatcher {
1339+ Name : "__name__" ,
1340+ Type : storepb .LabelMatcher_EQ ,
1341+ Value : "cpu:idle" ,
1342+ },
1343+ expectedOutput : []string {
1344+ "cpu.idle" ,
1345+ },
1346+ periodCharacter : ":" ,
1347+ },
1348+ {
1349+ input : storepb.LabelMatcher {
1350+ Name : "__name__" ,
1351+ Type : storepb .LabelMatcher_EQ ,
1352+ Value : "cpu__idle_time" ,
1353+ },
1354+ expectedOutput : []string {
1355+ "cpu.idle_time" ,
1356+ },
1357+ // '__' means '_' can still be passed through as an underscore
1358+ periodCharacter : "__" ,
1359+ },
1360+ {
1361+ input : storepb.LabelMatcher {
1362+ Name : "__name__" ,
1363+ Type : storepb .LabelMatcher_EQ ,
1364+ Value : "cpu.idle" ,
1365+ },
1366+ expectedOutput : []string {
1367+ "cpu.idle" ,
1368+ },
1369+ periodCharacter : "" ,
13291370 },
13301371 }
13311372
@@ -1343,7 +1384,7 @@ func TestGetMatchingMetricNames(t *testing.T) {
13431384 "tsd.rpc.received" ,
13441385 "tsd.rpc.unauthorized" ,
13451386 },
1346- periodCharacter : ":" ,
1387+ periodCharacter : test . periodCharacter ,
13471388 }
13481389 output , err := store .getMatchingMetricNames (test .input )
13491390
0 commit comments