Add "get[Low|High]CardinalityKeyValue()" on "Observation.Context" by ttddyy · Pull Request #3505 · micrometer-metrics/micrometer (original) (raw)

@ttddyy

Add two new methods getLowCardinalityKeyValue and getHighCardinalityKeyValue. Also, changes the internal holder from Set to Map.

Prior to this change, the usage of LinkedHashSet allowed multiple KeyValues with the same key. It was deduped when converted to KeyValues, but it is not an ideal implementation.

This change replaces the LinkedHashSet with LinkedHashMap using the key from KeyValue as a map key. This way, when a new KeyValue is added, it will override the old KeyValue with the same key.