...

Source file src/golang.conradwood.net/go-easyops/prometheus/summaryvec.go

Documentation: golang.conradwood.net/go-easyops/prometheus

     1  package prometheus
     2  
     3  import (
     4  	pm "github.com/prometheus/client_golang/prometheus"
     5  )
     6  
     7  type SummaryVec struct {
     8  	collector
     9  	opts       SummaryOpts
    10  	labelnames []string
    11  	gv         *pm.SummaryVec
    12  }
    13  
    14  func (h *SummaryVec) init() *SummaryVec {
    15  	h.gv = pm.NewSummaryVec(
    16  		pm.SummaryOpts{
    17  			Name:       h.opts.Name,
    18  			Objectives: h.opts.Objectives,
    19  			Help:       h.opts.Help,
    20  		}, h.labelnames)
    21  	h.setParent(h)
    22  	return h
    23  }
    24  func (g *SummaryVec) PMCollector() pm.Collector {
    25  	return g.gv
    26  }
    27  func (g *SummaryVec) With(l Labels) pm.Observer {
    28  	promreg.used(g.opts.Name, l)
    29  	return g.gv.With(pm.Labels(l))
    30  }
    31  func (g *SummaryVec) Observe(f float64) {
    32  	g.gv.With(pm.Labels{}).Observe(f)
    33  }
    34  func (g *SummaryVec) WithLabelValues(vs ...string) pm.Observer {
    35  	i := 0
    36  	l := make(map[string]string)
    37  	for {
    38  		if i >= len(vs) {
    39  			break
    40  		}
    41  		l[vs[i]] = l[vs[i+1]]
    42  		i = i + 2
    43  	}
    44  
    45  	promreg.used(g.opts.Name, l)
    46  	return g.gv.WithLabelValues(vs...)
    47  }
    48  

View as plain text