Update weaveworks/billing-client to latest.

```
$ 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
```
This commit is contained in:
Marc CARRE
2017-10-08 13:56:15 +01:00
parent 76807eb54f
commit 6c709157c3
2 changed files with 13 additions and 12 deletions

View File

@@ -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)
})
}

4
vendor/manifest vendored
View File

@@ -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
},
{