From 6c709157c373d28e6036ec3e04d777cd98d2277d Mon Sep 17 00:00:00 2001 From: Marc CARRE Date: Sun, 8 Oct 2017 13:56:15 +0100 Subject: [PATCH] Update weaveworks/billing-client to latest. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` $ gvt delete github.com/weaveworks/billing-client $ gvt fetch -revision be0d55e547b147ea1817f037cab9458bf7fc7850 github.com/weaveworks/billing-client 2017/10/08 XX:XX:XX Fetching: github.com/weaveworks/billing-client 2017/10/08 XX:XX:XX · Skipping (existing): github.com/sirupsen/logrus 2017/10/08 XX:XX:XX · Skipping (existing): github.com/prometheus/client_golang/prometheus 2017/10/08 XX:XX:XX · Skipping (existing): github.com/fluent/fluent-logger-golang/fluent 2017/10/08 XX:XX:XX · Skipping (existing): github.com/weaveworks/common/instrument ``` --- .../weaveworks/billing-client/client.go | 21 ++++++++++--------- vendor/manifest | 4 ++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/vendor/github.com/weaveworks/billing-client/client.go b/vendor/github.com/weaveworks/billing-client/client.go index cce5bdb33..5f1873807 100644 --- a/vendor/github.com/weaveworks/billing-client/client.go +++ b/vendor/github.com/weaveworks/billing-client/client.go @@ -1,6 +1,7 @@ package billing import ( + "context" "fmt" "net" "strconv" @@ -10,19 +11,19 @@ import ( log "github.com/sirupsen/logrus" "github.com/fluent/fluent-logger-golang/fluent" "github.com/prometheus/client_golang/prometheus" - "golang.org/x/net/context" "github.com/weaveworks/common/instrument" ) var ( - // RequestDuration is the duration of billing client requests - RequestDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{ + // requestCollector is the duration of billing client requests + requestCollector = instrument.NewHistogramCollector(prometheus.NewHistogramVec(prometheus.HistogramOpts{ Namespace: "billing_client", Name: "request_duration_seconds", Help: "Time in seconds spent emitting billing info.", Buckets: prometheus.DefBuckets, - }, []string{"method", "status_code"}) + }, []string{"method", "status_code"})) + // EventsCounter is the count of billing events EventsCounter = prometheus.NewCounterVec(prometheus.CounterOpts{ Namespace: "billing_client", @@ -39,7 +40,7 @@ var ( // MustRegisterMetrics is a convenience function for registering all the metrics from this package func MustRegisterMetrics() { - prometheus.MustRegister(RequestDuration) + requestCollector.Register() prometheus.MustRegister(EventsCounter) prometheus.MustRegister(AmountsCounter) } @@ -53,7 +54,7 @@ type Client struct { Config } -// New creates a new billing client. +// NewClient creates a new billing client. func NewClient(cfg Config) (*Client, error) { host, port, err := net.SplitHostPort(cfg.IngesterHostPort) if err != nil { @@ -112,9 +113,9 @@ func NewClient(cfg Config) (*Client, error) { // here. Prefer including a lookup address over whole data. For example, // include a report id or s3 address instead of the information in the report. func (c *Client) AddAmounts(uniqueKey, internalInstanceID string, timestamp time.Time, amounts Amounts, metadata map[string]string) error { - return instrument.TimeRequestHistogram(context.Background(), "Billing.AddAmounts", RequestDuration, func(_ context.Context) error { + return instrument.CollectedRequest(context.Background(), "Billing.AddAmounts", requestCollector, nil, func(_ context.Context) error { if uniqueKey == "" { - return fmt.Errorf("billing units uniqueKey cannot be blank") + return fmt.Errorf("billing: units uniqueKey cannot be blank") } e := Event{ @@ -128,7 +129,7 @@ func (c *Client) AddAmounts(uniqueKey, internalInstanceID string, timestamp time select { case <-c.stop: trackEvent("stopping", e) - return fmt.Errorf("stopping, discarding event: %v", e) + return fmt.Errorf("billing: stopping, discarding event: %v", e) default: } @@ -139,7 +140,7 @@ func (c *Client) AddAmounts(uniqueKey, internalInstanceID string, timestamp time // full } trackEvent("buffer_full", e) - return fmt.Errorf("reached billing event buffer limit (%d), discarding event: %v", c.MaxBufferedEvents, e) + return fmt.Errorf("billing: reached billing event buffer limit (%d), discarding event: %v", c.MaxBufferedEvents, e) }) } diff --git a/vendor/manifest b/vendor/manifest index fbd0debb4..938910213 100644 --- a/vendor/manifest +++ b/vendor/manifest @@ -1322,8 +1322,8 @@ "importpath": "github.com/weaveworks/billing-client", "repository": "https://github.com/weaveworks/billing-client", "vcs": "git", - "revision": "694ea14d915e520638b234d9b3ca780c25963435", - "branch": "master", + "revision": "be0d55e547b147ea1817f037cab9458bf7fc7850", + "branch": "HEAD", "notests": true }, {