-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Validate low cardinality keys #6713
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
Validate low cardinality keys #6713
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.
I'm not sure I'd validate this by default. Observations are multiple layers abstracted away from Prometheus, which is the only system I'm aware of that has this limitation, and even then, the limitation is only in the Prometheus Java client. I guess we're trying to help people writing instrumentation where they don't know what ObservationHandler might be in use at runtime. Logging a warning probably isn't very helpful when running tests because it's likely to go unnoticed. Given that, I'm not sure what alternative there is. Maybe this is the best we can do.
|
I added a component to be able to turn features on/off. TestObservationRegistry.create(new TestObservationRegistry.Capability[]{});or maybe adding an TestObservationRegistry.create(EMPTY); |
|
I'd be fine with it being checked by default if there's a straightforward way to disable it. These kinds of configurations options tend to get complicated easily, though. |
|
I enabled by default and added a constant to disable it easily: TestObservationRegistry.create(ALL_CAPABILITIES_DISABLED);I guess another alternative to make these things configurable is boolean flags with setters or a builder which I think they can get complicated the same way as the enums, not sure what better options we have. |
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.
A builder is most future-proof, I think, but we can try with this for now and switch to a builder later if it makes more sense.
Observations with the same name should have the same set of low cardinality keys
fa7d59b to
d6de427
Compare
|
Let's use a builder from the beginning since it can prevent making the enum public. |
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.
LGTM
Observations with the same name should have the same set of low cardinality keys.
Example 1:
Example 1 is valid since all the observations with the same name ("test") has the same set of low cardinality keys ("color").
Example 2:
Example 2 is invalid since the second observation is missing a key the first one has ("color") and the third observation is not only missing a key the first one has ("color") but it also has an extra key the first one does not have ("status").
If the validator detects this, it will give you an error like this:
In order to fix it, you should always add the same set of keys to the Observation. If some data is missing, you can signal it with a
"none"/"unknown"/etc. value:In your codebase, this means if you attach keyvalues conditionally:
you should only apply the condition to the value only:
If you want to turn this validation off (not recommended), you can do it this way: