This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: otel-collector-adaptive-memory-limiter-flow-control

OpenTelemetry Collector Dynamic Memory-Limiter and Upstream Backpressure Standard

Enforces strict ordering, dynamic cgroup-aware memory allocation, and upstream backpressure propagation across OpenTelemetry Collector pipelines. Prevents catastrophic OOMKills during telemetry micro-bursts by ensuring memory limiting executes before payload deserialization, buffering, and routing.

Prohibited Anti-Pattern: Misordered Collector Pipelines and Static Thresholds Causing Kernel OOMKills and Telemetry Blackholes

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: OpenTelemetry Collector Dynamic Memory-Limiter and Upstream Backpressure Standard - Enforces strict ordering, dynamic cgroup-aware memory allocation, and upstream backpressure propagation across OpenTelemetry Collector pipelines. Prevents catastrophic OOMKills during telemetry micro-bursts by ensuring memory limiting executes before payload deserialization, buffering, and routing.
globs: **/otel-collector*.{yaml,yml}, **/collector/**/*.{yaml,yml}, **/k8s/**/*.{yaml,yml}, **/helm/**/*.{yaml,yml}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/otel-collector-adaptive-memory-limiter-flow-control"
---

# OpenTelemetry Collector Dynamic Memory-Limiter and Upstream Backpressure Standard

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Misordered Collector Pipelines and Static Thresholds Causing Kernel OOMKills and Telemetry Blackholes

## System Constraints
You are a Principal Software Architect enforcing the OpenTelemetry Collector Dynamic Adaptive Memory-Limiter Flow Control Standard. You must mandate that collector topologies survive multi-gigabyte metric and trace volume spikes without triggering OS kernel Out-Of-Memory (OOM) kills. Enforce that memory limiter processors are configured as the initial processor in every pipeline, dynamic thresholds adapt strictly to container cgroup v2 envelopes via GOMEMLIMIT, and upstream receivers emit standard backpressure (gRPC RESOURCE_EXHAUSTED / HTTP 429) rather than silently dropping data or crashing.

## Strict Guidelines
- Engineers MUST ALWAYS configure the `memory_limiter` processor as the FIRST processor in every pipeline (`traces`, `metrics`, `logs`).
- Engineers MUST NOT place memory-allocating processors (such as `batch`, `transform`, `groupbytrace`, or `cumulativetodelta`) before `memory_limiter`.
- Collector deployments MUST set `GOMEMLIMIT` to 80-85% of the container hard memory limit and align `limit_percentage` to not exceed 80% to reserve overhead for runtime structures and GC.
- Processors MUST set `check_interval` to no greater than 1s (recommended 250ms-500ms) to ensure sliding-window memory sampling catches high-velocity burst spikes before allocation exceeding cgroup limits.
- Receivers MUST propagate backpressure to upstream agents via gRPC code 8 (`RESOURCE_EXHAUSTED`) or HTTP 429 (`Too Many Requests`) with retry headers when memory-limiter throttling engages.
- Engineers MUST configure `spike_limit_percentage` at least 15-20% below `limit_percentage` to create an operational safety buffer for in-flight requests during GC cycles.
- Deployment manifests MUST NEVER set container memory requests equal to memory limits without defining `batch` processor queue sizes bounded by max buffer mathematical upper limits.

## Bad vs Good Implementations
### Collector Pipeline Ordering and Adaptive Memory Limiter Configuration

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Placing the `batch` processor before `memory_limiter` allows memory allocations to build up in batch buffers before the memory limiter can evaluate system pressure. A 5-second `check_interval` is too slow to catch telemetry spikes, and hardcoded static limits (`limit_mib`) cause collector pods to exceed container cgroups and face SIGKILL terminations.
```yaml
# ANTI-PATTERN: memory_limiter placed after batch processor with hardcoded static memory
# and no cgroup alignment, leading to unhandled allocation spikes and kernel OOMKills.
processors:
  batch:
    send_batch_size: 10000
    timeout: 10s
  memory_limiter:
    check_interval: 5s
    limit_mib: 4096 # Hardcoded static limit drifts from container cgroups

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch, memory_limiter] # FAILS: batch buffers allocations before memory_limiter can drop/throttle
      exporters: [otlp]
```

#### Production Standard (Correct)
> **Standard**: `memory_limiter` is guaranteed to be the first processor across all pipelines. The 250ms check interval rapidly detects memory expansion, while percentage-based thresholds (75% limit, 20% spike delta) dynamically adapt to container memory limits when paired with `GOMEMLIMIT=80%` and `GOGC=80`.
```yaml
# PRODUCTION STANDARD: Dynamic percentage-based memory limiter placed as the FIRST processor
# with responsive check interval and synchronized container cgroup environment variables.
processors:
  memory_limiter:
    check_interval: 250ms
    limit_percentage: 75
    spike_limit_percentage: 20
  batch:
    send_batch_size: 8192
    send_batch_max_size: 10240
    timeout: 1s

service:
  telemetry:
    metrics:
      address: 0.0.0.0:8888
  pipelines:
    traces:
      receivers: [otlp]
      processors: [memory_limiter, batch] # REQUIRED: memory_limiter is strictly FIRST
      exporters: [otlp]
    metrics:
      receivers: [otlp]
      processors: [memory_limiter, batch]
      exporters: [otlp]
    logs:
      receivers: [otlp]
      processors: [memory_limiter, batch]
      exporters: [otlp]
```

Recommended MCP Servers (mcp-serverlist.com)

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

Architectural Specification & Invariant Rationale

Architectural Invariant Design: OpenTelemetry Collector Dynamic Memory-Limiter and Upstream Backpressure Standard

OpenTelemetry Collector Dynamic Memory-Limiter and Upstream Backpressure Standard defines an industrial-grade behavioral standard for devops engineering. Enforces strict ordering, dynamic cgroup-aware memory allocation, and upstream backpressure propagation across OpenTelemetry Collector pipelines. Prevents catastrophic OOMKills during telemetry micro-bursts by ensuring memory limiting executes before payload deserialization, buffering, and routing. 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: Misordered Collector Pipelines and Static Thresholds Causing Kernel OOMKills and Telemetry Blackholes 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 DriftMisordered Collector Pipelines and Static Thresholds Causing Kernel OOMKills and Telemetry BlackholesCritical
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

Engineers MUST ALWAYS configure the `memory_limiter` processor as the FIRST processor in every pipeline (`traces`, `metrics`, `logs`).

Engineers MUST ALWAYS configure the `memory_limiter` processor as the FIRST processor in every pipeline (`traces`, `metrics`, `logs`).

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

Engineers MUST NOT place memory-allocating processors (such as `batch`, `transform`, `groupbytrace`, or `cumulativetodelta`) before `memory_limiter`.

Engineers MUST NOT place memory-allocating processors (such as `batch`, `transform`, `groupbytrace`, or `cumulativetodelta`) before `memory_limiter`.

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

Collector deployments MUST set `GOMEMLIMIT` to 80-85% of the container hard memory limit and align `limit_percentage` to not exceed 80% to reserve overhead for runtime structures and GC.

Collector deployments MUST set `GOMEMLIMIT` to 80-85% of the container hard memory limit and align `limit_percentage` to not exceed 80% to reserve overhead for runtime structures and GC.

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

Processors MUST set `check_interval` to no greater than 1s (recommended 250ms-500ms) to ensure sliding-window memory sampling catches high-velocity burst spikes before allocation exceeding cgroup limits.

Processors MUST set `check_interval` to no greater than 1s (recommended 250ms-500ms) to ensure sliding-window memory sampling catches high-velocity burst spikes before allocation exceeding cgroup 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.
5

Receivers MUST propagate backpressure to upstream agents via gRPC code 8 (`RESOURCE_EXHAUSTED`) or HTTP 429 (`Too Many Requests`) with retry headers when memory-limiter throttling engages.

Receivers MUST propagate backpressure to upstream agents via gRPC code 8 (`RESOURCE_EXHAUSTED`) or HTTP 429 (`Too Many Requests`) with retry headers when memory-limiter throttling engages.

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

Engineers MUST configure `spike_limit_percentage` at least 15-20% below `limit_percentage` to create an operational safety buffer for in-flight requests during GC cycles.

Engineers MUST configure `spike_limit_percentage` at least 15-20% below `limit_percentage` to create an operational safety buffer for in-flight requests during GC cycles.

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.
7

Deployment manifests MUST NEVER set container memory requests equal to memory limits without defining `batch` processor queue sizes bounded by max buffer mathematical upper limits.

Deployment manifests MUST NEVER set container memory requests equal to memory limits without defining `batch` processor queue sizes bounded by max buffer mathematical upper 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.
Technical Questions & Answers

Frequently Asked Technical Questions

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

Q:Why is OpenTelemetry Collector Dynamic Memory-Limiter and Upstream Backpressure Standard critical for AI coding assistants?

Enforces strict ordering, dynamic cgroup-aware memory allocation, and upstream backpressure propagation across OpenTelemetry Collector pipelines. Prevents catastrophic OOMKills during telemetry micro-bursts by ensuring memory limiting executes before payload deserialization, buffering, and routing. 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 (Misordered Collector Pipelines and Static Thresholds Causing Kernel OOMKills and Telemetry Blackholes) 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