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

Function TestSummaryWithDefaultObjectives

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

Source from the content-addressed store, hash-verified

26)
27
28func TestSummaryWithDefaultObjectives(t *testing.T) {
29 now := time.Now()
30
31 reg := NewRegistry()
32 summaryWithDefaultObjectives := NewSummary(SummaryOpts{
33 Name: "default_objectives",
34 Help: "Test help.",
35 now: func() time.Time { return now },
36 })
37 if err := reg.Register(summaryWithDefaultObjectives); err != nil {
38 t.Error(err)
39 }
40
41 m := &dto.Metric{}
42 if err := summaryWithDefaultObjectives.Write(m); err != nil {
43 t.Error(err)
44 }
45 if len(m.GetSummary().Quantile) != 0 {
46 t.Error("expected no objectives in summary")
47 }
48
49 if !m.Summary.CreatedTimestamp.AsTime().Equal(now) {
50 t.Errorf("expected created timestamp %s, got %s", now, m.Summary.CreatedTimestamp.AsTime())
51 }
52}
53
54func TestSummaryWithoutObjectives(t *testing.T) {
55 reg := NewRegistry()

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected