...
1
16
17 package slis
18
19 import (
20 "net/http"
21 "sync"
22
23 "k8s.io/component-base/metrics"
24 )
25
26 var (
27 installOnce = sync.Once{}
28 installWithResetOnce = sync.Once{}
29 )
30
31 type mux interface {
32 Handle(path string, handler http.Handler)
33 }
34
35 type SLIMetrics struct{}
36
37
38 func (s SLIMetrics) Install(m mux) {
39 installOnce.Do(func() {
40 Register(Registry)
41 m.Handle("/metrics/slis", metrics.HandlerFor(Registry, metrics.HandlerOpts{}))
42 })
43 }
44
45 type SLIMetricsWithReset struct{}
46
47
48 func (s SLIMetricsWithReset) Install(m mux) {
49 installWithResetOnce.Do(func() {
50 Register(Registry)
51 m.Handle("/metrics/slis", metrics.HandlerWithReset(Registry, metrics.HandlerOpts{}))
52 })
53 }
54
View as plain text