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
Obtain a Meter from the global MeterProvider with a versioned instrumentation scope name
Create a Counter for monotonically increasing values (requests, errors) using meter.createCounter, then call counter.add(1, attributes) on each event
Use meter.createUpDownCounter for values that can rise and fall (queue depth, active connections) and call add with positive or negative deltas
Create a Histogram for latency or payload size using meter.createHistogram with explicit bucket boundaries tuned to the expected distribution
Set the export interval on the PeriodicExportingMetricReader and choose the correct temporality (cumulative vs delta) for the backend
Known gotchas
Using cumulative temporality with a short export interval sends ever-growing counter values; the backend must compute rate-of-change, whereas delta temporality sends differences directly
High-cardinality attribute combinations on metrics explode the number of time series; enforce an attribute allowlist using Views
Histogram bucket boundaries default to a generic set; recording latencies in milliseconds against microsecond boundaries produces all observations in a single bucket
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?