This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: otel-collector-processor-pipeline-safeguards

OpenTelemetry Collector Processor Pipeline Order and Memory Guardrails

Mandates strict ordering and configuration of OpenTelemetry Collector processor pipelines. Enforces memory_limiter as the non-negotiable first processor to prevent process crashes, requires OTTL-driven PII redaction before persistence or sampling, and mandates dedicated pipeline tiers for tail-based sampling.

Prohibited Anti-Pattern: Placing batch or sampling processors before memory limiters and exporting raw unredacted telemetry

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: OpenTelemetry Collector Processor Pipeline Order and Memory Guardrails - Mandates strict ordering and configuration of OpenTelemetry Collector processor pipelines. Enforces memory_limiter as the non-negotiable first processor to prevent process crashes, requires OTTL-driven PII redaction before persistence or sampling, and mandates dedicated pipeline tiers for tail-based sampling.
globs: **/otel-collector*.yaml, **/otel-collector*.yml, **/collector*.yaml, **/collector*.yml, deploy/k8s/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/otel-collector-processor-pipeline-safeguards"
---

# OpenTelemetry Collector Processor Pipeline Order and Memory Guardrails

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Placing batch or sampling processors before memory limiters and exporting raw unredacted telemetry

## System Constraints
You are a Principal Observability and Infrastructure Architect enforcing OpenTelemetry Collector configuration standards. Every pipeline configuration must enforce deterministic processor sequencing: memory_limiter MUST precede all other processors to eliminate Out-Of-Memory (OOM) fatal crashes; transform processors MUST redact PII attributes using OTTL before telemetry hits sampling or exporting stages; and batch processors MUST be tuned alongside memory ceilings. Never emit unredacted attributes, unbounded batch sizes, or inverted processor pipelines.

## Strict Guidelines
- Engineers MUST ALWAYS declare 'memory_limiter' as the first processor in every pipeline (traces, metrics, logs) before any compute-intensive or buffer-allocating processors.
- Engineers MUST NOT place 'batch' or 'tail_sampling' processors before 'memory_limiter', as high ingest volume will cause unbounded heap growth and fatal SIGKILL termination.
- Engineers MUST configure 'memory_limiter' with explicit 'check_interval', 'limit_percentage' (or 'limit_mib'), and 'spike_limit_percentage' (or 'spike_limit_mib') calibrated to the container memory ceiling.
- Engineers MUST ALWAYS redact sensitive attributes (PII, tokens, auth headers) using the 'transform' processor via OpenTelemetry Transformation Language (OTTL) prior to any sampling or export step.
- Pipelines using 'tail_sampling' MUST be deployed in an isolated collector cluster with trace-ID-consistent routing, and MUST execute after PII redaction but before the final 'batch' processor.
- Batch processors MUST declare explicit 'send_batch_size', 'timeout', and 'send_batch_max_size' to ensure bounded memory envelopes during network backpressure.

## Bad vs Good Implementations
### OpenTelemetry Collector Processor Pipeline Order and Configuration

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The memory_limiter is placed last in the pipeline, which renders it ineffective against spikes buffering in tail_sampling and batch processors, leading to unpreventable container OOMKills. Furthermore, no transform/redaction processor is configured, causing sensitive authorization and user PII to leak to APM backends.
```yaml
processors:
  batch:
    timeout: 10s
  tail_sampling:
    decision_wait: 10s
    expected_new_traces_per_sec: 2000
    policies:
      [ { name: drop_healthchecks, type: string_attribute, string_attribute: { key: http.target, values: [ "/healthz" ], enabled_regex_matching: false, invert_match: true } } ]
  memory_limiter:
    check_interval: 5s
    limit_percentage: 80
    spike_limit_percentage: 20

service:
  pipelines:
    traces:
      receivers: [otlp]
      # ANTI-PATTERN: memory_limiter is executed last. Tail sampling and batching
      # will consume unconstrained memory under load spikes, causing OOM kills.
      # Missing PII redaction transforms exposes credentials to downstream backends.
      processors: [tail_sampling, batch, memory_limiter]
      exporters: [otlp]
```

#### Production Standard (Correct)
> **Standard**: The pipeline rigorously applies the memory_limiter first, shielding the collector from heap exhaustion. PII attributes are wiped next via OTTL transforms before the tail_sampling decision engine. Finally, batching executes with rigid upper bounds right before network export.
```yaml
processors:
  # INVARIANT 1: memory_limiter must be first to evaluate allocation against limits
  memory_limiter:
    check_interval: 1s
    limit_percentage: 75
    spike_limit_percentage: 15

  # INVARIANT 2: OTTL transform redacts PII before trace decisions or exports
  transform/pii_redaction:
    error_mode: ignore
    trace_statements:
      - context: span
        statements:
          - replace_pattern(attributes["http.request.header.authorization"], ".*", "[REDACTED]")
          - replace_pattern(attributes["user.email"], ".*", "[REDACTED]")
          - delete_key(attributes, "db.statement.parameters")

  # INVARIANT 3: Tail-based sampling operates on sanitized spans
  tail_sampling:
    decision_wait: 5s
    num_traces: 50000
    expected_new_traces_per_sec: 5000
    policies:
      - name: drop_healthchecks
        type: string_attribute
        string_attribute:
          key: http.target
          values: ["/healthz", "/ready"]
          invert_match: true

  # INVARIANT 4: Bounded batch processor immediately precedes export
  batch:
    send_batch_size: 8192
    timeout: 1s
    send_batch_max_size: 10240

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [memory_limiter, transform/pii_redaction, 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 Collector Processor Pipeline Order and Memory Guardrails

OpenTelemetry Collector Processor Pipeline Order and Memory Guardrails defines an industrial-grade behavioral standard for devops engineering. Mandates strict ordering and configuration of OpenTelemetry Collector processor pipelines. Enforces memory_limiter as the non-negotiable first processor to prevent process crashes, requires OTTL-driven PII redaction before persistence or sampling, and mandates dedicated pipeline tiers for tail-based sampling. 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: Placing batch or sampling processors before memory limiters and exporting raw unredacted telemetry 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 DriftPlacing batch or sampling processors before memory limiters and exporting raw unredacted telemetryCritical
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 first processor in every pipeline (traces, metrics, logs) before any compute-intensive or buffer-allocating processors.

Engineers MUST ALWAYS declare 'memory_limiter' as the first processor in every pipeline (traces, metrics, logs) before any compute-intensive or buffer-allocating processors.

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 'batch' or 'tail_sampling' processors before 'memory_limiter', as high ingest volume will cause unbounded heap growth and fatal SIGKILL termination.

Engineers MUST NOT place 'batch' or 'tail_sampling' processors before 'memory_limiter', as high ingest volume will cause unbounded heap growth and fatal SIGKILL termination.

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 configure 'memory_limiter' with explicit 'check_interval', 'limit_percentage' (or 'limit_mib'), and 'spike_limit_percentage' (or 'spike_limit_mib') calibrated to the container memory ceiling.

Engineers MUST configure 'memory_limiter' with explicit 'check_interval', 'limit_percentage' (or 'limit_mib'), and 'spike_limit_percentage' (or 'spike_limit_mib') calibrated to the container memory 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.
4

Engineers MUST ALWAYS redact sensitive attributes (PII, tokens, auth headers) using the 'transform' processor via OpenTelemetry Transformation Language (OTTL) prior to any sampling or export step.

Engineers MUST ALWAYS redact sensitive attributes (PII, tokens, auth headers) using the 'transform' processor via OpenTelemetry Transformation Language (OTTL) prior to any sampling or export step.

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

Pipelines using 'tail_sampling' MUST be deployed in an isolated collector cluster with trace-ID-consistent routing, and MUST execute after PII redaction but before the final 'batch' processor.

Pipelines using 'tail_sampling' MUST be deployed in an isolated collector cluster with trace-ID-consistent routing, and MUST execute after PII redaction but before the final 'batch' processor.

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

Batch processors MUST declare explicit 'send_batch_size', 'timeout', and 'send_batch_max_size' to ensure bounded memory envelopes during network backpressure.

Batch processors MUST declare explicit 'send_batch_size', 'timeout', and 'send_batch_max_size' to ensure bounded memory envelopes during network backpressure.

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 Processor Pipeline Order and Memory Guardrails critical for AI coding assistants?

Mandates strict ordering and configuration of OpenTelemetry Collector processor pipelines. Enforces memory_limiter as the non-negotiable first processor to prevent process crashes, requires OTTL-driven PII redaction before persistence or sampling, and mandates dedicated pipeline tiers for tail-based sampling. 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 (Placing batch or sampling processors before memory limiters and exporting raw unredacted telemetry) 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