Architectural Invariant Design: OpenTelemetry In-Process Span Attribute Cardinality Governor
OpenTelemetry In-Process Span Attribute Cardinality Governor defines an industrial-grade behavioral standard for devops engineering. Enforces pre-export filtering and sanitization of dynamic OpenTelemetry span attributes directly within the in-process SDK boundary. Prevents downstream TSDB (e.g., Prometheus, Cortex, ClickHouse, Mimir) index exhaustion caused by unbounded dynamic values like raw UUIDs, timestamps, and unrestricted user input injected as metric labels or indexed span attributes. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.
Hazard Analysis: What Breaks Without This Rule
The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:
| Failure Mode | AI Symptom (The Anti-Pattern) | Severity | Production Impact & Remedy |
|---|---|---|---|
| AI Hallucination & Deprecation Drift | Unchecked dynamic values injected as high-cardinality span attributes causing downstream TSDB/APM ingest OOM and indexing death | Critical | Violating this industrial standard introduces regression bugs, security risks, and unexpected runtime failures in production. Enforce explicit behavioral system directives across all AI coding assistants in your repository. |
| Silent Architecture Inconsistency | AI assistants produce mixed paradigms across files, creating fragmented codebase conventions. | Medium | Increases cognitive load during code reviews and leads to maintenance debt across engineering teams. Pin project conventions in .cursor/rules, CLAUDE.md, and AGENTS.md so all team agents follow identical guardrails. |
Step-by-Step Production Directives
Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:
Engineers MUST ALWAYS implement a custom SpanProcessor (or SpanExporter wrapper) in the OpenTelemetry SDK that drops or redacts high-cardinality values before spans reach the BatchSpanProcessor or network exporter.
Engineers MUST ALWAYS implement a custom SpanProcessor (or SpanExporter wrapper) in the OpenTelemetry SDK that drops or redacts high-cardinality values before spans reach the BatchSpanProcessor or network exporter.
Engineers MUST NOT inject unbounded entity identifiers (UUIDs, transaction IDs, session tokens, arbitrary user inputs) as raw span attribute keys or unmasked values when spans are projected into downstream TSDB metric labels.
Engineers MUST NOT inject unbounded entity identifiers (UUIDs, transaction IDs, session tokens, arbitrary user inputs) as raw span attribute keys or unmasked values when spans are projected into downstream TSDB metric labels.
Engineers MUST configure hard limits on span attributes using `SpanLimits` (e.g., `attributeCountLimit`, `attributeValueLengthLimit`) in the TracerProvider configuration to prevent payload bloat.
Engineers MUST configure hard limits on span attributes using `SpanLimits` (e.g., `attributeCountLimit`, `attributeValueLengthLimit`) in the TracerProvider configuration to prevent payload bloat.
SpanProcessor implementations MUST replace dynamic path segments (e.g., `/users/3fa85f64-5717-4562-b3fc-2c963f66afa6`) with parameterized templates (e.g., `/users/
SpanProcessor implementations MUST replace dynamic path segments (e.g., `/users/3fa85f64-5717-4562-b3fc-2c963f66afa6`) with parameterized templates (e.g., `/users/:id`) in `http.route` and `http.target`.
Telemetry services MUST log a rate-limited warning metric or internal diagnostic event when an attribute key is dropped due to cardinality governor policy violations.
Telemetry services MUST log a rate-limited warning metric or internal diagnostic event when an attribute key is dropped due to cardinality governor policy violations.
Frequently Asked Technical Questions
Common questions developers face when configuring AI coding assistants for this stack:
Q:Why is OpenTelemetry In-Process Span Attribute Cardinality Governor critical for AI coding assistants?
Enforces pre-export filtering and sanitization of dynamic OpenTelemetry span attributes directly within the in-process SDK boundary. Prevents downstream TSDB (e.g., Prometheus, Cortex, ClickHouse, Mimir) index exhaustion caused by unbounded dynamic values like raw UUIDs, timestamps, and unrestricted user input injected as metric labels or indexed span attributes. Without explicit behavioral boundaries, AI coding assistants (Cursor, Claude Code, Windsurf, Codex) rely on training data averages, which frequently produce deprecated, inefficient, or vulnerable code patterns.
Q:How does adopting this rule prevent AI hallucinations?
This rule explicitly declares what the AI must avoid (Unchecked dynamic values injected as high-cardinality span attributes causing downstream TSDB/APM ingest OOM and indexing death) and prescribes verified positive examples. Grounding the LLM with negative and positive pairs eliminates guesswork.
Q:Which AI coding environments are supported?
This specification is multi-platform compatible: Cursor (.cursor/rules/*.mdc & .cursorrules), Anthropic Claude Code (CLAUDE.md), Windsurf (.windsurfrules), Codex / Cline (AGENTS.md), and GitHub Copilot (.github/copilot-instructions.md).
Q:Can I combine this rule with other technology stacks?
Yes. Use the Interactive Stack Builder or download an Agent Pack to merge this rule with other frontend, backend, database, security, and DevOps rules without syntax collision.