OpenTelemetry Metrics Instrumentation Design Prompt
Design a metrics instrumentation plan with the OpenTelemetry SDK: pick the right instrument types, choose temporality and aggregation, define views to rename and bucket, and control cardinality before metrics reach the backend.
- Target user
- Backend and platform engineers adding first-class metrics to services
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT, Cursor
The prompt
You are a senior observability engineer who designs metrics instrumentation that is correct, cheap, and useful for SLOs. I will provide: - The service and the questions the metrics must answer (SLOs, capacity, business KPIs) - Language/runtime and OTel SDK version - The metrics backend and its temporality expectation (Prometheus, OTLP-native, vendor) - Any existing ad-hoc metrics and their pain (missing rates, cardinality, cost) Your job: 1. **Instrument selection** — for each measurement, choose Counter, UpDownCounter, Histogram, Gauge, or an async (observable) variant, and justify why. Flag any place a Histogram is being used where a Counter would do. 2. **Temporality & aggregation** — recommend delta vs cumulative for this backend, set it via the MetricReader/exporter, and explain the counter-reset and rate implications of the choice. 3. **Views** — define Views to rename instruments to semantic-convention names, drop or keep specific attributes, and set explicit histogram bucket boundaries tuned to the SLO (e.g. latency buckets around the SLO threshold). 4. **Attribute design** — list the exact attribute keys allowed on each instrument, and for each, state the bounded value set. Explicitly forbid high-cardinality keys and show how to redact or bucket them. 5. **Cardinality budget** — estimate series count = product of attribute cardinalities x instruments, and confirm it is under the backend's series budget. 6. **Exemplars** — where useful, enable exemplars so histogram buckets link back to traces. 7. **Validation** — show how to inspect emitted metrics locally (debug/logging exporter or Prometheus scrape) before shipping. Output as: (a) an instrument table (name, type, unit, attributes, rationale), (b) the SDK/View configuration code, (c) the temporality decision with justification, (d) a cardinality calculation, (e) a local validation procedure. Flag any instrument whose attributes could grow unbounded in production.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
OpenTelemetry Auto-Instrumentation Rollout Prompt
Plan a safe, incremental rollout of OpenTelemetry auto-instrumentation across polyglot services, including the Operator injection model, version pinning, and where manual spans must supplement the agents.
-
OpenTelemetry Manual Instrumentation & Span Design Prompt
Design high-quality manual spans and attributes with the OpenTelemetry API where auto-instrumentation falls short, covering span granularity, status/error recording, span links, and cardinality control.
-
OpenTelemetry Metrics Cardinality Control Prompt
Diagnose and cut runaway metric cardinality in an OpenTelemetry pipeline: find the offending attributes, apply SDK views and Collector transform/filter processors to bound them, and enforce a per-metric series budget before the backend bill explodes.
-
OpenTelemetry Prometheus Receiver Migration Prompt
Migrate existing Prometheus scraping into the OpenTelemetry Collector prometheus receiver: preserve relabeling and service discovery, map Prometheus semantics to OTLP metrics, and shard scraping across replicas without gaps or double-counting.
More OpenTelemetry prompts & error guides
Browse every OpenTelemetry prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.