Cardinality Explosion
What you'll learn: How high-cardinality tags multiply trace span volume and strategies to limit cardinality in distributed tracing.
The Problem
Cardinality is the number of unique values a tag or attribute can have. In tracing, adding tags like user_id, request_id, or session_id to spans creates cardinality explosion—each unique combination of tag values produces a distinct trace or span entry, multiplying your storage requirements exponentially.
Imagine a library catalog. Organizing by genre (low cardinality: ~20 values) is manageable. But indexing by every reader's name who borrowed each book (high cardinality: thousands/millions) creates an unmanageable explosion of catalog entries.
Why It Matters
High-cardinality tags can:
- Overwhelm storage backends with millions of unique span combinations
- Slow queries as indexes grow massive
- Increase costs dramatically (you're storing and querying far more data)
- Degrade performance of trace collection pipelines
A single tag like user_id with 1M users on a service processing 100M requests/day creates astronomical storage needs.
Strategies to Limit Cardinality
- Avoid user-specific identifiers as span tags—use them as searchable attributes only when essential
- Sample more aggressively for high-cardinality scenarios (as covered in your sampling lessons)
- Hash or bucket values (e.g.,
user_bucket: hash(user_id) % 100reduces 1M users to 100 buckets) - Use span events for contextual data instead of creating new tag dimensions
- Limit tag sets to meaningful dimensions for debugging (service, endpoint, status_code)
Think dimensions, not identifiers—trace systems excel at showing patterns across services, not tracking individual users.
Key Takeaway:
High-cardinality tags like user IDs or request IDs cause exponential span volume growth; control cardinality by avoiding unique identifiers as dimensions, sampling strategically, and bucketing values when necessary.