From 329023b7c5c13160d199dec9495121fadb7c51f2 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Fri, 6 Mar 2020 13:29:54 +0000 Subject: [PATCH] Improve calculation of usage in multitenant code Use the duration supplied, if there is one. It was looking for a process named "scope-probe", whereas the executable is just named "scope". --- app/multitenant/billing_emitter.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/multitenant/billing_emitter.go b/app/multitenant/billing_emitter.go index 3375b034d..d01b1670c 100644 --- a/app/multitenant/billing_emitter.go +++ b/app/multitenant/billing_emitter.go @@ -93,15 +93,18 @@ func (e *BillingEmitter) Add(ctx context.Context, rep report.Report, buf []byte) } // reportInterval tries to find the custom report interval of this report. If -// it is malformed, or not set, it returns false. +// it is malformed, or not set, it returns a default value. func (e *BillingEmitter) reportInterval(r report.Report) time.Duration { + if r.Window != 0 { + return r.Window + } var inter string for _, c := range r.Process.Nodes { cmd, ok := c.Latest.Lookup("cmdline") if !ok { continue } - if strings.Contains(cmd, "scope-probe") && + if strings.Contains(cmd, "scope") && strings.Contains(cmd, "probe.publish.interval") { cmds := strings.SplitAfter(cmd, "probe.publish.interval") aft := strings.Split(cmds[1], " ")