summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-12-10 10:30:38 +0300
committerValery Piashchynski <[email protected]>2020-12-10 10:30:38 +0300
commit72ef974e2f79c9ee8eb2584baa50ea9a8b98eac9 (patch)
treec19174a239253cf2c62c18398c2a69d400627416 /service
parent95bcb4c3f390bebb91041db710dbb4bde994d2fe (diff)
Add objectives to the metrics summary
Diffstat (limited to 'service')
-rw-r--r--service/metrics/config.go12
-rw-r--r--service/metrics/config_test.go3
-rw-r--r--service/metrics/rpc.go11
3 files changed, 17 insertions, 9 deletions
diff --git a/service/metrics/config.go b/service/metrics/config.go
index c95fd940..023eff27 100644
--- a/service/metrics/config.go
+++ b/service/metrics/config.go
@@ -2,6 +2,7 @@ package metrics
import (
"fmt"
+
"github.com/prometheus/client_golang/prometheus"
"github.com/spiral/roadrunner/service"
)
@@ -54,6 +55,8 @@ type Collector struct {
Labels []string `json:"labels"`
// Buckets for histogram metric.
Buckets []float64 `json:"buckets"`
+ // Objectives for the summary opts
+ Objectives map[float64]float64 `json:"objectives"`
}
// Hydrate configuration.
@@ -114,10 +117,11 @@ func (c *Config) getCollectors() (map[string]prometheus.Collector, error) {
}
case Summary:
opts := prometheus.SummaryOpts{
- Name: name,
- Namespace: m.Namespace,
- Subsystem: m.Subsystem,
- Help: m.Help,
+ Name: name,
+ Namespace: m.Namespace,
+ Subsystem: m.Subsystem,
+ Help: m.Help,
+ Objectives: m.Objectives,
}
if len(m.Labels) != 0 {
diff --git a/service/metrics/config_test.go b/service/metrics/config_test.go
index a64e9047..94f97da5 100644
--- a/service/metrics/config_test.go
+++ b/service/metrics/config_test.go
@@ -1,11 +1,12 @@
package metrics
import (
+ "testing"
+
json "github.com/json-iterator/go"
"github.com/prometheus/client_golang/prometheus"
"github.com/spiral/roadrunner/service"
"github.com/stretchr/testify/assert"
- "testing"
)
type mockCfg struct{ cfg string }
diff --git a/service/metrics/rpc.go b/service/metrics/rpc.go
index 377d6173..0544d109 100644
--- a/service/metrics/rpc.go
+++ b/service/metrics/rpc.go
@@ -2,6 +2,7 @@ package metrics
import (
"fmt"
+
"github.com/prometheus/client_golang/prometheus"
)
@@ -134,6 +135,7 @@ func (rpc *rpcServer) Observe(m *Metric, ok *bool) (err error) {
*ok = true
return nil
}
+
// Declare is used to register new collector in prometheus
// THE TYPES ARE:
// NamedCollector -> Collector with the name
@@ -200,10 +202,11 @@ func (rpc *rpcServer) Declare(c *NamedCollector, ok *bool) (err error) {
}
case Summary:
opts := prometheus.SummaryOpts{
- Name: c.Name,
- Namespace: c.Namespace,
- Subsystem: c.Subsystem,
- Help: c.Help,
+ Name: c.Name,
+ Namespace: c.Namespace,
+ Subsystem: c.Subsystem,
+ Help: c.Help,
+ Objectives: c.Objectives,
}
if len(c.Labels) != 0 {