-
Notifications
You must be signed in to change notification settings - Fork 90
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
Write out error message when plugin seems have a bug #1024
Conversation
c72550e
to
52338c7
Compare
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.
LGTM!
Just out of curiosity, why aren't following situations considered PluginFaultError
?
I thought they are also caused when plugin does not satisfy specifications.
- plugin outputs bad header
- plugin outputs unsupported version
if err != nil { | ||
|
||
var faultError *metrics.PluginFaultError | ||
if errors.As(err, &faultError) { |
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.
[nit] According to https://pkg.go.dev/errors#As example, maybe it is more idiomatic to check nil
first then detect by errors.As
.
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.
hmmm, I feel like it is not idiomatic. I think the way in the example is just for illustration. That requires more nesting.
For mackerel-agent, "Bad header" means "the first line from a plugin is not
Though, I think it is kind for user to log a message about plugin is unsupported. |
Thanks for your review! |
Mackerel-agent does not write out any error log when fails to parse a broken JSON as a plugin's graph definition.
It makes hard to find out a bug of the plugin.
This PR makes mackerel-agent write out error log when plugin seems have a bug.
Implements
I defined PluginFaultError.
A method PrepareGraphDefs fetches a graph definition from a plugin. By this PR, PrepareGraphDefs will return PluginFaultError, when it faces following two situation,
Mackerel-agent will write out an error log when it catches PluginFaultError.
Behaviour
When plugin provides broken JSON as a graph definition, mackerel-agent write out ERROR log.
When plugin has no graph definition (It should not be a bug), no ERROR log.
DEBUG log is written out if verbose option is on. This behavior is the same as before.