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

chore: oauth v2 stats refactor #5262

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

sanpj2292
Copy link
Contributor

@sanpj2292 sanpj2292 commented Nov 4, 2024

Description

The way in which stats are written is not easily readable. Through this PR, we are trying to make the stat emission in oauthv2 module a bit more developer friendly and readable

Linear Ticket

Resolves INT-2744

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

) (int, *AuthResponse, error) {
actionType := strings.Join(strings.Fields(strings.ToLower(logTypeName)), "_")
Copy link
Contributor Author

@sanpj2292 sanpj2292 Nov 4, 2024

Choose a reason for hiding this comment

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

For reference

> strings.Join(strings.Fields(strings.ToLower("Refresh Token")), "_")
refresh_token

@sanpj2292 sanpj2292 self-assigned this Nov 4, 2024
Copy link

codecov bot commented Nov 4, 2024

Codecov Report

Attention: Patch coverage is 93.54839% with 6 lines in your changes missing coverage. Please review.

Project coverage is 74.79%. Comparing base (34a1caf) to head (48ec02b).

Files with missing lines Patch % Lines
services/oauth/v2/oauth.go 94.64% 3 Missing ⚠️
services/oauth/v2/utils.go 50.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5262      +/-   ##
==========================================
+ Coverage   74.74%   74.79%   +0.04%     
==========================================
  Files         433      433              
  Lines       60926    60942      +16     
==========================================
+ Hits        45542    45580      +38     
+ Misses      12862    12846      -16     
+ Partials     2522     2516       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

This PR is considered to be stale. It has been open 20 days with no further activity thus it is going to be closed in 7 days. To avoid such a case please consider removing the stale label manually or add a comment to the PR.

@github-actions github-actions bot added the Stale label Nov 29, 2024
@sanpj2292 sanpj2292 removed the Stale label Dec 5, 2024
@ktgowtham ktgowtham requested a review from Sidddddarth December 5, 2024 09:06
Comment on lines +53 to +59
func (m *OAuthStatsHandler) mergeTags(tags stats.Tags) stats.Tags {
allTags := m.defaultTags
for key, value := range tags {
allTags[key] = value
}
s.stats.NewTaggedStat(s.statName, stats.CountType, statsTags).Increment()
return allTags
}
Copy link
Member

Choose a reason for hiding this comment

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

This should be the other way around. If we don't want to put values into m.defaultTags.

func (m *OAuthStatsHandler) mergeTags(tags stats.Tags) stats.Tags {
	for key, value := range m.defaultTags {
		tags[key] = value
	}
	return tags
}

Add a map lookup check if you don't want to override with default.

Comment on lines +61 to +63
func (m *OAuthStatsHandler) getStatName(suffix string) string {
return strings.Join([]string{"oauth_action", suffix}, "_")
}
Copy link
Member

Choose a reason for hiding this comment

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

minor
Can inline this function's call.

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