@@ -577,52 +577,67 @@ Setting the limit incorrectly can have consequences:
577577
578578Consider these guidelines when determining the appropriate limit:
579579
580- ** 1. For Cumulative Temporality:**
581-
582- * Cumulative metrics keep track of every unique attribute combination that has
583- ever been seen, so you need to account for the maximum number of combinations
584- that could exist. Calculate this by multiplying the number of possible values
585- (i.e cardinality) for each attribute.
586- * ** Example:** Using the fruit sales example, if you have a ` name ` attribute
587- that can be either "apple" or "lemon" (2 values) and a ` color ` attribute that
588- can be "red", "yellow", or "green" (3 values), then you could potentially see
589- ` 2 × 3 = 6 ` different combinations. Set your cardinality limit to 6.
590-
591- ** 2. For Delta Temporality:**
592-
593- * Delta temporality resets aggregations after each export cycle, enabling more
594- flexible cardinality management based on actual usage patterns rather than
595- theoretical maximums.
596- * When all possible attribute combinations are known (eg: fruit sales example from
597- above), use the same calculation approach as cumulative temporality.
598- * For dynamic scenarios where not all combinations appear in every export cycle,
599- base the limit on expected total measurements within a single interval.
600- * ** Example 1:** If your application generates at most 1,000 distinct attribute
601- combinations per export interval, set
602- the cardinality limit to 1,000. Delta temporality allows the SDK to reset
603- after each export, accommodating different attribute combinations across
604- intervals without accumulating state.
605- * ** Example 2:** For web applications with known Request Per Second (RPS) rates,
606- calculate the maximum measurements per interval: ` RPS × Export Interval `
607- (assuming one measurement per request). With 500 RPS and a 60-second interval:
608- ` 500 × 60 = 30,000 ` measurements per cycle. Set the cardinality limit to
609- 30,000.
610- * ** High-Cardinality Attributes:** Delta temporality excels with attributes like
611- ` user_id ` where not all values appear simultaneously. Due to delta temporality's
612- state-clearing behavior and the fact that not all users are active within a
613- single interval, you can set a cardinality limit much lower than the total
614- possible cardinality. For example, even with millions of registered users, if
615- only 30,000 are active per interval (based on ` 500 RPS × 60 seconds ` ), the
616- cardinality limit can be set to 30,000 rather than millions.
617- * ** Export Interval Tuning:** Reducing export intervals lowers cardinality
618- requirements. With 30-second intervals: ` 500 × 30 = 15,000 ` measurements,
619- allowing a lower limit. However, balance this against increased serialization
620- and network overhead from more frequent exports.
621-
622- ** 3. Backend Compatibility Considerations:**
623-
624- While delta temporality offers significant advantages for cardinality
625- management, your choice may be constrained by backend support:
580+ ##### Choosing the Right Limit for Cumulative Temporality
581+
582+ Cumulative metrics retain every unique attribute combination that has * ever*
583+ been observed since the start of the process.
584+
585+ * You must account for the theoretical maximum number of attribute combinations.
586+ * This can be estimated by multiplying the number of possible values for each
587+ attribute.
588+
589+ ###### Example - Fruit Sales Scenario
590+
591+ Attributes:
592+
593+ * ` name ` can be "apple" or "lemon" (2 values)
594+ * ` color ` can be "red", "yellow", or "green" (3 values)
595+
596+ You may observe up to 2 × 3 = 6 unique attribute sets.
597+
598+ ** Set the cardinality limit to 6.**
599+
600+ ##### Choosing the Right Limit for Delta Temporality
601+
602+ Delta metrics reset their aggregation state after every export interval. This
603+ allows for more efficient memory usage based on per-interval needs rather than
604+ entire combinations.
605+
606+ * If all combinations are known ahead of time (as in the fruit example), you can
607+ apply the same calculation as with cumulative temporality.
608+ * However, delta really shines when handling high-cardinality dimensions like
609+ ` user_id ` , where the set of active values changes over time and only a few are
610+ active at a given interval.
611+
612+ ###### Example - High Cardinality Attribute Scenario
613+
614+ Attributes:
615+
616+ * ` user_id ` (up to 1 million unique users)
617+ * ` success ` (true or false, 2 values)
618+
619+ Theoretical limit: 1 million users × 2 = 2 million attribute sets
620+
621+ But if only 10,000 users are typically active during a 1-minute export interval:
622+ 10,000 × 2 = 20,000
623+
624+ ** You can set the limit to 20,000, dramatically reducing memory usage during
625+ normal operation.**
626+
627+ ###### Export Interval Tuning
628+
629+ Shorter export intervals further reduce the required cardinality:
630+
631+ * If your interval is halved (e.g., from 60s to 30s), the number of unique
632+ attribute sets seen per interval may also be halved.
633+
634+ But beware: more frequent exports increase CPU/network overhead due to
635+ serialization and transmission costs.
636+
637+ ##### Choosing the Right Limit - Backend Considerations
638+
639+ While delta temporality offers certain advantages for cardinality management,
640+ your choice may be constrained by backend support:
626641
627642* ** Backend Restrictions:** Some metrics backends only support cumulative
628643 temporality. For example, Prometheus requires cumulative temporality and
@@ -700,7 +715,7 @@ Follow these guidelines when deciding where to attach metric attributes:
700715 * * * Meter - level attributes ** : If the dimension applies only to a subset of
701716 metrics (e . g. , library version ), model it as meter - level attributes via
702717 `meter_with_scope `.
703-
718+
704719 ```rust
705720 // Example: Setting meter-level attributes
706721 let scope = InstrumentationScope :: builder (" payment_library" )
@@ -738,3 +753,7 @@ Common pitfalls that can result in missing metrics include:
738753 used , some metrics may be placed in the overflow bucket .
739754
740755// TODO: Add more specific examples
756+
757+ ## References
758+
759+ [OTel Metrics Specification - Supplementary Guidelines ](https : // opentelemetry.io/docs/specs/otel/metrics/supplementary-guidelines/)
0 commit comments