summaryrefslogtreecommitdiff
path: root/plugins/metrics/rpc.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-11-14 17:18:28 +0300
committerValery Piashchynski <[email protected]>2020-11-14 17:18:28 +0300
commite45155e77e99e85e4ee9cd8863365bf6d599796e (patch)
treefe22608b4206fcab3219b824b5bd8cfaf5cfb85f /plugins/metrics/rpc.go
parente83f7d824e5f491fb50b4a9024ef7862aee9b6ca (diff)
More tests for the Metrics
Diffstat (limited to 'plugins/metrics/rpc.go')
-rw-r--r--plugins/metrics/rpc.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/plugins/metrics/rpc.go b/plugins/metrics/rpc.go
index 9799db3f..d0f071ef 100644
--- a/plugins/metrics/rpc.go
+++ b/plugins/metrics/rpc.go
@@ -3,10 +3,12 @@ package metrics
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/spiral/errors"
+ "github.com/spiral/roadrunner/v2/interfaces/log"
)
type rpcServer struct {
svc *Plugin
+ log log.Logger
}
// Metric represent single metric produced by the application.
@@ -24,9 +26,11 @@ type Metric struct {
// Add new metric to the designated collector.
func (rpc *rpcServer) Add(m *Metric, ok *bool) error {
const op = errors.Op("Add metric")
+ rpc.log.Info("Adding metric", "name", m.Name, "value", m.Value, "labels", m.Labels)
c, exist := rpc.svc.collectors.Load(m.Name)
if !exist {
- return errors.E(op, errors.Errorf("undefined collector `%s`", m.Name))
+ rpc.log.Error("undefined collector", "collector", m.Name)
+ return errors.E(op, errors.Errorf("undefined collector %s, try first Declare the desired collector", m.Name))
}
switch c := c.(type) {
@@ -56,6 +60,7 @@ func (rpc *rpcServer) Add(m *Metric, ok *bool) error {
// RPC, set ok to true as return value. Need by rpc.Call reply argument
*ok = true
+ rpc.log.Info("new metric successfully added")
return nil
}
@@ -197,7 +202,7 @@ func (rpc *rpcServer) Declare(nc *NamedCollector, ok *bool) error {
}
default:
- return errors.E(op, errors.Errorf("unknown collector type `%s`", nc.Type))
+ return errors.E(op, errors.Errorf("unknown collector type %s", nc.Type))
}
// add collector to sync.Map