MCPcopy Create free account
hub / github.com/prometheus/common / testTextParse

Function testTextParse

expfmt/text_parse_test.go:26–419  ·  view source on GitHub ↗
(t testing.TB)

Source from the content-addressed store, hash-verified

24)
25
26func testTextParse(t testing.TB) {
27 scenarios := []struct {
28 in string
29 out []*dto.MetricFamily
30 }{
31 // 0: Empty lines as input.
32 {
33 in: `
34
35`,
36 out: []*dto.MetricFamily{},
37 },
38 // 1: Minimal case.
39 {
40 in: `
41minimal_metric 1.234
42another_metric -3e3 103948
43# Even that:
44no_labels{} 3
45# HELP line for non-existing metric will be ignored.
46`,
47 out: []*dto.MetricFamily{
48 {
49 Name: proto.String("minimal_metric"),
50 Type: dto.MetricType_UNTYPED.Enum(),
51 Metric: []*dto.Metric{
52 {
53 Untyped: &dto.Untyped{
54 Value: proto.Float64(1.234),
55 },
56 },
57 },
58 },
59 {
60 Name: proto.String("another_metric"),
61 Type: dto.MetricType_UNTYPED.Enum(),
62 Metric: []*dto.Metric{
63 {
64 Untyped: &dto.Untyped{
65 Value: proto.Float64(-3e3),
66 },
67 TimestampMs: proto.Int64(103948),
68 },
69 },
70 },
71 {
72 Name: proto.String("no_labels"),
73 Type: dto.MetricType_UNTYPED.Enum(),
74 Metric: []*dto.Metric{
75 {
76 Untyped: &dto.Untyped{
77 Value: proto.Float64(3),
78 },
79 },
80 },
81 },
82 },
83 },

Callers 2

TestTextParseFunction · 0.85
BenchmarkTextParseFunction · 0.85

Calls 2

TextToMetricFamiliesMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected