-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat(usage): at-least-once and dynamic sampling #26
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving as a comment because I don't disagree with any of the code written here strongly, but I do have some suggestions about clarifying the config arguments better.
And, some discussion on log levels if we have wrong configs. Just wondering about others' thoughts on this as well!
fix: use one config object for all sampling logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Ty for all the fixes after comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
My only thought was that if we're introducing a "new" API for configuration that we should try and match the official NodeJS client as closely as possible, but I see this would conflict with some other feedback related to some values being multiple types (e.g. boolean and function) - which I agree is maybe a bit confusing as I don't think this is as common in ruby code (probably due to lack of strong type-safety). So looks good to me.
Context
GraphQL Hive Client has an option for at least once sampling that is not included in the ruby gem. As a side, this option also allows dynamic sampling via passing in a function.
Currently,
graphql-ruby-hive
only allows for a fixed sampling rate. With this update, you can input either a fixed sampling rate or a dynamic sampler. You can also choose to sample all distinct operations at least once. See new README.md for specific configuration details.Changes
BasicSampler
created for fixed sampling rates, with the option to sample all operations at least onceDynamicSampler
created for dynamic sampling, with the option to sample all operations at least onceSampler
created to manage sampling logic forUsageReporter
to usecollect_usage_sampling
still works, but will also log a deprecated field warningTesting
Unit tests have been included for all
Sampler
classes and updated forUsageReporter
.This gem was tested locally with the following cases:
Cases were consistent with behaviour documented in README.