[trace] Add optional flags to support flexible jaeger configs #8199
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 flag
is 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(
float64
for example) with a boolean flag to track whetherSet()
wasever called on the flag. Since, for the jaeger sampler params, we only
need a
string
for the sampler type and afloat64
for the samplingrate, I only implemented
OptionalFlag
for 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
newJaegerTracerFromEnv
more 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 [email protected]
Examples!
(for all examples
pwd
is./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