Merge pull request #112 from prometheus/julius-allow-oneletter-metrics
Allow single-letter identifiers (metric and label names).
This commit is contained in:
commit
2116c7ff8c
|
@ -45,7 +45,7 @@ AVG|SUM|MAX|MIN { yylval.str = yytext; return AGGR_OP }
|
||||||
[*/%] { yylval.str = yytext; return MULT_OP }
|
[*/%] { yylval.str = yytext; return MULT_OP }
|
||||||
|
|
||||||
{D}+{U} { yylval.str = yytext; return DURATION }
|
{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);
|
\-?{D}+(\.{D}*)? { num, err := strconv.ParseFloat(yytext, 32);
|
||||||
if (err != nil && err.(*strconv.NumError).Err == strconv.ErrSyntax) {
|
if (err != nil && err.(*strconv.NumError).Err == strconv.ErrSyntax) {
|
||||||
|
|
|
@ -411,7 +411,7 @@ var yyrules []yyrule = []yyrule{{regexp.MustCompile("[^\\n]"), nil, []yystartcon
|
||||||
return yyactionreturn{DURATION, yyRT_USER_RETURN}
|
return yyactionreturn{DURATION, yyRT_USER_RETURN}
|
||||||
}
|
}
|
||||||
return yyactionreturn{0, yyRT_FALLTHROUGH}
|
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() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
if r != "yyREJECT" {
|
if r != "yyREJECT" {
|
||||||
|
|
|
@ -179,6 +179,13 @@ var expressionTests = []struct {
|
||||||
},
|
},
|
||||||
fullRanges: 8,
|
fullRanges: 8,
|
||||||
intervalRanges: 0,
|
intervalRanges: 0,
|
||||||
|
}, {
|
||||||
|
expr: "x{y='testvalue'}",
|
||||||
|
output: []string{
|
||||||
|
"x{y='testvalue'} => 100 @[%v]",
|
||||||
|
},
|
||||||
|
fullRanges: 0,
|
||||||
|
intervalRanges: 1,
|
||||||
// Invalid expressions that should fail to parse.
|
// Invalid expressions that should fail to parse.
|
||||||
}, {
|
}, {
|
||||||
expr: "",
|
expr: "",
|
||||||
|
|
|
@ -140,6 +140,14 @@ var testMatrix = ast.Matrix{
|
||||||
},
|
},
|
||||||
Values: getTestValueStream(0, 800, 80),
|
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)
|
var testVector = getTestVectorFromTestMatrix(testMatrix)
|
||||||
|
|
Loading…
Reference in New Issue