mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 18:20:27 +00:00
Merge pull request #2422 from weaveworks/billing-host-seconds
Add NodeSeconds to billing emitter
This commit is contained in:
@@ -53,12 +53,14 @@ func (e *BillingEmitter) Add(ctx context.Context, rep report.Report, buf []byte)
|
||||
}
|
||||
rowKey, colKey := calculateDynamoKeys(userID, now)
|
||||
|
||||
containerCount := int64(len(rep.Container.Nodes))
|
||||
interval := e.reportInterval(rep)
|
||||
hasher := sha256.New()
|
||||
hasher.Write(buf)
|
||||
hash := "sha256:" + base64.URLEncoding.EncodeToString(hasher.Sum(nil))
|
||||
amounts := billing.Amounts{billing.ContainerSeconds: int64(interval/time.Second) * containerCount}
|
||||
amounts := billing.Amounts{
|
||||
billing.ContainerSeconds: int64(interval/time.Second) * int64(len(rep.Container.Nodes)),
|
||||
billing.NodeSeconds: int64(interval/time.Second) * int64(len(rep.Host.Nodes)),
|
||||
}
|
||||
metadata := map[string]string{
|
||||
"row_key": rowKey,
|
||||
"col_key": colKey,
|
||||
|
||||
10
vendor/github.com/weaveworks/billing-client/client.go
generated
vendored
10
vendor/github.com/weaveworks/billing-client/client.go
generated
vendored
@@ -26,13 +26,13 @@ var (
|
||||
// EventsCounter is the count of billing events
|
||||
EventsCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||
Namespace: "billing_client",
|
||||
Name: "events",
|
||||
Help: "Number of billing events",
|
||||
}, []string{"status"})
|
||||
Name: "events_total",
|
||||
Help: "Number and type of billing events",
|
||||
}, []string{"status", "amount_type"})
|
||||
// AmountsCounter is the total of the billing amounts
|
||||
AmountsCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||
Namespace: "billing_client",
|
||||
Name: "amounts",
|
||||
Name: "amounts_total",
|
||||
Help: "Number and type of billing amounts",
|
||||
}, []string{"status", "amount_type"})
|
||||
)
|
||||
@@ -192,8 +192,8 @@ func (c *Client) post(e Event) error {
|
||||
}
|
||||
|
||||
func trackEvent(status string, e Event) {
|
||||
EventsCounter.WithLabelValues(status).Inc()
|
||||
for t, v := range e.Amounts {
|
||||
EventsCounter.WithLabelValues(status, string(t)).Inc()
|
||||
AmountsCounter.WithLabelValues(status, string(t)).Add(float64(v))
|
||||
}
|
||||
}
|
||||
|
||||
2
vendor/github.com/weaveworks/billing-client/event.go
generated
vendored
2
vendor/github.com/weaveworks/billing-client/event.go
generated
vendored
@@ -36,6 +36,8 @@ type AmountType string
|
||||
const (
|
||||
// ContainerSeconds is one of the billable metrics
|
||||
ContainerSeconds AmountType = "container-seconds"
|
||||
NodeSeconds AmountType = "node-seconds"
|
||||
Samples AmountType = "samples"
|
||||
)
|
||||
|
||||
// Amounts is a map of amount billable metrics to their values
|
||||
|
||||
2
vendor/manifest
vendored
2
vendor/manifest
vendored
@@ -1414,7 +1414,7 @@
|
||||
"importpath": "github.com/weaveworks/billing-client",
|
||||
"repository": "https://github.com/weaveworks/billing-client",
|
||||
"vcs": "git",
|
||||
"revision": "bf803baae0177625efc34699d79696644210a022",
|
||||
"revision": "f5ac1ebd2b577d93dca4d948ca429c499451dbc8",
|
||||
"branch": "master",
|
||||
"notests": true
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user