From 8144967fb4f15b0612f9f457d96d00f3652f4598 Mon Sep 17 00:00:00 2001 From: Sergio Gonzalez Monroy Date: Mon, 23 Sep 2019 17:03:10 +0200 Subject: [PATCH] comments r2 --- go/border/internal/metrics/ctrl.go | 14 +--- go/border/internal/metrics/metrics.go | 2 - go/border/internal/metrics/output.go | 4 +- go/border/metrics/BUILD.bazel | 12 --- go/border/metrics/metrics.go | 116 -------------------------- go/border/rctrl/ctrl.go | 3 +- go/border/rctrl/ifstate.go | 3 - go/border/rctrl/revinfo.go | 3 - 8 files changed, 7 insertions(+), 150 deletions(-) delete mode 100644 go/border/metrics/BUILD.bazel delete mode 100644 go/border/metrics/metrics.go diff --git a/go/border/internal/metrics/ctrl.go b/go/border/internal/metrics/ctrl.go index d03256fbf2..a82edc56f6 100644 --- a/go/border/internal/metrics/ctrl.go +++ b/go/border/internal/metrics/ctrl.go @@ -33,20 +33,16 @@ type ControlLabels struct { Result string // Type is the type of packet/message. Type string - // Src is the source address of the processed packet. - Src string - // Dst is the destination address of the processed packet. - Dst string } // Labels returns the list of labels. func (l ControlLabels) Labels() []string { - return []string{"result", "type", "src", "dst"} + return []string{"result", "type"} } // Values returns the label values in the order defined by Labels. func (l ControlLabels) Values() []string { - return []string{l.Result, l.Type, l.Src, l.Dst} + return []string{l.Result, l.Type} } type control struct { @@ -56,13 +52,11 @@ type control struct { func newControl() control { sub := "control" - il := IntfLabels{} - cl := ControlLabels{} return control{ pkts: prom.NewCounterVec(Namespace, sub, - "pkts_total", "Total number of processed packets.", cl.Labels()), + "pkts_total", "Total number of processed packets.", ControlLabels{}.Labels()), ifstate: prom.NewGaugeVec(Namespace, sub, - "interface_active", "Interface is active.", il.Labels()), + "interface_active", "Interface is active.", IntfLabels{}.Labels()), } } diff --git a/go/border/internal/metrics/metrics.go b/go/border/internal/metrics/metrics.go index 906264acbc..aa10ae4b92 100644 --- a/go/border/internal/metrics/metrics.go +++ b/go/border/internal/metrics/metrics.go @@ -45,8 +45,6 @@ const ( ErrParsePayload = "err_parse_payload" ) -const Self = "self" - // Metrics initialization. var ( Input = newInput() diff --git a/go/border/internal/metrics/output.go b/go/border/internal/metrics/output.go index 415889293e..2e6a6ff3fd 100644 --- a/go/border/internal/metrics/output.go +++ b/go/border/internal/metrics/output.go @@ -37,9 +37,9 @@ func newOutput() output { l := IntfLabels{}.Labels() return output{ pkts: prom.NewCounterVec(Namespace, sub, - "pkts_total", "Total number of output packets received.", l), + "pkts_total", "Total number of output packets sent.", l), bytes: prom.NewCounterVec(Namespace, sub, - "bytes_total", "Total number of output bytes received.", l), + "bytes_total", "Total number of output bytes sent.", l), pktSize: prom.NewHistogramVec(Namespace, sub, "pkt_size_bytes", "Size of output packets in bytes", l, []float64{64, 256, 512, 1024, 1280, 1500, 3000, 6000, 9000}), diff --git a/go/border/metrics/BUILD.bazel b/go/border/metrics/BUILD.bazel deleted file mode 100644 index 60172c940b..0000000000 --- a/go/border/metrics/BUILD.bazel +++ /dev/null @@ -1,12 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = ["metrics.go"], - importpath = "github.com/scionproto/scion/go/border/metrics", - visibility = ["//visibility:public"], - deps = [ - "//go/lib/prom:go_default_library", - "@com_github_prometheus_client_golang//prometheus:go_default_library", - ], -) diff --git a/go/border/metrics/metrics.go b/go/border/metrics/metrics.go deleted file mode 100644 index 5b8ab81df4..0000000000 --- a/go/border/metrics/metrics.go +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright 2016 ETH Zurich -// Copyright 2018 ETH Zurich, Anapaya Systems -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package metrics defines and exports router metrics to be scraped by -// prometheus. -package metrics - -import ( - "github.com/prometheus/client_golang/prometheus" - - "github.com/scionproto/scion/go/lib/prom" -) - -// Namespace is the metrics namespace for the border router. -const Namespace = "br" - -// Declare prometheus metrics to export. -var ( - // High-level input stats - InputPkts *prometheus.CounterVec - InputBytes *prometheus.CounterVec - InputPktSize *prometheus.HistogramVec - - // High-level output stats - OutputPkts *prometheus.CounterVec - OutputBytes *prometheus.CounterVec - OutputPktSize *prometheus.HistogramVec - - // Low-level input stats - InputReads *prometheus.CounterVec - InputReadErrors *prometheus.CounterVec - InputRcvOvfl *prometheus.GaugeVec - InputLatency *prometheus.CounterVec - - // Low-level output stats - OutputWrites *prometheus.CounterVec - OutputWriteErrors *prometheus.CounterVec - OutputWriteLatency *prometheus.CounterVec - - // Processing metrics - ProcessPktTime *prometheus.CounterVec - ProcessSockSrcDst *prometheus.CounterVec - - // Misc - IFState *prometheus.GaugeVec -) - -func init() { - sockLabels := []string{"sock"} - - // Some closures to reduce boiler-plate. - newCVec := func(name, help string, lNames []string) *prometheus.CounterVec { - return prom.NewCounterVec(Namespace, "", name, help, lNames) - } - newG := func(name, help string) prometheus.Gauge { - return prom.NewGauge(Namespace, "", name, help) - } - newGVec := func(name, help string, lNames []string) *prometheus.GaugeVec { - return prom.NewGaugeVec(Namespace, "", name, help, lNames) - } - newHVec := func(name, help string, - lNames []string, buckets []float64) *prometheus.HistogramVec { - - return prom.NewHistogramVec(Namespace, "", name, help, lNames, buckets) - } - - InputPkts = newCVec("input_pkts_total", "Total number of input packets received.", sockLabels) - InputBytes = newCVec("input_bytes_total", "Total number of input bytes received.", sockLabels) - InputPktSize = newHVec("input_pkt_size_bytes", "Size of input packets in bytes", sockLabels, - []float64{64, 256, 512, 1024, 1280, 1500, 3000, 6000, 9000}) - - OutputPkts = newCVec("output_pkts_total", "Total number of output packets sent.", sockLabels) - OutputBytes = newCVec("output_bytes_total", "Total number of output bytes sent.", sockLabels) - OutputPktSize = newHVec("output_pkt_size_bytes", "Size of output packets in bytes", sockLabels, - []float64{64, 256, 512, 1024, 1280, 1500, 3000, 6000, 9000}) - - InputReads = newCVec("input_reads_total", "Total number of input socket reads.", sockLabels) - InputReadErrors = newCVec( - "input_read_errors_total", "Total number of input socket read errors.", sockLabels) - InputLatency = newCVec( - "input_latency_seconds_total", - "Total time packets wait in the kernel to be read, in seconds", sockLabels) - InputRcvOvfl = newGVec( - "input_overflow_packets_total", - "Total number of packets dropped by kernel due to receive buffer overflow.", sockLabels) - - OutputWrites = newCVec("output_writes_total", "Number of output socket writes.", sockLabels) - OutputWriteErrors = newCVec( - "output_write_errors_total", "Number of output socket write errors.", sockLabels) - OutputWriteLatency = newCVec( - "output_write_seconds_total", - "Total time spent writing output packets, in seconds.", sockLabels) - - ProcessPktTime = newCVec("process_pkt_seconds_total", - "Total processing time for input packets, in seconds.", sockLabels) - ProcessSockSrcDst = newCVec("process_pkts_src_dst_total", - "Total number of packets from one sock to another.", []string{"inSock", "outSock"}) - - // border_base_labels is a special metric that always has the value `1`, - // that is used to add labels to non-br metrics. - BRLabels := newG("base_labels", "Border base labels.") - BRLabels.Set(1) - IFState = newGVec("interface_active", "Interface is active.", sockLabels) -} diff --git a/go/border/rctrl/ctrl.go b/go/border/rctrl/ctrl.go index a34511c02d..03712015d0 100644 --- a/go/border/rctrl/ctrl.go +++ b/go/border/rctrl/ctrl.go @@ -80,10 +80,9 @@ func Control(sRevInfoQ chan rpkt.RawSRevCallbackArgs, dispatcherReconnect bool) func processCtrl() { b := make(common.RawBytes, maxBufSize) - cl := metrics.ControlLabels{Dst: metrics.Self, Type: metrics.IFStateInfo} + cl := metrics.ControlLabels{Type: metrics.IFStateInfo} for { pktLen, src, err := snetConn.ReadFromSCION(b) - cl.Src = src.String() if err != nil { cl.Result = metrics.ErrRead metrics.Control.Pkts(cl).Inc() diff --git a/go/border/rctrl/ifstate.go b/go/border/rctrl/ifstate.go index 6f1bcb46cc..8337b5093a 100644 --- a/go/border/rctrl/ifstate.go +++ b/go/border/rctrl/ifstate.go @@ -54,8 +54,6 @@ func ifStateUpdate() { // genIFStateReq generates an Interface State request packet to the local beacon service. func genIFStateReq() error { cl := metrics.ControlLabels{ - Src: metrics.Self, - Dst: "svc_bs", Type: metrics.IFStateReq, Result: metrics.ErrProcess, } @@ -87,7 +85,6 @@ func genIFStateReq() error { var errors common.MultiError for _, addr := range bsAddrs { dst.NextHop = addr - cl.Dst = dst.String() if _, err := snetConn.WriteToSCION(pld, dst); err != nil { cl.Result = metrics.ErrWrite metrics.Control.Pkts(cl).Inc() diff --git a/go/border/rctrl/revinfo.go b/go/border/rctrl/revinfo.go index e8e68e2d74..f9f1b10d28 100644 --- a/go/border/rctrl/revinfo.go +++ b/go/border/rctrl/revinfo.go @@ -45,8 +45,6 @@ func revInfoFwd(revInfoQ chan rpkt.RawSRevCallbackArgs) { // fwdRevInfo forwards RevInfo payloads to a designated local host. func fwdRevInfo(sRevInfo *path_mgmt.SignedRevInfo, dstHost addr.HostSVC) { cl := metrics.ControlLabels{ - Src: metrics.Self, - Dst: dstHost.String(), Type: metrics.Revocation, Result: metrics.ErrProcess, } @@ -79,7 +77,6 @@ func fwdRevInfo(sRevInfo *path_mgmt.SignedRevInfo, dstHost addr.HostSVC) { logger.Error("Resolving SVC anycast", "err", err, "addr", dst) return } - cl.Dst = dst.String() if _, err := snetConn.WriteToSCION(pld, dst); err != nil { cl.Result = metrics.ErrWrite metrics.Control.Pkts(cl).Inc()