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

Cleanup FQDN host names in SignalFx client #35

Merged
merged 4 commits into from
Sep 8, 2021

Conversation

zorro786
Copy link
Contributor

@zorro786 zorro786 commented Sep 7, 2021

Fixes #32 and #33. Partially address #26.
Also adds "cluster" filter for SignalFx client.

Abdul Qadeer added 2 commits September 7, 2021 11:08
Signed-off-by: Abdul Qadeer <aqadeer@paypal.com>
Add UTs for SignalFx client

Signed-off-by: Abdul Qadeer <aqadeer@paypal.com>
Copy link
Contributor

@ridv ridv left a 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 {
Copy link
Contributor

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)
}

Copy link
Contributor Author

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 {
Copy link
Contributor

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.)

Copy link
Contributor Author

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>
wangchen615
wangchen615 previously approved these changes Sep 7, 2021
Copy link
Contributor

@ridv ridv left a 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())
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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>
@zorro786 zorro786 merged commit 9345bc9 into paypal:master Sep 8, 2021
@zorro786 zorro786 deleted the fix-32 branch September 8, 2021 03:08
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.

SignalFx FetchAllHostMetrics returns FQDN node names
3 participants