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

Function TestTextDecoder

expfmt/decode_test.go:36–104  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

34)
35
36func TestTextDecoder(t *testing.T) {
37 var (
38 ts = model.Now()
39 in = `
40# Only a quite simple scenario with two metric families.
41# More complicated tests of the parser itself can be found in the text package.
42# TYPE mf2 counter
43mf2 3
44mf1{label="value1"} -3.14 123456
45mf1{label="value2"} 42
46mf2 4
47`
48 out = model.Vector{
49 &model.Sample{
50 Metric: model.Metric{
51 model.MetricNameLabel: "mf1",
52 "label": "value1",
53 },
54 Value: -3.14,
55 Timestamp: 123456,
56 },
57 &model.Sample{
58 Metric: model.Metric{
59 model.MetricNameLabel: "mf1",
60 "label": "value2",
61 },
62 Value: 42,
63 Timestamp: ts,
64 },
65 &model.Sample{
66 Metric: model.Metric{
67 model.MetricNameLabel: "mf2",
68 },
69 Value: 3,
70 Timestamp: ts,
71 },
72 &model.Sample{
73 Metric: model.Metric{
74 model.MetricNameLabel: "mf2",
75 },
76 Value: 4,
77 Timestamp: ts,
78 },
79 }
80 )
81
82 dec := &SampleDecoder{
83 Dec: &textDecoder{
84 s: model.UTF8Validation,
85 r: strings.NewReader(in),
86 },
87 Opts: &DecodeOptions{
88 Timestamp: ts,
89 },
90 }
91 var all model.Vector
92 for {
93 var smpls model.Vector

Callers

nothing calls this directly

Calls 2

DecodeMethod · 0.95
NowFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…