Merge pull request #112 from prometheus/julius-allow-oneletter-metrics

Allow single-letter identifiers (metric and label names).
This commit is contained in:
Matt T. Proud 2013-03-28 10:39:40 -07:00
commit 2116c7ff8c
4 changed files with 17 additions and 2 deletions

View File

@ -45,7 +45,7 @@ AVG|SUM|MAX|MIN { yylval.str = yytext; return AGGR_OP }
[*/%] { yylval.str = yytext; return MULT_OP }
{D}+{U} { yylval.str = yytext; return DURATION }
{L}({L}|{D})+ { yylval.str = yytext; return IDENTIFIER }
{L}({L}|{D})* { yylval.str = yytext; return IDENTIFIER }
\-?{D}+(\.{D}*)? { num, err := strconv.ParseFloat(yytext, 32);
if (err != nil && err.(*strconv.NumError).Err == strconv.ErrSyntax) {

View File

@ -411,7 +411,7 @@ var yyrules []yyrule = []yyrule{{regexp.MustCompile("[^\\n]"), nil, []yystartcon
return yyactionreturn{DURATION, yyRT_USER_RETURN}
}
return yyactionreturn{0, yyRT_FALLTHROUGH}
}}, {regexp.MustCompile("([a-zA-Z_:])(([a-zA-Z_:])|([0-9]))+"), nil, []yystartcondition{}, false, func() (yyar yyactionreturn) {
}}, {regexp.MustCompile("([a-zA-Z_:])(([a-zA-Z_:])|([0-9]))*"), nil, []yystartcondition{}, false, func() (yyar yyactionreturn) {
defer func() {
if r := recover(); r != nil {
if r != "yyREJECT" {

View File

@ -179,6 +179,13 @@ var expressionTests = []struct {
},
fullRanges: 8,
intervalRanges: 0,
}, {
expr: "x{y='testvalue'}",
output: []string{
"x{y='testvalue'} => 100 @[%v]",
},
fullRanges: 0,
intervalRanges: 1,
// Invalid expressions that should fail to parse.
}, {
expr: "",

View File

@ -140,6 +140,14 @@ var testMatrix = ast.Matrix{
},
Values: getTestValueStream(0, 800, 80),
},
// Single-letter metric and label names.
{
Metric: model.Metric{
model.MetricNameLabel: "x",
"y": "testvalue",
},
Values: getTestValueStream(0, 100, 10),
},
}
var testVector = getTestVectorFromTestMatrix(testMatrix)