samshers
samshers

Reputation: 3690

Micrometer Observation lowCardinalityKeyValue and highCardinalityKeyValue uses/use cases?

I do understand micrometer observation. And i see that it supports adding lowCardinalityKeyValue and highCardinalityKeyValue with something like below -

Observation observation = Observation.start("my.operation", registry)
    .contextualName("span name")
    .lowCardinalityKeyValue("this.tag", "will end up as a meter tag and a span tag")
    .highCardinalityKeyValue("but.this.tag", "will end up as a span tag only");

I do understand what these KeyValues mean, but can some one give a real world use case where such distinguishing make more sense.

Upvotes: 0

Views: 463

Answers (1)

Jonatan Ivanov
Jonatan Ivanov

Reputation: 6931

This article might help by explaining what cardinality means, what difference it makes for metrics and why it is important to distinguish low and high cardinality (with examples): https://develotters.com/posts/high-cardinality/

The official documentation of Micrometer also talks about this (with examples): https://docs.micrometer.io/micrometer/reference/observation/introduction.html

The javadoc of the Observation class has an example as well.

But here are a few other:

  • High cardinality

    • UserId (if you have enough users)
    • Email address (if you have enough users)
    • Any type of resource id, e.g.: productId, orderId, etc. (if you have enough of them)
    • HTTP URL (/users/12345)
    • Any type of user input or practically unbounded set of data
  • Low cardinality

    • Gender of the user
    • Country where the user lives
    • Color of the product (Let's say we know the name of 16 colors)
    • HTTP URL template (/users/{id})
    • Sanitized/normalized user input that is mapped to a low cardinality set of data

Upvotes: 0

Related Questions