This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: otel-collector-cgroup-dynamic-backpressure-guardrail

OpenTelemetry Collector Cgroup-Aware Dynamic Backpressure Guardrail

Enforces deterministic memory bounds and cgroup-coupled dynamic backpressure on OpenTelemetry Collector instances to eliminate OOM kills under burst traffic. Mandates strict positioning of the memory_limiter processor, alignment of GOMEMLIMIT with container cgroup limits, and explicit bounded queues across all pipelines.

Prohibited Anti-Pattern: Unbounded Collector Queuing and Uncoupled Host-Relative Memory Limits Leading to Kernel OOM Termination

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: OpenTelemetry Collector Cgroup-Aware Dynamic Backpressure Guardrail - Enforces deterministic memory bounds and cgroup-coupled dynamic backpressure on OpenTelemetry Collector instances to eliminate OOM kills under burst traffic. Mandates strict positioning of the memory_limiter processor, alignment of GOMEMLIMIT with container cgroup limits, and explicit bounded queues across all pipelines.
globs: **/otel-collector*.{yaml,yml}, **/collector*.{yaml,yml}, **/helm/**/values*.{yaml,yml}, **/k8s/**/*.{yaml,yml}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/otel-collector-cgroup-dynamic-backpressure-guardrail"
---

# OpenTelemetry Collector Cgroup-Aware Dynamic Backpressure Guardrail

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Unbounded Collector Queuing and Uncoupled Host-Relative Memory Limits Leading to Kernel OOM Termination

## System Constraints
You are a Principal Observability Infrastructure Architect enforcing cgroup-aware memory safety and dynamic backpressure in OpenTelemetry Collector deployments. You must reject any configuration that exposes collector pods to OOM termination by mandating precise GOMEMLIMIT container tuning, strict memory_limiter processor placement as the primary pipeline filter, and bounded queues with backpressure rejection codes.

## Strict Guidelines
- Engineers MUST ALWAYS declare 'memory_limiter' as the absolute first processor in every receiver pipeline (traces, metrics, logs).
- Engineers MUST configure 'limit_percentage' at no more than 80% (or 'limit_mib' at <= 80% of container limit) with a 'spike_limit_percentage' of 20% to account for GC pacing.
- Engineers MUST NEVER use the deprecated 'memory_ballast' extension in contemporary OpenTelemetry Collector configurations.
- Container manifests MUST set the 'GOMEMLIMIT' environment variable to 80-85% of the container cgroup memory limit (e.g., 'GOMEMLIMIT=1700MiB' for a 2GiB container limit).
- Exporters MUST ALWAYS define a bounded 'sending_queue' with 'enabled: true' and a finite 'queue_size' to enforce downstream flow control and propagate HTTP 429/503 or gRPC ResourceExhausted backpressure to upstream emitters.
- Engineers MUST set 'check_interval' in 'memory_limiter' to a high-frequency polling value (between '500ms' and '1s') to catch burst spikes before kernel cgroup OOM reaper invocation.

## Bad vs Good Implementations
### Collector Pipeline & Container Manifest Alignment

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The collector container defines a 2Gi cgroup limit but lacks the GOMEMLIMIT environment variable, causing the Go runtime to allocate memory until Linux cgroups invoke the OOM killer. The collector pipeline omits the memory_limiter processor entirely and allows unbounded internal batching without backpressure signals.
```yaml
# INSECURE: Omits GOMEMLIMIT, memory_limiter missing or misplaced, unbounded queuing
apiVersion: apps/v1
kind: Deployment
metadata:
  name: otel-collector
spec:
  template:
    spec:
      containers:
        - name: otel-collector
          image: otel/opentelemetry-collector-contrib:0.95.0
          resources:
            limits:
              memory: 2Gi
            requests:
              memory: 2Gi
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: otel-collector-config
data:
  config.yaml: |
    processors:
      batch:
        send_batch_size: 10000
        timeout: 10s
    service:
      pipelines:
        traces:
          receivers: [otlp]
          processors: [batch]
          exporters: [otlp]
```

#### Production Standard (Correct)
> **Standard**: GOMEMLIMIT guarantees the Go garbage collector actively runs before cgroup boundaries are breached. The memory_limiter is the first processor in the pipeline, checking memory every 1s and rejecting new spans/metrics with transient errors when limits are approached, while sending_queue enforces explicit storage limits.
```yaml
# SECURE: Precise GOMEMLIMIT alignment, memory_limiter as first processor, bounded queue
apiVersion: apps/v1
kind: Deployment
metadata:
  name: otel-collector
spec:
  template:
    spec:
      containers:
        - name: otel-collector
          image: otel/opentelemetry-collector-contrib:0.95.0
          env:
            - name: GOMEMLIMIT
              value: "1600MiB" # Exactly 80% of 2000Mi cgroup limit
            - name: GOMAXPROCS
              value: "2"
          resources:
            limits:
              cpu: "2"
              memory: 2000Mi
            requests:
              cpu: "1"
              memory: 2000Mi
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: otel-collector-config
data:
  config.yaml: |
    processors:
      memory_limiter:
        check_interval: 1s
        limit_percentage: 75
        spike_limit_percentage: 20
      batch:
        send_batch_size: 8192
        timeout: 1s
    exporters:
      otlp:
        endpoint: tempo:4317
        sending_queue:
          enabled: true
          num_consumers: 4
          queue_size: 5000
    service:
      pipelines:
        traces:
          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.

Recommended Agent Skills (askills.dev)

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

Architectural Specification & Invariant Rationale

Architectural Invariant Design: OpenTelemetry Collector Cgroup-Aware Dynamic Backpressure Guardrail

OpenTelemetry Collector Cgroup-Aware Dynamic Backpressure Guardrail defines an industrial-grade behavioral standard for devops engineering. Enforces deterministic memory bounds and cgroup-coupled dynamic backpressure on OpenTelemetry Collector instances to eliminate OOM kills under burst traffic. Mandates strict positioning of the memory_limiter processor, alignment of GOMEMLIMIT with container cgroup limits, and explicit bounded queues across all pipelines. 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 Collector Queuing and Uncoupled Host-Relative Memory Limits Leading to Kernel OOM Termination 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 Collector Queuing and Uncoupled Host-Relative Memory Limits Leading to Kernel OOM TerminationCritical
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 declare 'memory_limiter' as the absolute first processor in every receiver pipeline (traces, metrics, logs).

Engineers MUST ALWAYS declare 'memory_limiter' as the absolute first processor in every receiver 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 configure 'limit_percentage' at no more than 80% (or 'limit_mib' at <= 80% of container limit) with a 'spike_limit_percentage' of 20% to account for GC pacing.

Engineers MUST configure 'limit_percentage' at no more than 80% (or 'limit_mib' at <= 80% of container limit) with a 'spike_limit_percentage' of 20% to account for GC pacing.

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

Engineers MUST NEVER use the deprecated 'memory_ballast' extension in contemporary OpenTelemetry Collector configurations.

Engineers MUST NEVER use the deprecated 'memory_ballast' extension in contemporary OpenTelemetry Collector configurations.

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

Container manifests MUST set the 'GOMEMLIMIT' environment variable to 80-85% of the container cgroup memory limit (e.g., 'GOMEMLIMIT=1700MiB' for a 2GiB container limit).

Container manifests MUST set the 'GOMEMLIMIT' environment variable to 80-85% of the container cgroup memory limit (e.g., 'GOMEMLIMIT=1700MiB' for a 2GiB container limit).

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

Exporters MUST ALWAYS define a bounded 'sending_queue' with 'enabled

Exporters MUST ALWAYS define a bounded 'sending_queue' with 'enabled: true' and a finite 'queue_size' to enforce downstream flow control and propagate HTTP 429/503 or gRPC ResourceExhausted backpressure to upstream emitters.

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 set 'check_interval' in 'memory_limiter' to a high-frequency polling value (between '500ms' and '1s') to catch burst spikes before kernel cgroup OOM reaper invocation.

Engineers MUST set 'check_interval' in 'memory_limiter' to a high-frequency polling value (between '500ms' and '1s') to catch burst spikes before kernel cgroup OOM reaper invocation.

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 Cgroup-Aware Dynamic Backpressure Guardrail critical for AI coding assistants?

Enforces deterministic memory bounds and cgroup-coupled dynamic backpressure on OpenTelemetry Collector instances to eliminate OOM kills under burst traffic. Mandates strict positioning of the memory_limiter processor, alignment of GOMEMLIMIT with container cgroup limits, and explicit bounded queues across all pipelines. 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 Collector Queuing and Uncoupled Host-Relative Memory Limits Leading to Kernel OOM Termination) 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