MCPcopy Create free account
hub / github.com/netdata/netdata / TestPromTextParser_parseToSeries

Function TestPromTextParser_parseToSeries

src/go/pkg/prometheus/parse_test.go:1391–1639  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1389}
1390
1391func TestPromTextParser_parseToSeries(t *testing.T) {
1392 tests := map[string]struct {
1393 input []byte
1394 want Series
1395 }{
1396 "All types": {
1397 input: []byte(`
1398# HELP test_gauge_metric_1 Test Gauge Metric 1
1399# TYPE test_gauge_metric_1 gauge
1400test_gauge_metric_1{label1="value1"} 11
1401test_gauge_no_meta_metric_1{label1="value1"} 11
1402# HELP test_counter_metric_1_total Test Counter Metric 1
1403# TYPE test_counter_metric_1_total counter
1404test_counter_metric_1_total{label1="value1"} 11
1405test_counter_no_meta_metric_1_total{label1="value1"} 11
1406# HELP test_summary_1_duration_microseconds Test Summary Metric 1
1407# TYPE test_summary_1_duration_microseconds summary
1408test_summary_1_duration_microseconds{label1="value1",quantile="0.5"} 4931.921
1409test_summary_1_duration_microseconds{label1="value1",quantile="0.9"} 4932.921
1410test_summary_1_duration_microseconds{label1="value1",quantile="0.99"} 4933.921
1411test_summary_1_duration_microseconds_sum{label1="value1"} 283201.29
1412test_summary_1_duration_microseconds_count{label1="value1"} 31
1413test_summary_no_meta_1_duration_microseconds{label1="value1",quantile="0.5"} 4931.921
1414test_summary_no_meta_1_duration_microseconds{label1="value1",quantile="0.9"} 4932.921
1415test_summary_no_meta_1_duration_microseconds{label1="value1",quantile="0.99"} 4933.921
1416test_summary_no_meta_1_duration_microseconds_sum{label1="value1"} 283201.29
1417test_summary_no_meta_1_duration_microseconds_count{label1="value1"} 31
1418# HELP test_histogram_1_duration_seconds Test Histogram Metric 1
1419# TYPE test_histogram_1_duration_seconds histogram
1420test_histogram_1_duration_seconds_bucket{label1="value1",le="0.1"} 4
1421test_histogram_1_duration_seconds_bucket{label1="value1",le="0.5"} 5
1422test_histogram_1_duration_seconds_bucket{label1="value1",le="+Inf"} 6
1423test_histogram_1_duration_seconds_sum{label1="value1"} 0.00147889
1424test_histogram_1_duration_seconds_count{label1="value1"} 6
1425test_histogram_no_meta_1_duration_seconds_bucket{label1="value1",le="0.1"} 4
1426test_histogram_no_meta_1_duration_seconds_bucket{label1="value1",le="0.5"} 5
1427test_histogram_no_meta_1_duration_seconds_bucket{label1="value1",le="+Inf"} 6
1428test_histogram_no_meta_1_duration_seconds_sum{label1="value1"} 0.00147889
1429test_histogram_no_meta_1_duration_seconds_count{label1="value1"} 6
1430`),
1431 want: Series{
1432 // Gauge
1433 {
1434 Labels: labels.Labels{
1435 {Name: "__name__", Value: "test_gauge_metric_1"},
1436 {Name: "label1", Value: "value1"},
1437 },
1438 Value: 11,
1439 },
1440 {
1441 Labels: labels.Labels{
1442 {Name: "__name__", Value: "test_gauge_no_meta_metric_1"},
1443 {Name: "label1", Value: "value1"},
1444 },
1445 Value: 11,
1446 },
1447 // Counter
1448 {

Callers

nothing calls this directly

Calls 5

parseToSeriesMethod · 0.95
SortMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…