This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: opentelemetry-v1-29-db-pool-wait-exponential-histogram-standard

OpenTelemetry v1.29 DB Connection Wait Time Exponential Histogram Guardrail

Database connection acquisition latency distribution must be captured using Base-2 exponential histogram aggregation rather than coarse explicit buckets. Default explicit bucket boundaries obscure sub-millisecond micro-starvation and latency tail creep in connection pools, preventing detection of impending connection exhaustion cascades. OpenTelemetry v1.29 metrics semantic conventions mandate uniform high-resolution distribution instrumentation for database wait queues.

Prohibited Anti-Pattern: Coarse Explicit Histogram Buckets Masking Database Connection Pool Micro-Starvation

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: OpenTelemetry v1.29 DB Connection Wait Time Exponential Histogram Guardrail - Database connection acquisition latency distribution must be captured using Base-2 exponential histogram aggregation rather than coarse explicit buckets. Default explicit bucket boundaries obscure sub-millisecond micro-starvation and latency tail creep in connection pools, preventing detection of impending connection exhaustion cascades. OpenTelemetry v1.29 metrics semantic conventions mandate uniform high-resolution distribution instrumentation for database wait queues.
globs: src/**/telemetry.{ts,js}, src/**/metrics.{ts,js}, src/**/instrumentation.{ts,js}, src/**/db/**/*.{ts,js}, lib/**/tracing.{ts,js}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/opentelemetry-v1-29-db-pool-wait-exponential-histogram-standard"
---

# OpenTelemetry v1.29 DB Connection Wait Time Exponential Histogram Guardrail

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Coarse Explicit Histogram Buckets Masking Database Connection Pool Micro-Starvation

## System Constraints
You are a Principal Software Architect enforcing OpenTelemetry Semantic Conventions v1.29 for database connection management. You must ensure all connection pool wait queue duration metrics (db.client.connection.wait_time) use exponential histogram aggregation with sufficient scale and bucket capacities to catch micro-starvation events before cascade failures occur.

## Strict Guidelines
- Engineers MUST ALWAYS configure an OpenTelemetry View targeting 'db.client.connection.wait_time' utilizing ExponentialHistogramAggregation with a minimum maxSize of 160.
- Engineers MUST NOT rely on default SDK ExplicitBucketHistogram aggregations whose static thresholds (>5ms or >10ms) hide microsecond-level connection acquisition queuing delays.
- Code SHOULD enforce unit 's' (seconds) and report attributes conforming to v1.29 semantic conventions: 'pool.name', 'db.system', and 'db.namespace'.
- Services MUST register the exponential histogram Views in the MeterProvider configuration BEFORE initializing any database clients, pools, or instrumentations.
- Components NEVER drop failed or timed-out connection attempts from the wait distribution; all acquisition outcomes must be recorded with appropriate error/state attributes.

## Bad vs Good Implementations
### Database Connection Pool Telemetry Setup

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Default metric reader uses coarse explicit histogram boundaries. Micro-starvation manifests as jitter in sub-millisecond ranges (e.g., jumping from 80µs to 2.5ms), which falls completely into the first 5ms bucket and remains invisible until complete pool collapse.
```typescript
import { MeterProvider, PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics';
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';

// ANTI-PATTERN: Default MeterProvider uses coarse explicit histogram buckets.
// 0.005s (5ms) minimum threshold masks 100µs - 4ms pool micro-starvation spikes.
const meterProvider = new MeterProvider({
  readers: [
    new PeriodicExportingMetricReader({
      exporter: new OTLPMetricExporter(),
      exportIntervalMillis: 10000,
    }),
  ],
});

const meter = meterProvider.getMeter('db-pool-meter');
const waitTimeHistogram = meter.createHistogram('db.client.connection.wait_time', {
  description: 'Time spent waiting for a connection from the pool',
  unit: 's',
});

export { meterProvider, waitTimeHistogram };
```

#### Production Standard (Correct)
> **Standard**: Configures an OpenTelemetry View with ExponentialHistogramAggregation (maxSize: 160, maxScale: 20) for 'db.client.connection.wait_time'. This provides fine-grained logarithmic resolution across sub-millisecond ranges, detecting queue growth instantly before cascading failures occur.
```typescript
import {
  MeterProvider,
  PeriodicExportingMetricReader,
  View,
  Aggregation,
  InstrumentType,
} from '@opentelemetry/sdk-metrics';
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';
import { SEMATTRS_DB_SYSTEM } from '@opentelemetry/semantic-conventions';

// PRODUCTION STANDARD: OpenTelemetry v1.29 Exponential Histogram View
// Base-2 exponential histogram with scale dynamic resolution (maxSize: 160)
const dbWaitTimeExponentialView = new View({
  instrumentName: 'db.client.connection.wait_time',
  instrumentType: InstrumentType.HISTOGRAM,
  aggregation: Aggregation.ExponentialHistogram({
    maxSize: 160,
    maxScale: 20,
  }),
});

const meterProvider = new MeterProvider({
  views: [dbWaitTimeExponentialView],
  readers: [
    new PeriodicExportingMetricReader({
      exporter: new OTLPMetricExporter(),
      exportIntervalMillis: 5000,
    }),
  ],
});

const meter = meterProvider.getMeter('db-pool-meter', '1.29.0');
const waitTimeHistogram = meter.createHistogram('db.client.connection.wait_time', {
  description: 'The time spent waiting for a database connection to become available',
  unit: 's',
});

export function recordConnectionWait(
  durationSeconds: number,
  poolName: string,
  dbSystem: string,
  state: 'acquired' | 'timeout' | 'failed'
): void {
  waitTimeHistogram.record(durationSeconds, {
    'pool.name': poolName,
    [SEMATTRS_DB_SYSTEM]: dbSystem,
    'db.client.connection.state': state,
  });
}
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: OpenTelemetry v1.29 DB Connection Wait Time Exponential Histogram Guardrail

OpenTelemetry v1.29 DB Connection Wait Time Exponential Histogram Guardrail defines an industrial-grade behavioral standard for devops engineering. Database connection acquisition latency distribution must be captured using Base-2 exponential histogram aggregation rather than coarse explicit buckets. Default explicit bucket boundaries obscure sub-millisecond micro-starvation and latency tail creep in connection pools, preventing detection of impending connection exhaustion cascades. OpenTelemetry v1.29 metrics semantic conventions mandate uniform high-resolution distribution instrumentation for database wait queues. 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: Coarse Explicit Histogram Buckets Masking Database Connection Pool Micro-Starvation 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 DriftCoarse Explicit Histogram Buckets Masking Database Connection Pool Micro-StarvationCritical
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 an OpenTelemetry View targeting 'db.client.connection.wait_time' utilizing ExponentialHistogramAggregation with a minimum maxSize of 160.

Engineers MUST ALWAYS configure an OpenTelemetry View targeting 'db.client.connection.wait_time' utilizing ExponentialHistogramAggregation with a minimum maxSize of 160.

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 rely on default SDK ExplicitBucketHistogram aggregations whose static thresholds (>5ms or >10ms) hide microsecond-level connection acquisition queuing delays.

Engineers MUST NOT rely on default SDK ExplicitBucketHistogram aggregations whose static thresholds (>5ms or >10ms) hide microsecond-level connection acquisition queuing delays.

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 enforce unit 's' (seconds) and report attributes conforming to v1.29 semantic conventions

Code SHOULD enforce unit 's' (seconds) and report attributes conforming to v1.29 semantic conventions: 'pool.name', 'db.system', and 'db.namespace'.

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 register the exponential histogram Views in the MeterProvider configuration BEFORE initializing any database clients, pools, or instrumentations.

Services MUST register the exponential histogram Views in the MeterProvider configuration BEFORE initializing any database clients, pools, or instrumentations.

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 drop failed or timed-out connection attempts from the wait distribution

Components NEVER drop failed or timed-out connection attempts from the wait distribution; all acquisition outcomes must be recorded with appropriate error/state attributes.

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 v1.29 DB Connection Wait Time Exponential Histogram Guardrail critical for AI coding assistants?

Database connection acquisition latency distribution must be captured using Base-2 exponential histogram aggregation rather than coarse explicit buckets. Default explicit bucket boundaries obscure sub-millisecond micro-starvation and latency tail creep in connection pools, preventing detection of impending connection exhaustion cascades. OpenTelemetry v1.29 metrics semantic conventions mandate uniform high-resolution distribution instrumentation for database wait queues. 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 (Coarse Explicit Histogram Buckets Masking Database Connection Pool Micro-Starvation) 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