MCPcopy
hub / github.com/prometheus/client_golang / TestSummaryWithoutObjectives

Function TestSummaryWithoutObjectives

prometheus/summary_test.go:54–80  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

52}
53
54func TestSummaryWithoutObjectives(t *testing.T) {
55 reg := NewRegistry()
56 summaryWithEmptyObjectives := NewSummary(SummaryOpts{
57 Name: "empty_objectives",
58 Help: "Test help.",
59 Objectives: map[float64]float64{},
60 })
61 if err := reg.Register(summaryWithEmptyObjectives); err != nil {
62 t.Error(err)
63 }
64 summaryWithEmptyObjectives.Observe(3)
65 summaryWithEmptyObjectives.Observe(0.14)
66
67 m := &dto.Metric{}
68 if err := summaryWithEmptyObjectives.Write(m); err != nil {
69 t.Error(err)
70 }
71 if got, want := m.GetSummary().GetSampleSum(), 3.14; got != want {
72 t.Errorf("got sample sum %f, want %f", got, want)
73 }
74 if got, want := m.GetSummary().GetSampleCount(), uint64(2); got != want {
75 t.Errorf("got sample sum %d, want %d", got, want)
76 }
77 if len(m.GetSummary().Quantile) != 0 {
78 t.Error("expected no objectives in summary")
79 }
80}
81
82func TestSummaryWithQuantileLabel(t *testing.T) {
83 defer func() {

Callers

nothing calls this directly

Calls 6

RegisterMethod · 0.95
ObserveMethod · 0.95
NewRegistryFunction · 0.85
NewSummaryFunction · 0.70
WriteMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected