summaryrefslogtreecommitdiff
path: root/plugins/metrics/tests/plugin1.go
blob: 345a3ec62d296342b841d1137c53bb3501dd8556 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package tests

import (
	"github.com/prometheus/client_golang/prometheus"
	"github.com/spiral/roadrunner/v2/plugins/config"
)

// Gauge //////////////
type Plugin1 struct {
	config config.Configurer
}

func (p1 *Plugin1) Init(cfg config.Configurer) error {
	p1.config = cfg
	return nil
}

func (p1 *Plugin1) Serve() chan error {
	errCh := make(chan error, 1)
	return errCh
}

func (p1 *Plugin1) Stop() error {
	return nil
}

func (p1 *Plugin1) Name() string {
	return "metrics_test.plugin1"
}

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
}