This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: otel-metric-temporal-delta-aggregation-ceiling

OpenTelemetry Delta-Aggregation State Table Memory Ceiling Invariant

Enforces deterministic memory limits on OpenTelemetry SDK metric readers by mandating bounded cardinality state tables and delta temporality aggregation. High-cardinality label explosions without pre-export bucketing or explicit cardinal limits induce unbounded heap retention and trigger catastrophic out-of-memory crashes. All MeterProvider instantiations must configure explicit stream boundary views and attribute filter processors.

Prohibited Anti-Pattern: Unbounded Cumulative Histogram Aggregation with High-Cardinality Ephemeral Attributes

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: OpenTelemetry Delta-Aggregation State Table Memory Ceiling Invariant - Enforces deterministic memory limits on OpenTelemetry SDK metric readers by mandating bounded cardinality state tables and delta temporality aggregation. High-cardinality label explosions without pre-export bucketing or explicit cardinal limits induce unbounded heap retention and trigger catastrophic out-of-memory crashes. All MeterProvider instantiations must configure explicit stream boundary views and attribute filter processors.
globs: src/**/telemetry.{ts,js}, src/**/metrics.{ts,js}, src/**/instrumentation.{ts,js}, src/**/otel.{ts,js}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/otel-metric-temporal-delta-aggregation-ceiling"
---

# OpenTelemetry Delta-Aggregation State Table Memory Ceiling Invariant

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Unbounded Cumulative Histogram Aggregation with High-Cardinality Ephemeral Attributes

## System Constraints
You are a Principal Software Architect enforcing the OpenTelemetry Metric Temporal Delta-Aggregation Memory Ceiling Invariant. You must reject any OpenTelemetry metric setup that fails to enforce explicit attribute cardinality ceilings, allows default unbounded cumulative state accumulation, or omits delta temporality with streaming buffer boundaries.

## Strict Guidelines
- Engineers MUST ALWAYS configure PeriodicExportingMetricReader with AggregationTemporality.DELTA to prevent unbounded cumulative state table accumulation.
- Engineers MUST NOT attach dynamic, high-cardinality attributes (e.g., UUIDs, timestamps, user IDs, raw URLs) directly to metric measurements without explicit pre-export aggregation views.
- Code SHOULD define explicit View instances with drop or filter attribute aggregators on instruments with variable runtime dimensions.
- Services MUST configure cardinality limiters (attribute limits or metric stream ceilings) at the MeterProvider initialization layer.
- Components NEVER instantiate MeterProvider using default unbounded cumulative memory allocators in production high-throughput pathways.

## Bad vs Good Implementations
### Unbounded Cumulative Metric Allocation vs. Bounded Delta Temporality with Explicit Stream Views

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Default MeterProvider configuration retains cumulative metric state in memory indefinitely. Recording unbounded attributes like `traceId` and `userId` generates an exponential explosion of unique dimension tuples, causing the OTel SDK memory footprint to scale monotonically until node OOM termination.
```typescript
import { MeterProvider, PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics';
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-grpc';

// ANTI-PATTERN: Default cumulative temporality and unbounded attribute retention
const exporter = new OTLPMetricExporter();
const reader = new PeriodicExportingMetricReader({
  exporter,
  exportIntervalMillis: 30000,
});

export const meterProvider = new MeterProvider({
  readers: [reader],
});

const meter = meterProvider.getMeter('order-service');
const latencyHistogram = meter.createHistogram('http.server.duration');

// Emitting unbounded cardinality dimensions continuously bloats SDK state table
export function recordDuration(durationMs: number, traceId: string, userId: string) {
  latencyHistogram.record(durationMs, { traceId, userId });
}
```

#### Production Standard (Correct)
> **Standard**: Delta temporality ensures state tables are reset upon successful export cycles. The explicit View enforces pre-export attribute filtering and defined histogram buckets, creating a deterministic, bounded upper memory ceiling regardless of request volume.
```typescript
import { MeterProvider, PeriodicExportingMetricReader, AggregationTemporality, ExplicitBucketHistogramAggregation, View } from '@opentelemetry/sdk-metrics';
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-grpc';

// PRODUCTION FIX: Explicit delta temporality combined with strict attribute filtering views
const exporter = new OTLPMetricExporter({
  temporalitySelector: () => AggregationTemporality.DELTA,
});

const reader = new PeriodicExportingMetricReader({
  exporter,
  exportIntervalMillis: 15000,
});

const histogramView = new View({
  instrumentName: 'http.server.duration',
  aggregation: new ExplicitBucketHistogramAggregation([5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000]),
  attributeFilter: (attributeName: string) => {
    // Drop unbounded ephemeral dimensions, retaining strictly bounded state
    return ['http.route', 'http.status_code'].includes(attributeName);
  },
});

export const meterProvider = new MeterProvider({
  readers: [reader],
  views: [histogramView],
});

const meter = meterProvider.getMeter('order-service');
const latencyHistogram = meter.createHistogram('http.server.duration');

export function recordDuration(durationMs: number, route: string, statusCode: number) {
  latencyHistogram.record(durationMs, {
    'http.route': route,
    'http.status_code': statusCode,
  });
}
```

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 Delta-Aggregation State Table Memory Ceiling Invariant

OpenTelemetry Delta-Aggregation State Table Memory Ceiling Invariant defines an industrial-grade behavioral standard for devops engineering. Enforces deterministic memory limits on OpenTelemetry SDK metric readers by mandating bounded cardinality state tables and delta temporality aggregation. High-cardinality label explosions without pre-export bucketing or explicit cardinal limits induce unbounded heap retention and trigger catastrophic out-of-memory crashes. All MeterProvider instantiations must configure explicit stream boundary views and attribute filter processors. 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 Cumulative Histogram Aggregation with High-Cardinality Ephemeral Attributes 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 Cumulative Histogram Aggregation with High-Cardinality Ephemeral AttributesCritical
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 PeriodicExportingMetricReader with AggregationTemporality.DELTA to prevent unbounded cumulative state table accumulation.

Engineers MUST ALWAYS configure PeriodicExportingMetricReader with AggregationTemporality.DELTA to prevent unbounded cumulative state table 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.
2

Engineers MUST NOT attach dynamic, high-cardinality attributes (e.g., UUIDs, timestamps, user IDs, raw URLs) directly to metric measurements without explicit pre-export aggregation views.

Engineers MUST NOT attach dynamic, high-cardinality attributes (e.g., UUIDs, timestamps, user IDs, raw URLs) directly to metric measurements without explicit pre-export aggregation views.

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 define explicit View instances with drop or filter attribute aggregators on instruments with variable runtime dimensions.

Code SHOULD define explicit View instances with drop or filter attribute aggregators on instruments with variable runtime dimensions.

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 configure cardinality limiters (attribute limits or metric stream ceilings) at the MeterProvider initialization layer.

Services MUST configure cardinality limiters (attribute limits or metric stream ceilings) at the MeterProvider initialization layer.

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 instantiate MeterProvider using default unbounded cumulative memory allocators in production high-throughput pathways.

Components NEVER instantiate MeterProvider using default unbounded cumulative memory allocators in production high-throughput pathways.

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 Delta-Aggregation State Table Memory Ceiling Invariant critical for AI coding assistants?

Enforces deterministic memory limits on OpenTelemetry SDK metric readers by mandating bounded cardinality state tables and delta temporality aggregation. High-cardinality label explosions without pre-export bucketing or explicit cardinal limits induce unbounded heap retention and trigger catastrophic out-of-memory crashes. All MeterProvider instantiations must configure explicit stream boundary views and attribute filter processors. 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 Cumulative Histogram Aggregation with High-Cardinality Ephemeral Attributes) 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