mirror of
https://github.com/weaveworks/scope.git
synced 2026-02-14 18:09:59 +00:00
fix(multitenant): move use of rounding map inside lock
This commit is contained in:
@@ -77,21 +77,21 @@ func (e *BillingEmitter) Add(ctx context.Context, rep report.Report, buf []byte)
|
||||
interval = e.DefaultInterval
|
||||
}
|
||||
}
|
||||
// Billing takes an integer number of seconds, so keep track of the amount lost to rounding
|
||||
nodeSeconds := interval.Seconds()*float64(len(rep.Host.Nodes)) + e.rounding[userID]
|
||||
rounding := nodeSeconds - math.Floor(nodeSeconds)
|
||||
e.rounding[userID] = rounding
|
||||
e.Unlock()
|
||||
|
||||
hasher := sha256.New()
|
||||
hasher.Write(buf)
|
||||
hash := "sha256:" + base64.URLEncoding.EncodeToString(hasher.Sum(nil))
|
||||
|
||||
weaveNetCount := 0
|
||||
if hasWeaveNet(rep) {
|
||||
weaveNetCount = 1
|
||||
}
|
||||
|
||||
// Billing takes an integer number of seconds, so keep track of the amount lost to rounding
|
||||
nodeSeconds := interval.Seconds()*float64(len(rep.Host.Nodes)) + e.rounding[userID]
|
||||
rounding := nodeSeconds - math.Floor(nodeSeconds)
|
||||
e.rounding[userID] = rounding
|
||||
|
||||
amounts := billing.Amounts{
|
||||
billing.ContainerSeconds: int64(interval/time.Second) * int64(len(rep.Container.Nodes)),
|
||||
billing.NodeSeconds: int64(nodeSeconds),
|
||||
|
||||
Reference in New Issue
Block a user