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

Function TestCounterVecEndToEndWithCollision

prometheus/vec_test.go:416–447  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

414}
415
416func TestCounterVecEndToEndWithCollision(t *testing.T) {
417 vec := NewCounterVec(
418 CounterOpts{
419 Name: "test",
420 Help: "helpless",
421 },
422 []string{"labelname"},
423 )
424 vec.WithLabelValues("77kepQFQ8Kl").Inc()
425 vec.WithLabelValues("!0IC=VloaY").Add(2)
426
427 m := &dto.Metric{}
428 if err := vec.WithLabelValues("77kepQFQ8Kl").Write(m); err != nil {
429 t.Fatal(err)
430 }
431 if got, want := m.GetLabel()[0].GetValue(), "77kepQFQ8Kl"; got != want {
432 t.Errorf("got label value %q, want %q", got, want)
433 }
434 if got, want := m.GetCounter().GetValue(), 1.; got != want {
435 t.Errorf("got value %f, want %f", got, want)
436 }
437 m.Reset()
438 if err := vec.WithLabelValues("!0IC=VloaY").Write(m); err != nil {
439 t.Fatal(err)
440 }
441 if got, want := m.GetLabel()[0].GetValue(), "!0IC=VloaY"; got != want {
442 t.Errorf("got label value %q, want %q", got, want)
443 }
444 if got, want := m.GetCounter().GetValue(), 2.; got != want {
445 t.Errorf("got value %f, want %f", got, want)
446 }
447}
448
449func TestCurryVec(t *testing.T) {
450 vec := NewCounterVec(

Callers

nothing calls this directly

Calls 7

WithLabelValuesMethod · 0.95
NewCounterVecFunction · 0.70
IncMethod · 0.65
AddMethod · 0.65
WriteMethod · 0.65
GetValueMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected