mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-28 23:19:41 -08:00
debugging parser
This commit is contained in:
parent
f66850c0fe
commit
8d1f6ecd77
|
@ -21,7 +21,6 @@ import (
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/prometheus/common/model"
|
|
||||||
"github.com/prometheus/prometheus/model/exemplar"
|
"github.com/prometheus/prometheus/model/exemplar"
|
||||||
"github.com/prometheus/prometheus/model/labels"
|
"github.com/prometheus/prometheus/model/labels"
|
||||||
)
|
)
|
||||||
|
@ -302,10 +301,10 @@ foo_total 17.0 1520879607.789 # {id="counter-test"} 5`
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUTF8OpenMetricsParse(t *testing.T) {
|
func TestUTF8OpenMetricsParse(t *testing.T) {
|
||||||
model.NameValidationScheme = model.UTF8Validation
|
// model.NameValidationScheme = model.UTF8Validation
|
||||||
defer func(){
|
// defer func(){
|
||||||
model.NameValidationScheme = model.LegacyValidation
|
// model.NameValidationScheme = model.LegacyValidation
|
||||||
}()
|
// }()
|
||||||
|
|
||||||
input := `# HELP "go.gc_duration_seconds" A summary of the GC invocation durations.
|
input := `# HELP "go.gc_duration_seconds" A summary of the GC invocation durations.
|
||||||
# TYPE "go.gc_duration_seconds" summary
|
# TYPE "go.gc_duration_seconds" summary
|
||||||
|
|
|
@ -219,10 +219,10 @@ testmetric{label="\"bar\""} 1`
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUTF8PromParse(t *testing.T) {
|
func TestUTF8PromParse(t *testing.T) {
|
||||||
model.NameValidationScheme = model.UTF8Validation
|
// model.NameValidationScheme = model.UTF8Validation
|
||||||
defer func() {
|
// defer func() {
|
||||||
model.NameValidationScheme = model.LegacyValidation
|
// model.NameValidationScheme = model.LegacyValidation
|
||||||
}()
|
// }()
|
||||||
|
|
||||||
input := `# HELP "go.gc_duration_seconds" A summary of the GC invocation durations.
|
input := `# HELP "go.gc_duration_seconds" A summary of the GC invocation durations.
|
||||||
# TYPE "go.gc_duration_seconds" summary
|
# TYPE "go.gc_duration_seconds" summary
|
||||||
|
|
|
@ -586,7 +586,10 @@ label_matcher : IDENTIFIER match_op STRING
|
||||||
| string_identifier match_op STRING
|
| string_identifier match_op STRING
|
||||||
{ $$ = yylex.(*parser).newLabelMatcher($1, $2, $3); }
|
{ $$ = yylex.(*parser).newLabelMatcher($1, $2, $3); }
|
||||||
| string_identifier
|
| string_identifier
|
||||||
{ $$ = yylex.(*parser).newMetricNameMatcher($1); }
|
{
|
||||||
|
// metric name matcher!
|
||||||
|
$$ = yylex.(*parser).newMetricNameMatcher($1);
|
||||||
|
}
|
||||||
| IDENTIFIER match_op error
|
| IDENTIFIER match_op error
|
||||||
{ yylex.(*parser).unexpected("label matching", "string"); $$ = nil}
|
{ yylex.(*parser).unexpected("label matching", "string"); $$ = nil}
|
||||||
| IDENTIFIER error
|
| IDENTIFIER error
|
||||||
|
@ -609,7 +612,10 @@ metric : metric_identifier label_set
|
||||||
metric_identifier: AVG | BOTTOMK | BY | COUNT | COUNT_VALUES | GROUP | IDENTIFIER | LAND | LOR | LUNLESS | MAX | METRIC_IDENTIFIER | MIN | OFFSET | QUANTILE | STDDEV | STDVAR | SUM | TOPK | WITHOUT | START | END;
|
metric_identifier: AVG | BOTTOMK | BY | COUNT | COUNT_VALUES | GROUP | IDENTIFIER | LAND | LOR | LUNLESS | MAX | METRIC_IDENTIFIER | MIN | OFFSET | QUANTILE | STDDEV | STDVAR | SUM | TOPK | WITHOUT | START | END;
|
||||||
|
|
||||||
label_set : LEFT_BRACE label_set_list RIGHT_BRACE
|
label_set : LEFT_BRACE label_set_list RIGHT_BRACE
|
||||||
{ $$ = labels.New($2...) }
|
{
|
||||||
|
// LEFT_BRACE label_set_list RIGHT_BRACE
|
||||||
|
$$ = labels.New($2...)
|
||||||
|
}
|
||||||
| LEFT_BRACE label_set_list COMMA RIGHT_BRACE
|
| LEFT_BRACE label_set_list COMMA RIGHT_BRACE
|
||||||
{ $$ = labels.New($2...) }
|
{ $$ = labels.New($2...) }
|
||||||
| LEFT_BRACE RIGHT_BRACE
|
| LEFT_BRACE RIGHT_BRACE
|
||||||
|
@ -628,7 +634,17 @@ label_set_list : label_set_list COMMA label_set_item
|
||||||
;
|
;
|
||||||
|
|
||||||
label_set_item : IDENTIFIER EQL STRING
|
label_set_item : IDENTIFIER EQL STRING
|
||||||
{ $$ = labels.Label{Name: $1.Val, Value: yylex.(*parser).unquoteString($3.Val) } }
|
{
|
||||||
|
// ident eq string
|
||||||
|
$$ = labels.Label{Name: $1.Val, Value: yylex.(*parser).unquoteString($3.Val) } }
|
||||||
|
// | STRING EQL STRING
|
||||||
|
// {
|
||||||
|
// // string eq string
|
||||||
|
// $$ = labels.Label{Name: yylex.(*parser).unquoteString($3.Val), Value: yylex.(*parser).unquoteString($3.Val) } }
|
||||||
|
// | STRING
|
||||||
|
// {
|
||||||
|
// // looks good?
|
||||||
|
// $$ = labels.Label{Name: labels.MetricName, Value: yylex.(*parser).unquoteString($1.Val) } }
|
||||||
| IDENTIFIER EQL error
|
| IDENTIFIER EQL error
|
||||||
{ yylex.(*parser).unexpected("label set", "string"); $$ = labels.Label{}}
|
{ yylex.(*parser).unexpected("label set", "string"); $$ = labels.Label{}}
|
||||||
| IDENTIFIER error
|
| IDENTIFIER error
|
||||||
|
@ -909,6 +925,7 @@ string_literal : STRING
|
||||||
|
|
||||||
string_identifier : STRING
|
string_identifier : STRING
|
||||||
{
|
{
|
||||||
|
// string_identifier
|
||||||
$$ = Item{
|
$$ = Item{
|
||||||
Typ: METRIC_IDENTIFIER,
|
Typ: METRIC_IDENTIFIER,
|
||||||
Pos: $1.PositionRange().Start,
|
Pos: $1.PositionRange().Start,
|
||||||
|
|
|
@ -1458,6 +1458,7 @@ yydefault:
|
||||||
case 93:
|
case 93:
|
||||||
yyDollar = yyS[yypt-1 : yypt+1]
|
yyDollar = yyS[yypt-1 : yypt+1]
|
||||||
{
|
{
|
||||||
|
// metric name matcher!
|
||||||
yyVAL.matcher = yylex.(*parser).newMetricNameMatcher(yyDollar[1].item)
|
yyVAL.matcher = yylex.(*parser).newMetricNameMatcher(yyDollar[1].item)
|
||||||
}
|
}
|
||||||
case 94:
|
case 94:
|
||||||
|
@ -1493,6 +1494,7 @@ yydefault:
|
||||||
case 121:
|
case 121:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
{
|
{
|
||||||
|
// LEFT_BRACE label_set_list RIGHT_BRACE
|
||||||
yyVAL.labels = labels.New(yyDollar[2].lblList...)
|
yyVAL.labels = labels.New(yyDollar[2].lblList...)
|
||||||
}
|
}
|
||||||
case 122:
|
case 122:
|
||||||
|
@ -1529,6 +1531,7 @@ yydefault:
|
||||||
case 128:
|
case 128:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
{
|
{
|
||||||
|
// ident eq string
|
||||||
yyVAL.label = labels.Label{Name: yyDollar[1].item.Val, Value: yylex.(*parser).unquoteString(yyDollar[3].item.Val)}
|
yyVAL.label = labels.Label{Name: yyDollar[1].item.Val, Value: yylex.(*parser).unquoteString(yyDollar[3].item.Val)}
|
||||||
}
|
}
|
||||||
case 129:
|
case 129:
|
||||||
|
@ -1829,6 +1832,7 @@ yydefault:
|
||||||
case 226:
|
case 226:
|
||||||
yyDollar = yyS[yypt-1 : yypt+1]
|
yyDollar = yyS[yypt-1 : yypt+1]
|
||||||
{
|
{
|
||||||
|
// string_identifier
|
||||||
yyVAL.item = Item{
|
yyVAL.item = Item{
|
||||||
Typ: METRIC_IDENTIFIER,
|
Typ: METRIC_IDENTIFIER,
|
||||||
Pos: yyDollar[1].item.PositionRange().Start,
|
Pos: yyDollar[1].item.PositionRange().Start,
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue