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

force getVariant to also add to the feature toggle metrics counter #124

Merged
merged 12 commits into from
Dec 22, 2022

Conversation

gastonfournier
Copy link
Contributor

@gastonfournier gastonfournier commented Dec 15, 2022

This forces resolving a variant to correctly add to the feature toggle counter metrics. Also fixes an issue where variants wouldn't get counted for the default/disabled case (brings this SDK inline with the behaviour of its siblings)

Also, other unrelated changes:

  1. Moved unleash_test.go to unleash_mock.go because it was in unleash package and not having any test
  2. Improved the Readme due to an unexisting command

Comment on lines +238 to +239
m.add(name, enabled, 1)
m.metricsChannels.count <- metric{Name: name, Enabled: enabled}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this is necessary but I'm not 100% sure - since we're now incrementing the counter for feature toggles, it makes sense to now add this to the channel

Same as #123 (comment)

@gastonfournier gastonfournier changed the base branch from v3 to force-variants-to-count-toggle-metric December 20, 2022 09:51
@gastonfournier gastonfournier changed the base branch from force-variants-to-count-toggle-metric to v3 December 20, 2022 10:12
@gastonfournier gastonfournier self-assigned this Dec 20, 2022
@gastonfournier gastonfournier marked this pull request as ready for review December 20, 2022 10:16
client.go Outdated
}

// GetVariantWithoutMetrics abstracts away the logic for resolving a variant without metrics
func (uc *Client) GetVariantWithoutMetrics(feature string, options ...VariantOption) *api.Variant {
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 lowercase, we don't want to expose this through the public API (by default uppercase method names are public in go, and lowercase are private).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I didn't know that!

@nunogois learning opportunity here :) https://go.dev/doc/effective_go#names

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link

@chriswk chriswk left a comment

Choose a reason for hiding this comment

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

Looks good to me

@gastonfournier gastonfournier merged commit e2278bd into v3 Dec 22, 2022
@gastonfournier gastonfournier deleted the force-variants-to-count-toggle-metric-v2 branch December 22, 2022 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants