This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: otlp-arrow-buffer-backpressure-gate

OTLP/Arrow In-Flight Chunk Quotas & Memory-Bound Backpressure Gate

Enforces strict byte-level memory accounting and adaptive backpressure on OpenTelemetry OTLP/Arrow columnar chunk streams prior to collector egress. Prevents telemetry agent and collector Out-Of-Memory (OOM) cascades by bounding in-flight Arrow RecordBatch allocations and shedding or throttling telemetry ingestion when memory saturation thresholds are reached.

Prohibited Anti-Pattern: Unmetered Arrow RecordBatch Accumulation Leading to Collector Ingestion OOM Cascades

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: OTLP/Arrow In-Flight Chunk Quotas & Memory-Bound Backpressure Gate - Enforces strict byte-level memory accounting and adaptive backpressure on OpenTelemetry OTLP/Arrow columnar chunk streams prior to collector egress. Prevents telemetry agent and collector Out-Of-Memory (OOM) cascades by bounding in-flight Arrow RecordBatch allocations and shedding or throttling telemetry ingestion when memory saturation thresholds are reached.
globs: src/**/*.{ts,tsx,js,mjs}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/otlp-arrow-buffer-backpressure-gate"
---

# OTLP/Arrow In-Flight Chunk Quotas & Memory-Bound Backpressure Gate

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Unmetered Arrow RecordBatch Accumulation Leading to Collector Ingestion OOM Cascades

## System Constraints
You are a Principal Software Architect enforcing production reliability standards for OpenTelemetry pipelines utilizing OTLP over Apache Arrow. You must mandate memory-bounded buffers, explicit byte accounting for Arrow RecordBatches, and backpressure gates that shed or throttle upstream telemetry to eliminate OOM cascades across collector fleets.

## Strict Guidelines
- Engineers MUST ALWAYS compute and bound memory utilization based on allocated byte sizes of Arrow RecordBatches rather than raw telemetry item counts.
- Engineers MUST NOT allow unbounded in-flight queues for Arrow columnar chunks awaiting collector acknowledgment (ACK).
- Code SHOULD implement dual-watermark adaptive backpressure (throttling at high watermark, resuming at low watermark) on in-memory buffers.
- Services MUST propagate collector backpressure (e.g., gRPC UNAVAILABLE or RESOURCE_EXHAUSTED) into client exporters immediately to halt pipeline ingestion.
- Components NEVER construct Arrow RecordBatches or allocate IPC buffers without acquiring bounded memory semaphore permits first.

## Bad vs Good Implementations
### Unbounded Arrow RecordBatch Accumulator vs. Semaphore-Bounded Backpressure Exporter

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The exporter accumulates spans in memory using a simple count threshold. Under collector latency or traffic bursts, unmetered span queues and subsequent Apache Arrow serialization exhaust the heap, triggering agent crashes and downstream collector OOM cascades.
```typescript
import { SpanExporter, ReadableSpan } from '@opentelemetry/sdk-trace-base';

export class UnboundedArrowExporter implements SpanExporter {
  private batchQueue: ReadableSpan[] = [];

  export(spans: ReadableSpan[], resultCallback: (result: { code: number }) => void): void {
    // ANTI-PATTERN: Indiscriminately appends spans without checking memory or in-flight byte size
    this.batchQueue.push(...spans);

    // When the network slows down or the collector blocks, this array expands indefinitely,
    // and transforming giant batches into Apache Arrow columnar structures triggers a heap OOM.
    if (this.batchQueue.length >= 1000) {
      this.flushToArrowCollector().finally(() => {
        resultCallback({ code: 0 });
      });
    } else {
      resultCallback({ code: 0 });
    }
  }

  private async flushToArrowCollector(): Promise<void> {
    // Serializes unbounded chunks directly into memory
    const batch = this.batchQueue.splice(0, this.batchQueue.length);
    await fetch('http://collector:4317/arrow', { method: 'POST', body: JSON.stringify(batch) });
  }

  async shutdown(): Promise<void> {}
}
```

#### Production Standard (Correct)
> **Standard**: Implements an explicit byte-quota gate with dual watermarks (80% saturation trip, 50% recovery). Backpressure is signaled up the telemetry pipeline via failure return codes, preventing runaway heap allocations and protecting collectors from memory exhaustion.
```typescript
import { SpanExporter, ReadableSpan } from '@opentelemetry/sdk-trace-base';
import { ExportResult, ExportResultCode } from '@opentelemetry/core';

export class BoundedArrowSpanExporter implements SpanExporter {
  private readonly maxBufferBytes: number;
  private currentAllocatedBytes = 0;
  private readonly highWatermarkRatio = 0.8;
  private readonly lowWatermarkRatio = 0.5;
  private isThrottled = false;

  constructor(maxBufferBytes = 32 * 1024 * 1024) {
    this.maxBufferBytes = maxBufferBytes;
  }

  export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void {
    const estimatedSpanBytes = spans.reduce((acc, s) => acc + (s.name.length * 2 + 256), 0);

    // Watermark check: reject or shed spans if memory saturation threshold breached
    if (this.currentAllocatedBytes + estimatedSpanBytes > this.maxBufferBytes * this.highWatermarkRatio) {
      this.isThrottled = true;
      // Fail fast to signal backpressure to upstream SDK processor
      resultCallback({ 
        code: ExportResultCode.FAILED, 
        error: new Error('OTLP/Arrow memory saturation: backpressure gate active') 
      });
      return;
    }

    this.currentAllocatedBytes += estimatedSpanBytes;
    this.dispatchArrowRecordBatch(spans, estimatedSpanBytes)
      .then(() => resultCallback({ code: ExportResultCode.SUCCESS }))
      .catch((err) => resultCallback({ code: ExportResultCode.FAILED, error: err }));
  }

  private async dispatchArrowRecordBatch(spans: ReadableSpan[], allocatedBytes: number): Promise<void> {
    try {
      // In production, records are serialized to Arrow IPC chunk streams
      await this.transmitToCollector(spans);
    } finally {
      this.currentAllocatedBytes = Math.max(0, this.currentAllocatedBytes - allocatedBytes);
      if (this.isThrottled && this.currentAllocatedBytes <= this.maxBufferBytes * this.lowWatermarkRatio) {
        this.isThrottled = false;
      }
    }
  }

  private async transmitToCollector(spans: ReadableSpan[]): Promise<void> {
    // Network transmission logic with timeout and gRPC status handling
  }

  async shutdown(): Promise<void> {}
}
```

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: OTLP/Arrow In-Flight Chunk Quotas & Memory-Bound Backpressure Gate

OTLP/Arrow In-Flight Chunk Quotas & Memory-Bound Backpressure Gate defines an industrial-grade behavioral standard for devops engineering. Enforces strict byte-level memory accounting and adaptive backpressure on OpenTelemetry OTLP/Arrow columnar chunk streams prior to collector egress. Prevents telemetry agent and collector Out-Of-Memory (OOM) cascades by bounding in-flight Arrow RecordBatch allocations and shedding or throttling telemetry ingestion when memory saturation thresholds are reached. 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: Unmetered Arrow RecordBatch Accumulation Leading to Collector Ingestion OOM Cascades 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 DriftUnmetered Arrow RecordBatch Accumulation Leading to Collector Ingestion OOM CascadesCritical
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 compute and bound memory utilization based on allocated byte sizes of Arrow RecordBatches rather than raw telemetry item counts.

Engineers MUST ALWAYS compute and bound memory utilization based on allocated byte sizes of Arrow RecordBatches rather than raw telemetry item counts.

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 allow unbounded in-flight queues for Arrow columnar chunks awaiting collector acknowledgment (ACK).

Engineers MUST NOT allow unbounded in-flight queues for Arrow columnar chunks awaiting collector acknowledgment (ACK).

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

Code SHOULD implement dual-watermark adaptive backpressure (throttling at high watermark, resuming at low watermark) on in-memory buffers.

Code SHOULD implement dual-watermark adaptive backpressure (throttling at high watermark, resuming at low watermark) on in-memory buffers.

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

Services MUST propagate collector backpressure (e.g., gRPC UNAVAILABLE or RESOURCE_EXHAUSTED) into client exporters immediately to halt pipeline ingestion.

Services MUST propagate collector backpressure (e.g., gRPC UNAVAILABLE or RESOURCE_EXHAUSTED) into client exporters immediately to halt pipeline ingestion.

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

Components NEVER construct Arrow RecordBatches or allocate IPC buffers without acquiring bounded memory semaphore permits first.

Components NEVER construct Arrow RecordBatches or allocate IPC buffers without acquiring bounded memory semaphore permits first.

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 OTLP/Arrow In-Flight Chunk Quotas & Memory-Bound Backpressure Gate critical for AI coding assistants?

Enforces strict byte-level memory accounting and adaptive backpressure on OpenTelemetry OTLP/Arrow columnar chunk streams prior to collector egress. Prevents telemetry agent and collector Out-Of-Memory (OOM) cascades by bounding in-flight Arrow RecordBatch allocations and shedding or throttling telemetry ingestion when memory saturation thresholds are reached. 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 (Unmetered Arrow RecordBatch Accumulation Leading to Collector Ingestion OOM Cascades) 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

OTLP/Arrow