-
Notifications
You must be signed in to change notification settings - Fork 35
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
Cleanup FQDN host names in SignalFx client #35
Conversation
Signed-off-by: Abdul Qadeer <aqadeer@paypal.com>
Add UTs for SignalFx client Signed-off-by: Abdul Qadeer <aqadeer@paypal.com>
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.
Overall LGTM. Left some comments
main.go
Outdated
func init() { | ||
logLevel, _ := os.LookupEnv("LOG_LEVEL") | ||
parsedLogLevel, err := log.ParseLevel(logLevel) | ||
if err != nil { |
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 think this should be err == nil
.
It may be a good idea to log a message saying there was an error parsing the log level failed and we're falling back on the library default if the environment variable was indeed set.
Something like:
logLevel, evnLogLevelSet := os.LookupEnv("LOG_LEVEL")
parsedLogLevel, err := log.ParseLevel(logLevel)
if evnLogLevelSet && err != nil {
log.Info("Unable to parse log level set. Defaulting to ", log.GetLevel())
}
if err == nil {
log.SetLevel(parsedLogLevel)
}
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.
Good catch, updated
|
||
// This function extracts host name from its FQDN | ||
// This assumes that host names themselves don't contain "." | ||
func cleanUpHostname(hostname string) string { |
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.
Can you give an example of the input and output expected by this function? (It may also be worth putting this in as a comment.)
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.
Added, also modified var/function names to make it clearer
Signed-off-by: Abdul Qadeer <aqadeer@paypal.com>
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 minus one subtle bug 🐛
Fix it, then ship it!
main.go
Outdated
logLevel, evnLogLevelSet := os.LookupEnv("LOG_LEVEL") | ||
parsedLogLevel, err := log.ParseLevel(logLevel) | ||
if evnLogLevelSet && err != nil { | ||
log.Info("unable to parse log level set; defaulting to: %v", log.GetLevel()) |
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.
log.Info("unable to parse log level set; defaulting to: %v", log.GetLevel()) | |
log.Infof("unable to parse log level set; defaulting to: %v", log.GetLevel()) |
Signed-off-by: Abdul Qadeer <aqadeer@paypal.com>
Fixes #32 and #33. Partially address #26.
Also adds "cluster" filter for SignalFx client.