-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for once mode; run processors and aggregators during test. #7474
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much anticipated PR. ❤️
Couple suggestions
agent/agent.go
Outdated
|
||
ticker := NewUnalignedTicker(interval, jitter) | ||
defer ticker.Stop() | ||
<-ticker.Elapsed() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't we want to collect immediately for the -test and -once command line arguments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
agent/agent.go
Outdated
switch input.Config.Name { | ||
case "cpu", "mongodb", "procstat": | ||
nulAcc := NewAccumulator(input, nul) | ||
nulAcc.SetPrecision(a.Precision()) | ||
if err := input.Input.Gather(nulAcc); err != nil { | ||
nulAcc.AddError(err) | ||
} | ||
|
||
time.Sleep(500 * time.Millisecond) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lost the comment here, but it'd still be helpful. Very wtf inducing. Or.. This might go well in a separate function, then you could name it gatherOnceAndDiscard or something.
agent/agent.go
Outdated
} | ||
wg.Wait() | ||
|
||
internal.SleepContext(ctx, wait) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do -test and -once really need to sleep?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for the --test-wait
cli option, which I am supporting here in --once mode as well. This option can be used to let service inputs run for a bit, allowing you to test plugins like influxdb_listener.
agent/agent.go
Outdated
acc.AddError(err) | ||
hasErrors = true | ||
} | ||
var wg sync.WaitGroup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have variable shadowing here. It'd be more clear to give this a different name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
agent/agent.go
Outdated
} | ||
} | ||
wg.Wait() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just clarifying that this is a wait on the internal wg, not the external wg.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a function for running the inputs in test mode, but yeah it was.
Just dropping in to say that I was directed here from #7569 (I hadn't seen this PR, sorry!): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The duplication between Run() and test() kind of bothers me but I don't think it would be worth it to try to combine them. Also the way delta metrics are hard coded by name ("cpu", "mongodb", "procstat") is ugly but it's not new code.
This PR contains several changes over #7408:
--test
behavior.--once
with the--test-wait
flag.--once
(let me know if you think this is to terse)--test
, which now runs processors and aggregators at last.There are several behavior changes compared to current behavior:
--test
now runs all inputs, previously stopped on first failure. Exit code is based on agent internal/selfstats.--test
mode now runs all inputs concurrently, this means that output lines will generally be mixed.closes #6190
closes #7408
closes #7415
Required for all PRs: