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

improvements: clean code #32

Merged
merged 12 commits into from
Dec 12, 2023
Merged

improvements: clean code #32

merged 12 commits into from
Dec 12, 2023

Conversation

shahbazn
Copy link
Contributor

@shahbazn shahbazn commented Nov 29, 2023

fixes netx-145

@shahbazn shahbazn changed the title Netx 145 improve logs improvements: clean code Nov 30, 2023
@shahbazn shahbazn marked this pull request as ready for review December 6, 2023 09:43
@shahbazn shahbazn requested a review from kayano December 6, 2023 10:04
pkg/config/config.go Outdated Show resolved Hide resolved
rpcs := cfg.GetRPCsMap()
rpcs, err := cfg.GetRPCsMap(paths)
if err != nil {
log.Fatal(err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

Validating a config is a nice feature but what if someone wants to use the exporter only for some of the paths? Maybe we should introduce a flag to validate and terminate exporter by default but give also an option to log a warning and continue if some RPCs are missing in the config. It will make an exporter useful for someone using it only for cosmos_wallet_balance metric

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Might be a good idea to have a flag but perhaps warrants a separate PR when the need arrives? I would like to keep the scope of this PR limited to current usecase


log.Debug("Stop collecting", zap.String("metric", walletBalanceMetricName))
}
var ctx = context.Background()
Copy link
Contributor

@kayano kayano Dec 6, 2023

Choose a reason for hiding this comment

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

Why to create a package global variable? Isn't it better to add ctx property to each collector struct which needs it?

Copy link
Contributor Author

@shahbazn shahbazn Dec 7, 2023

Choose a reason for hiding this comment

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

did this to please the linter :) I did consider collector level context but at the end the separation is only code files but the other variables are also global to package level e.g. clientExpiry. Linter liked this way better, is it a blocker? I am fine either way

Copy link
Contributor

Choose a reason for hiding this comment

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

up to you, doesn't matter much

pkg/config/config.go Outdated Show resolved Hide resolved
@shahbazn shahbazn requested a review from kayano December 7, 2023 12:32

port := urlParsed.Port()

// Port must be a iny <= 65535.
Copy link
Contributor

Choose a reason for hiding this comment

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

typo?

@shahbazn shahbazn merged commit 96f9837 into main Dec 12, 2023
3 checks passed
@shahbazn shahbazn deleted the netx-145-improve-logs branch December 12, 2023 10:27
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.

2 participants