Architectural Invariant Design: OpenTelemetry OTLP High-Cardinality Dynamic Attribute Scrubbing & Circuit Breaker Guardrail
OpenTelemetry OTLP High-Cardinality Dynamic Attribute Scrubbing & Circuit Breaker Guardrail defines an industrial-grade behavioral standard for devops engineering. Protects downstream telemetry collector pipelines, ClickHouse/Tempo backends, and in-memory trace buffers from catastrophic OOM crashes by dynamically bounding, hashing, and shedding unindexed dynamic runtime span attributes. Implements runtime span processors with token bucket rate limiters, strict key allowlists, and deterministic truncated SHA-256 hashing for dynamic entity identifiers. 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 | Unbounded Runtime Span Attribute Injection Inducing OTLP Collector Memory Exhaustion and Storage Explosion | 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 sanitize span attributes through a dedicated SpanProcessor or bounded telemetry wrapper before dispatching to BatchSpanProcessor.
Engineers MUST ALWAYS sanitize span attributes through a dedicated SpanProcessor or bounded telemetry wrapper before dispatching to BatchSpanProcessor.
Engineers MUST NOT inject raw dynamic identifiers (such as session tokens, raw user IDs, query strings, or memory addresses) directly into OTLP span attributes.
Engineers MUST NOT inject raw dynamic identifiers (such as session tokens, raw user IDs, query strings, or memory addresses) directly into OTLP span attributes.
Dynamic entity identifiers (e.g., tenant-specific UUIDs, transaction identifiers) MUST be masked or deterministically hashed using truncated SHA-256 (e.g., 12-char hex) when low-cardinality aggregation is required.
Dynamic entity identifiers (e.g., tenant-specific UUIDs, transaction identifiers) MUST be masked or deterministically hashed using truncated SHA-256 (e.g., 12-char hex) when low-cardinality aggregation is required.
Services MUST enforce hard caps on span attributes
Services MUST enforce hard caps on span attributes: MAX_ATTRIBUTES_PER_SPAN <= 32, MAX_ATTRIBUTE_KEY_LENGTH <= 64 bytes, and MAX_ATTRIBUTE_VALUE_LENGTH <= 256 bytes.
The telemetry layer MUST implement an in-memory circuit breaker that sheds non-critical span attributes or drops spans entirely when memory pressure exceeds 85% or attribute ingest rates exceed safe bucket capacities.
The telemetry layer MUST implement an in-memory circuit breaker that sheds non-critical span attributes or drops spans entirely when memory pressure exceeds 85% or attribute ingest rates exceed safe bucket capacities.
Span attribute keys MUST be constrained to a strictly defined, validated allowlist or hierarchical namespace (e.g., 'app.*', 'db.system', 'http.route').
Span attribute keys MUST be constrained to a strictly defined, validated allowlist or hierarchical namespace (e.g., 'app.*', 'db.system', 'http.route').
Dynamic keys constructed via string concatenation (e.g., `span.setAttribute(`user_${id}`, value)`) are STRICTLY FORBIDDEN.
Dynamic keys constructed via string concatenation (e.g., `span.setAttribute(`user_${id}`, value)`) are STRICTLY FORBIDDEN.
Frequently Asked Technical Questions
Common questions developers face when configuring AI coding assistants for this stack:
Q:Why is OpenTelemetry OTLP High-Cardinality Dynamic Attribute Scrubbing & Circuit Breaker Guardrail critical for AI coding assistants?
Protects downstream telemetry collector pipelines, ClickHouse/Tempo backends, and in-memory trace buffers from catastrophic OOM crashes by dynamically bounding, hashing, and shedding unindexed dynamic runtime span attributes. Implements runtime span processors with token bucket rate limiters, strict key allowlists, and deterministic truncated SHA-256 hashing for dynamic entity identifiers. 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 (Unbounded Runtime Span Attribute Injection Inducing OTLP Collector Memory Exhaustion and Storage Explosion) 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.