MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / execute

Function execute

metric/collector.go:83–98  ·  view source on GitHub ↗
(name string, c Collector, ch chan<- prometheus.Metric)

Source from the content-addressed store, hash-verified

81}
82
83func execute(name string, c Collector, ch chan<- prometheus.Metric) {
84 begin := time.Now()
85 err := c.Update(ch)
86 duration := time.Since(begin)
87 var success float64
88
89 if err != nil {
90 log.Errorf("ERROR: %s collector failed after %fs: %s", name, duration.Seconds(), err)
91 success = 0
92 } else {
93 log.Debugf("OK: %s collector succeeded after %fs.", name, duration.Seconds())
94 success = 1
95 }
96 ch <- prometheus.MustNewConstMetric(scrapeDurationDesc, prometheus.GaugeValue, duration.Seconds(), name)
97 ch <- prometheus.MustNewConstMetric(scrapeSuccessDesc, prometheus.GaugeValue, success, name)
98}
99
100// Collector is the interface a collector has to implement.
101type Collector interface {

Callers 1

CollectMethod · 0.85

Calls 3

ErrorfFunction · 0.92
DebugfFunction · 0.92
UpdateMethod · 0.65

Tested by

no test coverage detected