[trace] Add optional flags to support flexible jaeger configs#8199
Merged
ajm188 merged 2 commits intovitessio:mainfrom Jun 4, 2021
Merged
[trace] Add optional flags to support flexible jaeger configs#8199ajm188 merged 2 commits intovitessio:mainfrom
ajm188 merged 2 commits intovitessio:mainfrom
Conversation
added 2 commits
May 27, 2021 21:53
Closes vitessio#8198. A common pain point with the standard `package flag` is the inability to tell whether a flag was set on the command line or not. You can check against the default value, but that's not perfect either, because then you cannot tell the difference between a flag that was not specified at all and a flag that was set to exactly the default value. Enter `OptionalFlag`. We define some structs that wrap a primitive (`float64` for example) with a boolean flag to track whether `Set()` was ever called on the flag. Since, for the jaeger sampler params, we only need a `string` for the sampler type and a `float64` for the sampling rate, I only implemented `OptionalFlag` for those two types for now. Plus, all of this becomes obsolete if we move to `cobra`, so I wasn't highly-motivated to implement this interface for every primitive type (and we can also add more implementations if we need them). Anyway. Armed with our optional flags, we can make the configuration in `newJaegerTracerFromEnv` more sophisticated, giving flags precedence over environment variables, but also not ignoring environment variables (which we were previously doing by indiscriminately setting the sampler type to `const`). Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
doeg
approved these changes
May 28, 2021
ajm188
pushed a commit
to tinyspeck/vitess
that referenced
this pull request
Jul 6, 2021
…figs [trace] Add optional flags to support flexible jaeger configs Signed-off-by: Andrew Mason <amason@slack-corp.com>
7 tasks
ajm188
pushed a commit
to tinyspeck/vitess
that referenced
this pull request
Jul 23, 2021
…figs [trace] Add optional flags to support flexible jaeger configs Signed-off-by: Andrew Mason <amason@slack-corp.com>
8 tasks
33 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #8198.
Description
A common pain point with the standard
package flagis the inability totell whether a flag was set on the command line or not. You can check
against the default value, but that's not perfect either, because then
you cannot tell the difference between a flag that was not specified at
all and a flag that was set to exactly the default value.
Enter
OptionalFlag. We define some structs that wrap a primitive(
float64for example) with a boolean flag to track whetherSet()wasever called on the flag. Since, for the jaeger sampler params, we only
need a
stringfor the sampler type and afloat64for the samplingrate, I only implemented
OptionalFlagfor those two types for now.Plus, all of this becomes obsolete if we move to
cobra, so I wasn'thighly-motivated to implement this interface for every primitive type
(and we can also add more implementations if we need them).
Anyway. Armed with our optional flags, we can make the configuration in
newJaegerTracerFromEnvmore sophisticated, giving flags precedenceover environment variables, but also not ignoring environment variables
(which we were previously doing by indiscriminately setting the sampler
type to
const).Signed-off-by: Andrew Mason amason@slack-corp.com
Examples!
(for all examples
pwdis./examples/local)No flags set, no environment variables set
Configure sampler type via environment
Bad sampler type (mostly to check that jaeger would complain, and that we didn't need extra validation)
Overriding on the command line
Checklist
Deployment Notes