summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-01-25 13:10:06 +0300
committerValery Piashchynski <[email protected]>2021-01-25 13:10:06 +0300
commit2a0e7d37d825da6bb0538599ce0e2edaaa59403b (patch)
tree89c00a43333246bb6c6815c923548eecd7d4e717 /plugins
parentb18a3578b6d299aac5dfcc016c2a3a0f6905aa0d (diff)
resolve #415
Diffstat (limited to 'plugins')
-rw-r--r--plugins/http/config/http.go20
-rw-r--r--plugins/metrics/rpc.go14
-rw-r--r--plugins/rpc/plugin.go3
3 files changed, 8 insertions, 29 deletions
diff --git a/plugins/http/config/http.go b/plugins/http/config/http.go
index bd689918..a8b1e8e3 100644
--- a/plugins/http/config/http.go
+++ b/plugins/http/config/http.go
@@ -146,26 +146,6 @@ func ParseCIDRs(subnets []string) (Cidrs, error) {
return c, nil
}
-// IsTrusted if api can be trusted to use X-Real-Ip, X-Forwarded-For
-func (c *HTTP) IsTrusted(ip string) bool {
- if c.Cidrs == nil {
- return false
- }
-
- i := net.ParseIP(ip)
- if i == nil {
- return false
- }
-
- for _, cird := range c.Cidrs {
- if cird.Contains(i) {
- return true
- }
- }
-
- return false
-}
-
// Valid validates the configuration.
func (c *HTTP) Valid() error {
const op = errors.Op("validation")
diff --git a/plugins/metrics/rpc.go b/plugins/metrics/rpc.go
index d7c90d39..538cdb78 100644
--- a/plugins/metrics/rpc.go
+++ b/plugins/metrics/rpc.go
@@ -26,7 +26,7 @@ type Metric struct {
// Add new metric to the designated collector.
func (rpc *rpcServer) Add(m *Metric, ok *bool) error {
const op = errors.Op("metrics_plugin_add")
- rpc.log.Info("Adding metric", "name", m.Name, "value", m.Value, "labels", m.Labels)
+ rpc.log.Info("adding metric", "name", m.Name, "value", m.Value, "labels", m.Labels)
c, exist := rpc.svc.collectors.Load(m.Name)
if !exist {
rpc.log.Error("undefined collector", "collector", m.Name)
@@ -70,14 +70,14 @@ 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", "name", m.Name, "labels", m.Labels, "value", m.Value)
+ rpc.log.Info("metric successfully added", "name", m.Name, "labels", m.Labels, "value", m.Value)
return nil
}
// Sub subtract the value from the specific metric (gauge only).
func (rpc *rpcServer) Sub(m *Metric, ok *bool) error {
const op = errors.Op("metrics_plugin_sub")
- rpc.log.Info("Subtracting value from metric", "name", m.Name, "value", m.Value, "labels", m.Labels)
+ rpc.log.Info("subtracting value from metric", "name", m.Name, "value", m.Value, "labels", m.Labels)
c, exist := rpc.svc.collectors.Load(m.Name)
if !exist {
rpc.log.Error("undefined collector", "name", m.Name, "value", m.Value, "labels", m.Labels)
@@ -107,7 +107,7 @@ func (rpc *rpcServer) Sub(m *Metric, ok *bool) error {
default:
return errors.E(op, errors.Errorf("collector `%s` does not support method `Sub`", m.Name))
}
- rpc.log.Info("Subtracting operation applied successfully", "name", m.Name, "labels", m.Labels, "value", m.Value)
+ rpc.log.Info("subtracting operation finished successfully", "name", m.Name, "labels", m.Labels, "value", m.Value)
*ok = true
return nil
@@ -116,7 +116,7 @@ func (rpc *rpcServer) Sub(m *Metric, ok *bool) error {
// Observe the value (histogram and summary only).
func (rpc *rpcServer) Observe(m *Metric, ok *bool) error {
const op = errors.Op("metrics_plugin_observe")
- rpc.log.Info("Observing metric", "name", m.Name, "value", m.Value, "labels", m.Labels)
+ rpc.log.Info("observing metric", "name", m.Name, "value", m.Value, "labels", m.Labels)
c, exist := rpc.svc.collectors.Load(m.Name)
if !exist {
@@ -171,7 +171,7 @@ func (rpc *rpcServer) Observe(m *Metric, ok *bool) error {
// error
func (rpc *rpcServer) Declare(nc *NamedCollector, ok *bool) error {
const op = errors.Op("metrics_plugin_declare")
- rpc.log.Info("Declaring new metric", "name", nc.Name, "type", nc.Type, "namespace", nc.Namespace)
+ rpc.log.Info("declaring new metric", "name", nc.Name, "type", nc.Type, "namespace", nc.Namespace)
_, exist := rpc.svc.collectors.Load(nc.Name)
if exist {
rpc.log.Error("metric with provided name already exist", "name", nc.Name, "type", nc.Type, "namespace", nc.Namespace)
@@ -256,7 +256,7 @@ func (rpc *rpcServer) Declare(nc *NamedCollector, ok *bool) error {
// Set the metric value (only for gaude).
func (rpc *rpcServer) Set(m *Metric, ok *bool) (err error) {
const op = errors.Op("metrics_plugin_set")
- rpc.log.Info("Observing metric", "name", m.Name, "value", m.Value, "labels", m.Labels)
+ rpc.log.Info("observing metric", "name", m.Name, "value", m.Value, "labels", m.Labels)
c, exist := rpc.svc.collectors.Load(m.Name)
if !exist {
diff --git a/plugins/rpc/plugin.go b/plugins/rpc/plugin.go
index 55b24cd1..e13768f0 100644
--- a/plugins/rpc/plugin.go
+++ b/plugins/rpc/plugin.go
@@ -86,8 +86,7 @@ func (s *Plugin) Serve() chan error {
conn, err := s.listener.Accept()
if err != nil {
if atomic.LoadUint32(s.closed) == 1 {
- // just log and continue, this is not a critical issue, we just called Stop
- s.log.Warn("listener accept error, connection closed", "error", err)
+ // just continue, this is not a critical issue, we just called Stop
return
}