Record OTel metrics using a Counter, UpDownCounter, and Histogram with the OTel Metrics API and SDK

domain: opentelemetry.io · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Obtain a Meter from the global MeterProvider with a versioned instrumentation scope name
  2. Create a Counter for monotonically increasing values (requests, errors) using meter.createCounter, then call counter.add(1, attributes) on each event
  3. Use meter.createUpDownCounter for values that can rise and fall (queue depth, active connections) and call add with positive or negative deltas
  4. Create a Histogram for latency or payload size using meter.createHistogram with explicit bucket boundaries tuned to the expected distribution
  5. Set the export interval on the PeriodicExportingMetricReader and choose the correct temporality (cumulative vs delta) for the backend

Known gotchas

Related routes

Configure OTel metrics SDK for delta vs cumulative temporality per exporter
opentelemetry.io · 5 steps · unrated
Use the OTel Collector count connector to derive a request-count metric from log records without modifying the application
opentelemetry.io · 5 steps · unrated
Link metric spikes to traces using OTel exemplars
opentelemetry.io · 6 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans