Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Go prometheus client lib to latest version #2123

Merged
merged 3 commits into from
Nov 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildkite/setup.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- label: Prepare scion_base and scion images
command:
- ./tools/ci/prepare_image d1706fb3c9c8eacdc9a91ddeac7c3ac1ad815fe43fc81bd50a280b3738ce7569
- ./tools/ci/prepare_image 12897905098b25a493ecf876d0a3ab355521d0f2e8044eae3c0cfda8714b7339
- ./docker.sh build
concurrency: 1
concurrency_group: "build-scion"
Expand Down
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
command: sudo apt-get update && sudo ./tools/install_docker
- run:
name: Pull and tag scion_base image
command: ./tools/ci/prepare_image d1706fb3c9c8eacdc9a91ddeac7c3ac1ad815fe43fc81bd50a280b3738ce7569
command: ./tools/ci/prepare_image 12897905098b25a493ecf876d0a3ab355521d0f2e8044eae3c0cfda8714b7339
when: always
- run:
name: Build scion:latest image
Expand Down
16 changes: 4 additions & 12 deletions go/border/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,26 +72,18 @@ func Init(elem string) {

// Some closures to reduce boiler-plate.
newCVec := func(name, help string, lNames []string) *prometheus.CounterVec {
v := prom.NewCounterVec(namespace, "", name, help, constLabels, lNames)
prometheus.MustRegister(v)
return v
return prom.NewCounterVec(namespace, "", name, help, constLabels, lNames)
}
newG := func(name, help string) prometheus.Gauge {
v := prom.NewGauge(namespace, "", name, help, constLabels)
prometheus.MustRegister(v)
return v
return prom.NewGauge(namespace, "", name, help, constLabels)
}
newGVec := func(name, help string, lNames []string) *prometheus.GaugeVec {
v := prom.NewGaugeVec(namespace, "", name, help, constLabels, lNames)
prometheus.MustRegister(v)
return v
return prom.NewGaugeVec(namespace, "", name, help, constLabels, lNames)
}
newHVec := func(name, help string,
lNames []string, buckets []float64) *prometheus.HistogramVec {

v := prom.NewHistogramVec(namespace, "", name, help, constLabels, lNames, buckets)
prometheus.MustRegister(v)
return v
return prom.NewHistogramVec(namespace, "", name, help, constLabels, lNames, buckets)
}

InputPkts = newCVec("input_pkts_total", "Total number of input packets received.", sockLabels)
Expand Down
19 changes: 14 additions & 5 deletions go/lib/prom/prom.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2017 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.
Expand All @@ -18,6 +19,7 @@ package prom

import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)

func CopyLabels(labels prometheus.Labels) prometheus.Labels {
Expand All @@ -28,9 +30,10 @@ func CopyLabels(labels prometheus.Labels) prometheus.Labels {
return l
}

// NewCounter creates a new prometheus counter that is registered with the default registry.
func NewCounter(namespace, subsystem, name, help string,
constLabels prometheus.Labels) prometheus.Counter {
return prometheus.NewCounter(
return promauto.NewCounter(
prometheus.CounterOpts{
Namespace: namespace,
Subsystem: subsystem,
Expand All @@ -41,9 +44,10 @@ func NewCounter(namespace, subsystem, name, help string,
)
}

// NewCounterVec creates a new prometheus counter vec that is registered with the default registry.
func NewCounterVec(namespace, subsystem, name, help string,
constLabels prometheus.Labels, labelNames []string) *prometheus.CounterVec {
return prometheus.NewCounterVec(
return promauto.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Subsystem: subsystem,
Expand All @@ -55,9 +59,10 @@ func NewCounterVec(namespace, subsystem, name, help string,
)
}

// NewGauge creates a new prometheus gauge that is registered with the default registry.
func NewGauge(namespace, subsystem, name, help string,
constLabels prometheus.Labels) prometheus.Gauge {
return prometheus.NewGauge(
return promauto.NewGauge(
prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: subsystem,
Expand All @@ -67,9 +72,11 @@ func NewGauge(namespace, subsystem, name, help string,
},
)
}

// NewGaugeVec creates a new prometheus gauge vec that is registered with the default registry.
func NewGaugeVec(namespace, subsystem, name, help string,
constLabels prometheus.Labels, labelNames []string) *prometheus.GaugeVec {
return prometheus.NewGaugeVec(
return promauto.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: subsystem,
Expand All @@ -81,9 +88,11 @@ func NewGaugeVec(namespace, subsystem, name, help string,
)
}

// NewHistogramVec creates a new prometheus histogram vec
// that is registered with the default registry.
func NewHistogramVec(namespace, subsystem, name, help string, constLabels prometheus.Labels,
labelNames []string, buckets []float64) *prometheus.HistogramVec {
return prometheus.NewHistogramVec(
return promauto.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: namespace,
Subsystem: subsystem,
Expand Down
17 changes: 6 additions & 11 deletions go/lib/ringbuf/metrics.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2017 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.
Expand Down Expand Up @@ -32,19 +33,13 @@ var UsedEntries *prometheus.GaugeVec
func InitMetrics(namespace string, constLabels prometheus.Labels, labelNames []string) {
lNames := append(labelNames, "desc")
newCVec := func(name, help string) *prometheus.CounterVec {
v := prom.NewCounterVec(namespace, "ringbuf", name, help, constLabels, lNames)
prometheus.MustRegister(v)
return v
return prom.NewCounterVec(namespace, "ringbuf", name, help, constLabels, lNames)
}
newGVec := func(name, help string) *prometheus.GaugeVec {
v := prom.NewGaugeVec(namespace, "ringbuf", name, help, constLabels, lNames)
prometheus.MustRegister(v)
return v
return prom.NewGaugeVec(namespace, "ringbuf", name, help, constLabels, lNames)
}
newHVec := func(name, help string, buckets []float64) *prometheus.HistogramVec {
v := prom.NewHistogramVec(namespace, "ringbuf", name, help, constLabels, lNames, buckets)
prometheus.MustRegister(v)
return v
return prom.NewHistogramVec(namespace, "ringbuf", name, help, constLabels, lNames, buckets)
}
WriteCalls = newCVec("write_calls_total", "Number of calls to Write.")
ReadCalls = newCVec("read_calls_total", "Number of calls to Read.")
Expand All @@ -63,8 +58,8 @@ type metrics struct {
readCalls prometheus.Counter
writesBlocked prometheus.Counter
readsBlocked prometheus.Counter
writeEntries prometheus.Histogram
readEntries prometheus.Histogram
writeEntries prometheus.Observer
readEntries prometheus.Observer
maxEntries prometheus.Gauge
usedEntries prometheus.Gauge
}
Expand Down
8 changes: 2 additions & 6 deletions go/sig/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,10 @@ func Init(elem string) {

// Some closures to reduce boiler-plate.
newC := func(name, help string) prometheus.Counter {
v := prom.NewCounter(namespace, "", name, help, constLabels)
prometheus.MustRegister(v)
return v
return prom.NewCounter(namespace, "", name, help, constLabels)
}
newCVec := func(name, help string, lNames []string) *prometheus.CounterVec {
v := prom.NewCounterVec(namespace, "", name, help, constLabels, lNames)
prometheus.MustRegister(v)
return v
return prom.NewCounterVec(namespace, "", name, help, constLabels, lNames)
}
// FIXME(kormat): these metrics should probably have more informative labels
PktsRecv = newCVec("pkts_recv_total", "Number of packets received.", iaLabels)
Expand Down
64 changes: 47 additions & 17 deletions go/vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -363,18 +363,30 @@
"revisionTime": "2017-07-14T08:24:55Z"
},
{
"checksumSHA1": "Ph+qmEo8RdBKBHZUhx0y5Oyk/U0=",
"checksumSHA1": "JKm/LRfEg6/MwrN6bdjRSHnWazM=",
"license": "APL 2.0",
"path": "github.com/prometheus/client_golang/prometheus",
"revision": "334af0119a8f8fb6af5bb950d535c482cac7f836",
"revisionTime": "2016-10-17T12:35:36Z"
"revision": "abad2d1bd44235a26707c172eab6bca5bf2dbad3",
"revisionTime": "2018-11-03T14:23:28Z"
},
{
"checksumSHA1": "lG3//eDlwqA4IOuAPrNtLh9G0TA=",
"checksumSHA1": "UBqhkyjCz47+S19MVTigxJ2VjVQ=",
"path": "github.com/prometheus/client_golang/prometheus/internal",
"revision": "abad2d1bd44235a26707c172eab6bca5bf2dbad3",
"revisionTime": "2018-11-03T14:23:28Z"
},
{
"checksumSHA1": "BFMAsj5z3cYaNKx9fwHrazQRFvI=",
"path": "github.com/prometheus/client_golang/prometheus/promauto",
"revision": "abad2d1bd44235a26707c172eab6bca5bf2dbad3",
"revisionTime": "2018-11-03T14:23:28Z"
},
{
"checksumSHA1": "wJzzub/0w2espYvar3lylwHXBAk=",
"license": "APL 2.0",
"path": "github.com/prometheus/client_golang/prometheus/promhttp",
"revision": "334af0119a8f8fb6af5bb950d535c482cac7f836",
"revisionTime": "2016-10-17T12:35:36Z"
"revision": "abad2d1bd44235a26707c172eab6bca5bf2dbad3",
"revisionTime": "2018-11-03T14:23:28Z"
},
{
"checksumSHA1": "DvwvOlPNAgRntBzt3b3OSRMS2N4=",
Expand All @@ -384,32 +396,50 @@
"revisionTime": "2015-02-12T10:17:44Z"
},
{
"checksumSHA1": "mHyjbJ3BWOfUV6q9f5PBt0gaY1k=",
"checksumSHA1": "ljxJzXiQ7dNsmuRIUhqqP+qjRWc=",
"license": "APL 2.0",
"path": "github.com/prometheus/common/expfmt",
"revision": "85637ea67b04b5c3bb25e671dacded2977f8f9f6",
"revisionTime": "2016-10-02T21:02:34Z"
"revision": "0b1957f9d949dfa3084171a6ec5642b38055276a",
"revisionTime": "2018-11-09T10:09:15Z"
},
{
"checksumSHA1": "GWlM3d2vPYyNATtTFgftS10/A9w=",
"license": "3-BSD",
"path": "github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg",
"revision": "85637ea67b04b5c3bb25e671dacded2977f8f9f6",
"revisionTime": "2016-10-02T21:02:34Z"
"revision": "0b1957f9d949dfa3084171a6ec5642b38055276a",
"revisionTime": "2018-11-09T10:09:15Z"
},
{
"checksumSHA1": "nFie+rxcX5WdIv1diZ+fu3aj6lE=",
"checksumSHA1": "ewHRWF7p/HQeh7RowZg5BUeDkdY=",
"license": "APL 2.0",
"path": "github.com/prometheus/common/model",
"revision": "85637ea67b04b5c3bb25e671dacded2977f8f9f6",
"revisionTime": "2016-10-02T21:02:34Z"
"revision": "0b1957f9d949dfa3084171a6ec5642b38055276a",
"revisionTime": "2018-11-09T10:09:15Z"
},
{
"checksumSHA1": "W218eJZPXJG783fUr/z6IaAZyes=",
"checksumSHA1": "4zOdjJcskuocAzI+i6rcRzYjSlI=",
"license": "APL 2.0",
"path": "github.com/prometheus/procfs",
"revision": "abf152e5f3e97f2fafac028d2cc06c1feb87ffa5",
"revisionTime": "2016-04-11T19:08:41Z"
"revision": "185b4288413d2a0dd0806f78c90dde719829e5ae",
"revisionTime": "2018-10-05T14:02:18Z"
},
{
"checksumSHA1": "8E1IbrgtLBee7J404VKPyoI+qsk=",
"path": "github.com/prometheus/procfs/internal/util",
"revision": "185b4288413d2a0dd0806f78c90dde719829e5ae",
"revisionTime": "2018-10-05T14:02:18Z"
},
{
"checksumSHA1": "HSP5hVT0CNMRa8+Xtz4z2Ic5U0E=",
"path": "github.com/prometheus/procfs/nfs",
"revision": "185b4288413d2a0dd0806f78c90dde719829e5ae",
"revisionTime": "2018-10-05T14:02:18Z"
},
{
"checksumSHA1": "yItvTQLUVqm/ArLEbvEhqG0T5a0=",
"path": "github.com/prometheus/procfs/xfs",
"revision": "185b4288413d2a0dd0806f78c90dde719829e5ae",
"revisionTime": "2018-10-05T14:02:18Z"
},
{
"checksumSHA1": "6AYg4fjEvFuAVN3wHakGApjhZAM=",
Expand Down