mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 10:48:15 +08:00
[REV] optimization function implementation
This commit is contained in:
parent
5c228878fa
commit
cfa56bcfab
@ -22,8 +22,8 @@ import "github.com/goodrain/rainbond/node/nodem/controller"
|
||||
|
||||
//Manager Manager
|
||||
type Manager interface {
|
||||
GetServiceHeadthy(serviceName string) *ServiceHealth
|
||||
WatchServiceHeadthy() <-chan *ServiceHealth
|
||||
GetServiceHealthy(serviceName string) *ServiceHealth
|
||||
WatchServiceHealthy() <-chan *ServiceHealth
|
||||
Start() error
|
||||
AddServices([]*controller.Service) error
|
||||
Stop() error
|
||||
@ -31,4 +31,7 @@ type Manager interface {
|
||||
|
||||
//ServiceHealth ServiceHealth
|
||||
type ServiceHealth struct {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -43,9 +43,9 @@ type Exporter struct {
|
||||
workerUp prometheus.Gauge
|
||||
dbmanager db.Manager
|
||||
statusManager *status.AppRuntimeSyncClient
|
||||
healthStatus prometheus.Gauge
|
||||
taskNum prometheus.Gauge
|
||||
taskError prometheus.Gauge
|
||||
healthStatus *prometheus.GaugeVec
|
||||
taskNum prometheus.Counter
|
||||
taskError prometheus.Counter
|
||||
}
|
||||
|
||||
var scrapeDurationDesc = prometheus.NewDesc(
|
||||
@ -54,6 +54,12 @@ var scrapeDurationDesc = prometheus.NewDesc(
|
||||
[]string{"collector"}, nil,
|
||||
)
|
||||
|
||||
var healthDesc = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, "exporter", "health_status"),
|
||||
"health status.",
|
||||
[]string{"service_name"}, nil,
|
||||
)
|
||||
|
||||
//Describe Describe
|
||||
func (e *Exporter) Describe(ch chan<- *prometheus.Desc) {
|
||||
metricCh := make(chan prometheus.Metric)
|
||||
@ -132,9 +138,9 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) {
|
||||
} else {
|
||||
val = 0
|
||||
}
|
||||
ch <- prometheus.MustNewConstMetric(e.healthStatus.Desc(), prometheus.GaugeValue, val)
|
||||
ch <- prometheus.MustNewConstMetric(e.taskNum.Desc(), prometheus.GaugeValue, discover.TaskNum)
|
||||
ch <- prometheus.MustNewConstMetric(e.taskError.Desc(), prometheus.GaugeValue, discover.TaskError)
|
||||
ch <- prometheus.MustNewConstMetric(healthDesc, prometheus.GaugeValue, val, "service_name.worker")
|
||||
ch <- prometheus.MustNewConstMetric(e.taskNum.Desc(), prometheus.CounterValue, discover.TaskNum)
|
||||
ch <- prometheus.MustNewConstMetric(e.taskError.Desc(), prometheus.CounterValue, discover.TaskError)
|
||||
}
|
||||
|
||||
var namespace = "app_resource"
|
||||
@ -175,19 +181,19 @@ func New(statusManager *status.AppRuntimeSyncClient) *Exporter {
|
||||
Name: "appfs",
|
||||
Help: "tenant service fs used.",
|
||||
}, []string{"tenant_id", "service_id", "volume_type"}),
|
||||
healthStatus: prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
healthStatus: prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: "exporter",
|
||||
Name: "worker_health_status",
|
||||
Help: "worker component health status.",
|
||||
}),
|
||||
taskNum: prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
}, []string{"service_name"}),
|
||||
taskNum: prometheus.NewCounter(prometheus.CounterOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: "exporter",
|
||||
Name: "worker_task_number",
|
||||
Help: "worker total number of tasks.",
|
||||
}),
|
||||
taskError: prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
taskError: prometheus.NewCounter(prometheus.CounterOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: "exporter",
|
||||
Name: "worker_task_error",
|
||||
|
Loading…
Reference in New Issue
Block a user