This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: otel-streaming-tail-sampling-memory-bound-invariant

OpenTelemetry OTLP Streaming Tail-Sampling Memory Bound Invariant

Enforces deterministic ring-buffer ceilings, preemptive memory limiter processors, and backpressure-driven probabilistic trace shedding on OpenTelemetry collectors. Prevents catastrophic OOM cascading failovers across collector pools during telemetry bursts and downstream partition events.

Prohibited Anti-Pattern: Unbounded tail-sampling trace buffers without prioritized memory limiter processors or adaptive shedding

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: OpenTelemetry OTLP Streaming Tail-Sampling Memory Bound Invariant - Enforces deterministic ring-buffer ceilings, preemptive memory limiter processors, and backpressure-driven probabilistic trace shedding on OpenTelemetry collectors. Prevents catastrophic OOM cascading failovers across collector pools during telemetry bursts and downstream partition events.
globs: **/otel-collector*.yaml, **/otel-collector*.yml, k8s/**/collector*.yaml, deploy/**/otel*.yaml, terraform/**/otel*.tf
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/otel-streaming-tail-sampling-memory-bound-invariant"
---

# OpenTelemetry OTLP Streaming Tail-Sampling Memory Bound Invariant

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Unbounded tail-sampling trace buffers without prioritized memory limiter processors or adaptive shedding

## System Constraints
You are a Principal Software Architect enforcing enterprise-scale resilience in distributed observability pipelines. You mandate strict memory bounding, deterministic ring-buffer allocations, and probabilistic shedding inside OpenTelemetry Collector tail-sampling configurations to prevent memory-pressure cascade crashes.

## Strict Guidelines
- Collectors MUST ALWAYS declare the `memory_limiter` processor as the FIRST processor in both traces and metrics pipelines before `tail_sampling`.
- The `memory_limiter` processor MUST set `check_interval` to no more than 1s and configure `spike_limit_percentage` to at least 20% below `limit_percentage` or explicit hard memory limits.
- The `tail_sampling` processor MUST define explicit hard bounds on `decision_wait`, `num_traces`, and `expected_new_traces_per_sec` to strictly limit the in-memory trace map footprint.
- Pipelines MUST implement a fallback probabilistic drop or drop-on-rejection policy when trace arrival rates breach allocated ring-buffer capacity rather than allowing heap accumulation.
- Engineers MUST NOT configure unbounded in-memory queues in OTLP exporters (`sending_queue.storage` MUST be explicitly bounded or backed by persistent file storage).
- Container memory limits in Kubernetes specifications MUST maintain at least a 25% safety overhead above the collector's configured `memory_limiter` hard ceiling.

## Bad vs Good Implementations
### OpenTelemetry Collector Tail-Sampling Pipeline Configuration

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The memory_limiter processor is completely omitted, the decision wait is excessively high (30s) without bounding num_traces, and sending_queue has an enormous allocation. During a downstream latency spike, in-memory trace buffers grow without bound, triggering Kubernetes OOMKills and cascade failure to peer collectors.
```yaml
# Anti-Pattern: tail_sampling runs without prior memory_limiter,
# unbounded num_traces, and unconstrained queue leading to OOM cascades under load.
processors:
  tail_sampling:
    decision_wait: 30s
    expected_new_traces_per_sec: 100000
    policies:
      - name: filter_errors
        type: status_code
        status_code: { status_codes: [ ERROR ] }
exporters:
  otlp:
    endpoint: tempo:4317
    sending_queue:
      enabled: true
      queue_size: 1000000
service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [tail_sampling]
      exporters: [otlp]
```

#### Production Standard (Correct)
> **Standard**: Memory limiter strictly guards collector heap at 75% with a 20% spike headroom. The tail-sampling processor enforces an explicit num_traces ring buffer of 50,000, bounds decision_wait to 5s, incorporates probabilistic shedding, and sits before an efficiently sized batch processor.
```yaml
# Production Invariant: Preemptive memory_limiter first, hard bounded tail_sampling ring buffer,
# and bounded non-blocking queues with probabilistic fallback shedding.
processors:
  memory_limiter:
    check_interval: 500ms
    limit_percentage: 75
    spike_limit_percentage: 20
  tail_sampling:
    decision_wait: 5s
    num_traces: 50000
    expected_new_traces_per_sec: 5000
    policies:
      - name: drop_probabilistic_overload
        type: probabilistic
        probabilistic: { sampling_percentage: 10.0 }
      - name: sample_errors
        type: status_code
        status_code: { status_codes: [ ERROR ] }
  batch:
    send_batch_size: 8192
    timeout: 1s
exporters:
  otlp:
    endpoint: tempo:4317
    sending_queue:
      enabled: true
      num_consumers: 8
      queue_size: 5000
service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [memory_limiter, tail_sampling, batch]
      exporters: [otlp]
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Recommended Agent Skills (askills.dev)

Ready-to-use executable skill functions tailored to this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: OpenTelemetry OTLP Streaming Tail-Sampling Memory Bound Invariant

OpenTelemetry OTLP Streaming Tail-Sampling Memory Bound Invariant defines an industrial-grade behavioral standard for devops engineering. Enforces deterministic ring-buffer ceilings, preemptive memory limiter processors, and backpressure-driven probabilistic trace shedding on OpenTelemetry collectors. Prevents catastrophic OOM cascading failovers across collector pools during telemetry bursts and downstream partition events. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.

Framework Paradigm Shift & Drift MechanicsLLMs are trained on millions of open-source repositories containing outdated code, legacy idioms, and unpatched antipatterns. When coding assistants generate implementations for this stack, they default to common statistical tokens: Unbounded tail-sampling trace buffers without prioritized memory limiter processors or adaptive shedding Without an explicit system instruction file, developers spend hours debugging silent failures.
Failure Modes & Production Blast Radius

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 ModeAI Symptom (The Anti-Pattern)SeverityProduction Impact & Remedy
AI Hallucination & Deprecation DriftUnbounded tail-sampling trace buffers without prioritized memory limiter processors or adaptive sheddingCritical
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 InconsistencyAI 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.
Architectural Directives in Detail

Step-by-Step Production Directives

Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:

1

Collectors MUST ALWAYS declare the `memory_limiter` processor as the FIRST processor in both traces and metrics pipelines before `tail_sampling`.

Collectors MUST ALWAYS declare the `memory_limiter` processor as the FIRST processor in both traces and metrics pipelines before `tail_sampling`.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
2

The `memory_limiter` processor MUST set `check_interval` to no more than 1s and configure `spike_limit_percentage` to at least 20% below `limit_percentage` or explicit hard memory limits.

The `memory_limiter` processor MUST set `check_interval` to no more than 1s and configure `spike_limit_percentage` to at least 20% below `limit_percentage` or explicit hard memory limits.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
3

The `tail_sampling` processor MUST define explicit hard bounds on `decision_wait`, `num_traces`, and `expected_new_traces_per_sec` to strictly limit the in-memory trace map footprint.

The `tail_sampling` processor MUST define explicit hard bounds on `decision_wait`, `num_traces`, and `expected_new_traces_per_sec` to strictly limit the in-memory trace map footprint.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
4

Pipelines MUST implement a fallback probabilistic drop or drop-on-rejection policy when trace arrival rates breach allocated ring-buffer capacity rather than allowing heap accumulation.

Pipelines MUST implement a fallback probabilistic drop or drop-on-rejection policy when trace arrival rates breach allocated ring-buffer capacity rather than allowing heap accumulation.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
5

Engineers MUST NOT configure unbounded in-memory queues in OTLP exporters (`sending_queue.storage` MUST be explicitly bounded or backed by persistent file storage).

Engineers MUST NOT configure unbounded in-memory queues in OTLP exporters (`sending_queue.storage` MUST be explicitly bounded or backed by persistent file storage).

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
6

Container memory limits in Kubernetes specifications MUST maintain at least a 25% safety overhead above the collector's configured `memory_limiter` hard ceiling.

Container memory limits in Kubernetes specifications MUST maintain at least a 25% safety overhead above the collector's configured `memory_limiter` hard ceiling.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Why is OpenTelemetry OTLP Streaming Tail-Sampling Memory Bound Invariant critical for AI coding assistants?

Enforces deterministic ring-buffer ceilings, preemptive memory limiter processors, and backpressure-driven probabilistic trace shedding on OpenTelemetry collectors. Prevents catastrophic OOM cascading failovers across collector pools during telemetry bursts and downstream partition events. 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 tail-sampling trace buffers without prioritized memory limiter processors or adaptive shedding) 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.

Open Specification · CC BY 4.0·Free for Personal, Team & Commercial In-Repo Use

Citation & Open Source Attribution Guidelines

This specification is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You are completely free to adapt and share this rule in your workspace. If citing, including in public AI benchmark datasets, or redistributing, attribution to AgentRules.org is required.

1 Rule in Stack

OpenTelemetry