diff options
Diffstat (limited to 'plugins/metrics/tests')
-rw-r--r-- | plugins/metrics/tests/metrics_test.go | 4 | ||||
-rw-r--r-- | plugins/metrics/tests/plugin1.go | 69 |
2 files changed, 4 insertions, 69 deletions
diff --git a/plugins/metrics/tests/metrics_test.go b/plugins/metrics/tests/metrics_test.go index 7528fc46..d3043fbb 100644 --- a/plugins/metrics/tests/metrics_test.go +++ b/plugins/metrics/tests/metrics_test.go @@ -158,9 +158,9 @@ func TestMetricsGaugeCollector(t *testing.T) { assert.NoError(t, err) assert.Contains(t, out, "my_gauge 100") - genericOut, err := get("http://localhost:2112/metrics") + out, err = get("http://localhost:2112/metrics") assert.NoError(t, err) - assert.Contains(t, genericOut, "go_gc_duration_seconds") + assert.Contains(t, out, "go_gc_duration_seconds") for { select { diff --git a/plugins/metrics/tests/plugin1.go b/plugins/metrics/tests/plugin1.go index 8f1ece52..fb2a2235 100644 --- a/plugins/metrics/tests/plugin1.go +++ b/plugins/metrics/tests/plugin1.go @@ -28,77 +28,12 @@ func (p1 *Plugin1) Name() string { return "metrics_test.plugin1" } -func (p1 *Plugin1) MetricsCollector() prometheus.Collector { +func (p1 *Plugin1) MetricsCollector() []prometheus.Collector { collector := prometheus.NewGauge(prometheus.GaugeOpts{ Name: "my_gauge", Help: "My gauge value", }) collector.Set(100) - return collector -} - -// ////////////////////////////////////////////////////////////// -type Plugin3 struct { - config config.Configurer -} - -func (p *Plugin3) Init(cfg config.Configurer) error { - p.config = cfg - return nil -} - -func (p *Plugin3) Serve() chan error { - errCh := make(chan error, 1) - return errCh -} - -func (p *Plugin3) Stop() error { - return nil -} - -func (p *Plugin3) Name() string { - return "metrics_test.plugin3" -} - -func (p *Plugin3) MetricsCollector() prometheus.Collector { - var ( - cpuTemp = prometheus.NewGauge(prometheus.GaugeOpts{ - Name: "cpu_temperature_celsius", - Help: "Current temperature of the CPU.", - }) - ) - return cpuTemp -} - -type Plugin4 struct { - config config.Configurer -} - -func (p *Plugin4) Init(cfg config.Configurer) error { - p.config = cfg - return nil -} - -func (p *Plugin4) Serve() chan error { - errCh := make(chan error, 1) - return errCh -} - -func (p *Plugin4) Stop() error { - return nil -} - -func (p *Plugin4) Name() string { - return "metrics_test.plugin4" -} - -func (p *Plugin4) MetricsCollector() prometheus.Collector { - var ( - cpuTemp = prometheus.NewGauge(prometheus.GaugeOpts{ - Name: "cpu_temperature_celsius", - Help: "Current temperature of the CPU.", - }) - ) - return cpuTemp + return []prometheus.Collector{collector} } |