hash_context_with_host

Function hash_context_with_host 

Source
pub fn hash_context_with_host<I, I2, T, T2>(
    name: &str,
    host: Option<&str>,
    tags: I,
    origin_tags: I2,
) -> (ContextKey, TagSetKey)
where I: IntoIterator<Item = T>, T: AsRef<str>, I2: IntoIterator<Item = T2>, T2: AsRef<str>,
Expand description

Hashes a metric context with an explicit host dimension, using a provided set to track duplicate tags.

Takes a metric name, optional host, an iterator of tags, and an iterator of origin tags, and returns a tuple containing a unique hash key for the overall context, and a unique hash key for the non-origin tags by themselves. The host is considered part of overall context identity, but not part of the non-origin tag set.

All tags are hashed in an order-oblivious (XOR) manner, which allows tags to be hashed in any order while still resulting in the same overall hash. This function is not oblivious to the actual tag values themselves, though, so differences such as case (lower vs upper) or leading/trailing whitespace will influence the resulting hash. The host and metric name are order-dependent scalar context fields, not tags.

If a tag is seen more than once, it will be ignored and not included in the overall hash. This function requires the caller to provide the hash set used for tracking duplicates, and is more efficient than hash_context which allocates a new hash set each time.

Returns a hash that uniquely identifies the combination of name, host, tags, and origin of the value. An unset host and an explicitly empty host are distinct contexts.