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

sc-13403 Added timezone parameter #4

Merged
merged 9 commits into from
Sep 19, 2024
Merged

sc-13403 Added timezone parameter #4

merged 9 commits into from
Sep 19, 2024

Conversation

Gyan-Gupta-Rtsl
Copy link
Contributor

Story_card: https://app.shortcut.com/simpledotorg/story/13403/minor-fixes-in-sendgrid-prometheus-exporter

What:
Added timezone to the exporter
Why:
As ethiopia_production and production(for other countries) has different timezones in their respective sendgrid accounts,
so to get the correct data to monitor in prometheus.

Copy link
Contributor

@tfidfwastaken tfidfwastaken left a comment

Choose a reason for hiding this comment

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

Requested some changes.

Additionally, ensure that gofmt is run over the code, to automatically fix any style issues (if this wasn't already done).

main.go Outdated
@@ -22,6 +22,7 @@ type Config struct {
SendGridAccounts []struct {
AccountName string `yaml:"account_name"`
APIKey string `yaml:"api_key"`
TimeZone string `yaml:"time_zone"` // Added TimeZone field
Copy link
Contributor

Choose a reason for hiding this comment

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

chore: this comment should be removed.

Comments should only describe things that are not obvious from reading the code.

Suggested change
TimeZone string `yaml:"time_zone"` // Added TimeZone field
TimeZone string `yaml:"time_zone"`

Copy link
Contributor

Choose a reason for hiding this comment

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

I would additionally suggest sweeping over this code again and removing all such code comments, even if they were merged in last time.

main.go Outdated
}
sendgridExporter := sendgrid.NewExporter(apiKeys)
sendgridExporter := sendgrid.NewExporter(apiKeys, timeZones) // Passed timeZones to Exporter
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: I am thinking that a better interface would be to take multiple structs of configs as opposed to multiple maps where the ordering of the maps needs to be consistent.

confer: Data Clumps

Comment on lines 84 to 86
if !exists {
timeZone = time.UTC // Default to UTC if the time zone is not provided
}
Copy link
Contributor

Choose a reason for hiding this comment

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

quibble: The config reading code guaranteed a default value of UTC, this is redundant.

But if we refactor away the data clump, this whole thing wouldn't exist anyway. We would be able to access the timezone with account.TimeZone.


log.Printf("timeUntilExpiration: %+v", timeUntilExpiration)
Copy link
Contributor

Choose a reason for hiding this comment

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

question: why are we logging this?

Comment on lines 22 to 39
client: NewClient(apiKeys),
client: NewClient(apiKeys), // Pass apiKeys map directly
timeZones: timeZones, // Pass timeZones map
Copy link
Contributor

Choose a reason for hiding this comment

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

chore: this comment should be removed.

reason: comments should only describe things that are not obvious from reading the code.

timeZones := map[string]*time.Location{
"mockAccount": time.UTC,
}
exporter := NewExporter(accountNames, timeZones)
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: This test case won't compile, because the NewExporter function only takes one argument.

Please ensure that all the test cases pass before marking the code for review.

@Gyan-Gupta-Rtsl Gyan-Gupta-Rtsl merged commit 58ae6d1 into master Sep 19, 2024
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