MCPcopy
hub / github.com/prometheus/prometheus / TestOTLPWriteHandler

Function TestOTLPWriteHandler

storage/remote/write_otlp_handler_test.go:53–259  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

51type sample = teststorage.Sample
52
53func TestOTLPWriteHandler(t *testing.T) {
54 ts := time.Now()
55 st := ts.Add(-1 * time.Millisecond)
56
57 // Expected samples passed via OTLP request without details (labels for now) that
58 // depend on translation or type and unit labels options.
59 expectedSamplesWithoutLabelsFn := func() []sample {
60 return []sample{
61 {
62 M: metadata.Metadata{Type: model.MetricTypeCounter, Unit: "bytes", Help: "test-counter-description"},
63 V: 10.0, ST: timestamp.FromTime(st), T: timestamp.FromTime(ts), ES: []exemplar.Exemplar{
64 {
65 Labels: labels.FromStrings("span_id", "0001020304050607", "trace_id", "000102030405060708090a0b0c0d0e0f"),
66 Value: 10, Ts: timestamp.FromTime(ts), HasTs: true,
67 },
68 },
69 },
70 {
71 M: metadata.Metadata{Type: model.MetricTypeGauge, Unit: "bytes", Help: "test-gauge-description"},
72 V: 10.0, ST: timestamp.FromTime(st), T: timestamp.FromTime(ts),
73 },
74 {
75 M: metadata.Metadata{Type: model.MetricTypeHistogram, Unit: "bytes", Help: "test-histogram-description"},
76 V: 30.0, ST: timestamp.FromTime(st), T: timestamp.FromTime(ts),
77 },
78 {
79 M: metadata.Metadata{Type: model.MetricTypeHistogram, Unit: "bytes", Help: "test-histogram-description"},
80 V: 12.0, ST: timestamp.FromTime(st), T: timestamp.FromTime(ts),
81 },
82 {
83 M: metadata.Metadata{Type: model.MetricTypeHistogram, Unit: "bytes", Help: "test-histogram-description"},
84 V: 2.0, ST: timestamp.FromTime(st), T: timestamp.FromTime(ts),
85 },
86 {
87 M: metadata.Metadata{Type: model.MetricTypeHistogram, Unit: "bytes", Help: "test-histogram-description"},
88 V: 4.0, ST: timestamp.FromTime(st), T: timestamp.FromTime(ts),
89 },
90 {
91 M: metadata.Metadata{Type: model.MetricTypeHistogram, Unit: "bytes", Help: "test-histogram-description"},
92 V: 6.0, ST: timestamp.FromTime(st), T: timestamp.FromTime(ts),
93 },
94 {
95 M: metadata.Metadata{Type: model.MetricTypeHistogram, Unit: "bytes", Help: "test-histogram-description"},
96 V: 8.0, ST: timestamp.FromTime(st), T: timestamp.FromTime(ts),
97 },
98 {
99 M: metadata.Metadata{Type: model.MetricTypeHistogram, Unit: "bytes", Help: "test-histogram-description"},
100 V: 10.0, ST: timestamp.FromTime(st), T: timestamp.FromTime(ts),
101 },
102 {
103 M: metadata.Metadata{Type: model.MetricTypeHistogram, Unit: "bytes", Help: "test-histogram-description"},
104 V: 12.0, ST: timestamp.FromTime(st), T: timestamp.FromTime(ts),
105 },
106 {
107 M: metadata.Metadata{Type: model.MetricTypeHistogram, Unit: "bytes", Help: "test-histogram-description"},
108 V: 12.0, ST: timestamp.FromTime(st), T: timestamp.FromTime(ts),
109 },
110 {

Callers

nothing calls this directly

Calls 8

FromTimeFunction · 0.92
FromStringsFunction · 0.92
RequireEqualFunction · 0.92
generateOTLPWriteRequestFunction · 0.85
handleOTLPFunction · 0.85
ResultSamplesMethod · 0.80
AddMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…