Architectural Invariant Design: OpenTelemetry Collector Tail-Sampling and Ingestion Cardinality Limits
OpenTelemetry Collector Tail-Sampling and Ingestion Cardinality Limits defines an industrial-grade behavioral standard for devops engineering. Enforces adaptive tail-based sampling and strict attribute cardinality clamping within OpenTelemetry Collector pipelines. Prevents storage backend exhaustion and degraded query performance by deterministically capturing high-value error/latency traces while dropping mundane telemetry and sanitizing dynamic high-cardinality attributes at ingestion. 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 Telemetry Pass-Through and Raw Dynamic Span Attributes Causing Storage OOM and Cardinality 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:
Pipelines MUST ALWAYS position the `memory_limiter` processor as the first processor in traces, metrics, and logs pipelines to protect the collector process from out-of-memory crashes.
Pipelines MUST ALWAYS position the `memory_limiter` processor as the first processor in traces, metrics, and logs pipelines to protect the collector process from out-of-memory crashes.
Pipelines MUST ALWAYS configure `tail_sampling` with multi-tier composite policies
Pipelines MUST ALWAYS configure `tail_sampling` with multi-tier composite policies: 100% evaluation for spans with `status.code == STATUS_CODE_ERROR`, 100% for latency excursions (e.g. > 1500ms), and rate-limited probabilistic sampling (e.g. 1-5%) for nominal HTTP/gRPC success codes.
Engineers MUST NOT allow unparameterized URLs, raw database queries with literal values, raw JWTs, or unbounded entity IDs (like generated session UUIDs) to persist as un-clamped span attributes.
Engineers MUST NOT allow unparameterized URLs, raw database queries with literal values, raw JWTs, or unbounded entity IDs (like generated session UUIDs) to persist as un-clamped span attributes.
Processors MUST use OTTL (`transform` processor) or regex replacement to sanitize dynamic high-cardinality attributes, normalizing endpoints to parameterized routing patterns (e.g., replacing `/users/12345/profile` with `/users/{id}/profile`).
Processors MUST use OTTL (`transform` processor) or regex replacement to sanitize dynamic high-cardinality attributes, normalizing endpoints to parameterized routing patterns (e.g., replacing `/users/12345/profile` with `/users/{id}/profile`).
Services MUST define an explicit `decision_wait` in `tail_sampling` that accommodates the 99th percentile end-to-end trace assembly time without exceeding the Collector memory footprint limits.
Services MUST define an explicit `decision_wait` in `tail_sampling` that accommodates the 99th percentile end-to-end trace assembly time without exceeding the Collector memory footprint limits.
Components NEVER export traces directly to storage clusters using unbuffered or head-only 100% sampling in production environments.
Components NEVER export traces directly to storage clusters using unbuffered or head-only 100% sampling in production environments.
Frequently Asked Technical Questions
Common questions developers face when configuring AI coding assistants for this stack:
Q:Why is OpenTelemetry Collector Tail-Sampling and Ingestion Cardinality Limits critical for AI coding assistants?
Enforces adaptive tail-based sampling and strict attribute cardinality clamping within OpenTelemetry Collector pipelines. Prevents storage backend exhaustion and degraded query performance by deterministically capturing high-value error/latency traces while dropping mundane telemetry and sanitizing dynamic high-cardinality attributes at ingestion. 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 Telemetry Pass-Through and Raw Dynamic Span Attributes Causing Storage OOM and Cardinality 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.