forked from roadrunner-server/http
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics.go
30 lines (24 loc) · 1.31 KB
/
metrics.go
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
package http
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/roadrunner-server/sdk/v4/metrics"
"github.com/roadrunner-server/sdk/v4/state/process"
)
type Informer interface {
Workers() []*process.State
}
func (p *Plugin) MetricsCollector() []prometheus.Collector {
return []prometheus.Collector{p.statsExporter}
}
func newWorkersExporter(stats Informer) *metrics.StatsExporter {
return &metrics.StatsExporter{
TotalWorkersDesc: prometheus.NewDesc("rr_http_total_workers", "Total number of workers used by the HTTP plugin", nil, nil),
TotalMemoryDesc: prometheus.NewDesc("rr_http_workers_memory_bytes", "Memory usage by HTTP workers.", nil, nil),
StateDesc: prometheus.NewDesc("rr_http_worker_state", "Worker current state", []string{"state", "pid"}, nil),
WorkerMemoryDesc: prometheus.NewDesc("rr_http_worker_memory_bytes", "Worker current memory usage", []string{"pid"}, nil),
WorkersReady: prometheus.NewDesc("rr_http_workers_ready", "HTTP workers currently in ready state", nil, nil),
WorkersWorking: prometheus.NewDesc("rr_http_workers_working", "HTTP workers currently in working state", nil, nil),
WorkersInvalid: prometheus.NewDesc("rr_http_workers_invalid", "HTTP workers currently in invalid,killing,destroyed,errored,inactive states", nil, nil),
Workers: stats,
}
}