Skip to content
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

Merged
merged 3 commits into from
Mar 24, 2021
Merged

Conversation

MikeGoldsmith
Copy link
Contributor

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.

@MikeGoldsmith MikeGoldsmith requested a review from a team March 22, 2021 12:52
@@ -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")
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks great!

@MikeGoldsmith MikeGoldsmith requested a review from vreynolds March 24, 2021 11:06
Copy link
Member

@robbkidd robbkidd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@MikeGoldsmith MikeGoldsmith merged commit 6cd648c into main Mar 24, 2021
@MikeGoldsmith MikeGoldsmith deleted the mike/log-rules branch March 24, 2021 13:19
ghost pushed a commit to opsramp/tracing-proxy that referenced this pull request Jul 5, 2024
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants