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".
This commit is contained in:
Bryan Boreham
2020-03-06 13:29:54 +00:00
parent b07bfb294b
commit 329023b7c5

View File

@@ -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], " ")