summaryrefslogtreecommitdiff
path: root/plugins/metrics/tests/plugin1.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-11-13 17:36:22 +0300
committerValery Piashchynski <[email protected]>2020-11-13 17:36:22 +0300
commit99b6012400ab407cfcb04aab833640af565d550d (patch)
tree75a228cf96d90f99e7ee6367c5d7cbb4c465c61d /plugins/metrics/tests/plugin1.go
parent6eefd067f4c08ed51834926abd1a4c60ec55b56d (diff)
Metrics config test
Config proper parsing Add metrics tests to the CI and Makefile
Diffstat (limited to 'plugins/metrics/tests/plugin1.go')
-rw-r--r--plugins/metrics/tests/plugin1.go67
1 files changed, 61 insertions, 6 deletions
diff --git a/plugins/metrics/tests/plugin1.go b/plugins/metrics/tests/plugin1.go
index fdf10e54..cac41c82 100644
--- a/plugins/metrics/tests/plugin1.go
+++ b/plugins/metrics/tests/plugin1.go
@@ -1,12 +1,11 @@
package tests
import (
- "fmt"
-
"github.com/prometheus/client_golang/prometheus"
"github.com/spiral/roadrunner/v2/plugins/config"
)
+// Gauge //////////////
type Plugin1 struct {
config config.Configurer
}
@@ -30,6 +29,39 @@ func (p1 *Plugin1) Name() string {
}
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.plugin1"
+}
+
+func (p *Plugin3) MetricsCollector() prometheus.Collector {
var (
cpuTemp = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "cpu_temperature_celsius",
@@ -39,11 +71,34 @@ func (p1 *Plugin1) MetricsCollector() prometheus.Collector {
return cpuTemp
}
-type PluginRpc struct {
- srv *Plugin1
+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 (r *PluginRpc) Hello(in string, out *string) error {
- *out = fmt.Sprintf("Hello, username: %s", in)
+func (p *Plugin4) Stop() error {
return nil
}
+
+func (p *Plugin4) Name() string {
+ return "metrics_test.plugin1"
+}
+
+func (p *Plugin4) MetricsCollector() prometheus.Collector {
+ var (
+ cpuTemp = prometheus.NewGauge(prometheus.GaugeOpts{
+ Name: "cpu_temperature_celsius",
+ Help: "Current temperature of the CPU.",
+ })
+ )
+ return cpuTemp
+}