-
Notifications
You must be signed in to change notification settings - Fork 95
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
Log sampler config and validation errors #228
Conversation
config/file_config.go
Outdated
@@ -311,11 +314,13 @@ func (f *fileConfig) validateSamplerConfigs() error { | |||
} | |||
err := f.rules.Unmarshal(i) | |||
if err != nil { | |||
logrus.WithError(err).Warn("Failed to unmarshal sampler rule") |
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.
Looks like these validation errors get logged upstream. Would it make sense to add context to the returned error instead of adding a log statement, so that logging is consolidated to the topmost place?
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.
Yeah, good idea. Maybe something like this to wrap the error?
return fmt.Errorf("Failed to unmarshal sampler rule: %w", err)
I used this as reference on how to extend/wrap an err
.
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.
That looks great!
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.
👍
When loading sampler rules from file based config, it can be difficult to see what rules have been set or any validation errors. This PR logs the sampler config in Debug level and also any unmarshalling / validation errors in Warn level.
When loading sampler rules from file based config, it can be difficult to see what rules have been set or any validation errors.
This PR logs the sampler config in
Debug
level and also any unmarshalling / validation errors inWarn
level.