Architectural Invariant Design: OpenTelemetry Distributed Exemplar Cardinality Fencing and Reservoir Bounding
OpenTelemetry Distributed Exemplar Cardinality Fencing and Reservoir Bounding defines an industrial-grade behavioral standard for devops engineering. Enforces strict reservoir sampling bounds and attribute fencing on OpenTelemetry metric exemplars to prevent memory leaks and downstream time-series database (TSDB) indexing explosions. Unbounded exemplar propagation or injecting high-cardinality business labels into metric exemplar buffers compromises Prometheus, Mimir, and Thanos aggregators. All metric providers must explicitly define exemplar filters, bound reservoir cell sizes, and restrict exemplar baggage strictly to standardized W3C trace 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 | Attaching raw user or request metadata as un-sampled exemplar baggage inside metric aggregators without cardinality filters | 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 restrict metric exemplar attachments exclusively to standard W3C trace context keys (`trace_id`, `span_id`).
Engineers MUST ALWAYS restrict metric exemplar attachments exclusively to standard W3C trace context keys (`trace_id`, `span_id`).
Engineers MUST NOT inject business entity identifiers, tenant IDs, email addresses, or unhashed request parameters into exemplar attribute bags.
Engineers MUST NOT inject business entity identifiers, tenant IDs, email addresses, or unhashed request parameters into exemplar attribute bags.
Services MUST configure an explicit `ExemplarReservoir` (such as a fixed-size `AlignedHistogramBucketExemplarReservoir`) with deterministic memory bounds for all histogram and counter metric views.
Services MUST configure an explicit `ExemplarReservoir` (such as a fixed-size `AlignedHistogramBucketExemplarReservoir`) with deterministic memory bounds for all histogram and counter metric views.
Code SHOULD enforce `TraceBasedExemplarFilter` or sample-rate bounded filters rather than `AlwaysSampleFilter` in high-throughput ingress pathways.
Code SHOULD enforce `TraceBasedExemplarFilter` or sample-rate bounded filters rather than `AlwaysSampleFilter` in high-throughput ingress pathways.
Components NEVER instantiate unbounded custom in-memory accumulators that allow linear memory expansion per active time series.
Components NEVER instantiate unbounded custom in-memory accumulators that allow linear memory expansion per active time series.
Frequently Asked Technical Questions
Common questions developers face when configuring AI coding assistants for this stack:
Q:Why is OpenTelemetry Distributed Exemplar Cardinality Fencing and Reservoir Bounding critical for AI coding assistants?
Enforces strict reservoir sampling bounds and attribute fencing on OpenTelemetry metric exemplars to prevent memory leaks and downstream time-series database (TSDB) indexing explosions. Unbounded exemplar propagation or injecting high-cardinality business labels into metric exemplar buffers compromises Prometheus, Mimir, and Thanos aggregators. All metric providers must explicitly define exemplar filters, bound reservoir cell sizes, and restrict exemplar baggage strictly to standardized W3C trace 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 (Attaching raw user or request metadata as un-sampled exemplar baggage inside metric aggregators without cardinality filters) 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.