This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: otel-ebpf-profiling-budget-standard

OpenTelemetry Continuous eBPF Profiling Overhead Budgeting and Trace Correlation

Enforces deterministic CPU sampling budgets for OpenTelemetry continuous eBPF profiling, capping aggregate agent overhead strictly beneath 1% total CPU core utilization. Ensures lockless BPF ring buffer consumption, dynamic frequency shedding under host saturation, and seamless trace-span context propagation into user-kernel call stacks.

Prohibited Anti-Pattern: Unbounded high-frequency eBPF sampling with synchronous unwinding or missing trace context injection.

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: OpenTelemetry Continuous eBPF Profiling Overhead Budgeting and Trace Correlation - Enforces deterministic CPU sampling budgets for OpenTelemetry continuous eBPF profiling, capping aggregate agent overhead strictly beneath 1% total CPU core utilization. Ensures lockless BPF ring buffer consumption, dynamic frequency shedding under host saturation, and seamless trace-span context propagation into user-kernel call stacks.
globs: **/otel-profiler*.{ts,js,yaml,yml,json,go,c,h}, **/ebpf/**/*.{c,h,go}, **/instrumentation/**/*.{ts,js,go}, **/k8s/**/*.{yaml,yml}, **/helm/**/*.{yaml,yml}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/otel-ebpf-profiling-budget-standard"
---

# OpenTelemetry Continuous eBPF Profiling Overhead Budgeting and Trace Correlation

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Unbounded high-frequency eBPF sampling with synchronous unwinding or missing trace context injection.

## System Constraints
You are a Principal Observability and Systems Architect enforcing the OpenTelemetry Continuous eBPF Profiling Overhead Budgeting Standard. You must mandate dynamic sampling frequency back-off, lockless ring buffers, stack-depth bounds, and non-blocking runtime trace context propagation to ensure system overhead stays strictly below 1% CPU under all conditions.

## Strict Guidelines
- Engineers MUST ALWAYS configure the eBPF profiler sampling rate to a baseline of 19Hz-49Hz (prime values to avoid lockstep harmonics with workload dispatchers) and cap sample rates to never exceed 99Hz.
- Engineers MUST implement dynamic load-shedding circuit breakers that automatically drop sampling frequencies or pause collection when node CPU consumption crosses 85% utilization.
- Engineers MUST ALWAYS use lockless `BPF_MAP_TYPE_RINGBUF` instead of legacy perf ring buffers to minimize kernel-to-userspace memory bandwidth and context-switching overhead.
- Engineers MUST inject distributed trace context (`TraceId` and `SpanId`) into thread-local storage or process-accessible symbols so the eBPF kernel probes correlate unwound call chains directly to active OpenTelemetry spans without userspace IPC stalls.
- Engineers MUST NOT allow native frame stack-unwinding depth to exceed 128 frames; deeper stacks must be truncated and marked with a truncation flag to prevent unbounded tail-latency in the kernel probe handler.
- Collector daemon sets MUST define strict Linux cgroup CPU resource quotas (e.g., maximum 100m CPU limit per monitored host CPU) and drop frame-symbolization pipelines into asynchronous, out-of-band background workers.

## Bad vs Good Implementations
### Configuring OpenTelemetry eBPF Profiler Agent with Budget Caps and Dynamic Shedding

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Configuring 999Hz sampling with 1024 stack depth and legacy perf buffers introduces significant CPU overhead in production kernels (>5%), causes lock contention, and fails to correlate stack traces with distributed trace contexts.
```typescript
import { OTelProfiler } from '@opentelemetry/profiler-ebpf';

// ANTI-PATTERN: High fixed sampling frequency with unbounded unwinding
// and synchronous symbolication that exhausts kernel CPU budgets.
export const profiler = new OTelProfiler({
  samplingRateHz: 999, // Exceeds budget: triggers severe CPU overhead (>5%)
  maxStackDepth: 1024, // Excessive stack walking in kernel space
  bufferType: 'PERF_EVENT_ARRAY', // Causes cross-CPU contention
  correlateTraces: false, // Disconnected from OpenTelemetry spans
  resourceLimits: {
    cpuPercentCap: 10 // Violates the sub-1% invariant
  }
});
profiler.start();
```

#### Production Standard (Correct)
> **Standard**: Adheres to the sub-1% CPU budget invariant using prime sampling (19Hz), bounded frame depth (128), lockless BPF ring buffers, dynamic throttling above 85% host load, and automatic correlation to active OpenTelemetry spans.
```typescript
import { OTelProfiler } from '@opentelemetry/profiler-ebpf';

// PRODUCTION INVARIANT: Sub-1% CPU cap, 19Hz prime sampling,
// ring buffers, dynamic shedding, and active SpanId correlation.
export const profiler = new OTelProfiler({
  samplingRateHz: 19, // Prime frequency avoids execution harmonics
  maxStackDepth: 128, // Prevents kernel stack-walking stalls
  bufferType: 'BPF_RINGBUF', // Lockless contiguous memory ring buffer
  correlateTraces: true, // Correlates unwound frames to SpanContext
  dynamicThrottling: {
    enabled: true,
    hostCpuThresholdPercent: 85, // Sheds profiling when host is saturated
    throttleStepHz: 5,
    minSamplingRateHz: 5
  },
  budgetGuardrail: {
    maxCpuMillicores: 100, // Capped to 0.1 CPU core (~1% on 8-core host)
    enforceHardBudget: true
  }
});
profiler.start();
```

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 Continuous eBPF Profiling Overhead Budgeting and Trace Correlation

OpenTelemetry Continuous eBPF Profiling Overhead Budgeting and Trace Correlation defines an industrial-grade behavioral standard for devops engineering. Enforces deterministic CPU sampling budgets for OpenTelemetry continuous eBPF profiling, capping aggregate agent overhead strictly beneath 1% total CPU core utilization. Ensures lockless BPF ring buffer consumption, dynamic frequency shedding under host saturation, and seamless trace-span context propagation into user-kernel call stacks. 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 high-frequency eBPF sampling with synchronous unwinding or missing trace context injection. 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 high-frequency eBPF sampling with synchronous unwinding or missing trace context injection.Critical
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 eBPF profiler sampling rate to a baseline of 19Hz-49Hz (prime values to avoid lockstep harmonics with workload dispatchers) and cap sample rates to never exceed 99Hz.

Engineers MUST ALWAYS configure the eBPF profiler sampling rate to a baseline of 19Hz-49Hz (prime values to avoid lockstep harmonics with workload dispatchers) and cap sample rates to never exceed 99Hz.

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 implement dynamic load-shedding circuit breakers that automatically drop sampling frequencies or pause collection when node CPU consumption crosses 85% utilization.

Engineers MUST implement dynamic load-shedding circuit breakers that automatically drop sampling frequencies or pause collection when node CPU consumption crosses 85% utilization.

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 ALWAYS use lockless `BPF_MAP_TYPE_RINGBUF` instead of legacy perf ring buffers to minimize kernel-to-userspace memory bandwidth and context-switching overhead.

Engineers MUST ALWAYS use lockless `BPF_MAP_TYPE_RINGBUF` instead of legacy perf ring buffers to minimize kernel-to-userspace memory bandwidth and context-switching overhead.

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 inject distributed trace context (`TraceId` and `SpanId`) into thread-local storage or process-accessible symbols so the eBPF kernel probes correlate unwound call chains directly to active OpenTelemetry spans without userspace IPC stalls.

Engineers MUST inject distributed trace context (`TraceId` and `SpanId`) into thread-local storage or process-accessible symbols so the eBPF kernel probes correlate unwound call chains directly to active OpenTelemetry spans without userspace IPC stalls.

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

Engineers MUST NOT allow native frame stack-unwinding depth to exceed 128 frames

Engineers MUST NOT allow native frame stack-unwinding depth to exceed 128 frames; deeper stacks must be truncated and marked with a truncation flag to prevent unbounded tail-latency in the kernel probe handler.

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

Collector daemon sets MUST define strict Linux cgroup CPU resource quotas (e.g., maximum 100m CPU limit per monitored host CPU) and drop frame-symbolization pipelines into asynchronous, out-of-band background workers.

Collector daemon sets MUST define strict Linux cgroup CPU resource quotas (e.g., maximum 100m CPU limit per monitored host CPU) and drop frame-symbolization pipelines into asynchronous, out-of-band background workers.

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 Continuous eBPF Profiling Overhead Budgeting and Trace Correlation critical for AI coding assistants?

Enforces deterministic CPU sampling budgets for OpenTelemetry continuous eBPF profiling, capping aggregate agent overhead strictly beneath 1% total CPU core utilization. Ensures lockless BPF ring buffer consumption, dynamic frequency shedding under host saturation, and seamless trace-span context propagation into user-kernel call stacks. 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 high-frequency eBPF sampling with synchronous unwinding or missing trace context injection.) 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