Skip to main content

Metrics reference

SQL 0.1.1 and SDKs 0.4.0 expose database queue metrics and optional client instrumentation. Client instrumentation contract 1 uses scope postgremq, version 1; that contract version is separate from package versions.

Database state​

postgremq.queue_metrics() returns one row per queue, including empty and expired queues. All rows use one statement timestamp. The function is read-only, uses caller privileges, and reads no payloads.

SQL columnOpenTelemetry nameUnit and meaning
activepostgremq.queue.active1; live Durable or unexpired Exclusive queue is 1, expired is 0.
readypostgremq.queue.messages.ready{message}; visible unsettled rows under the attempt limit; zero for expired queues.
delayedpostgremq.queue.messages.delayed{message}; pending rows with a future visibility time.
processingpostgremq.queue.messages.processing{message}; processing rows with a future visibility deadline.
exhaustedpostgremq.queue.messages.exhausted{message}; visible unsettled rows at the finite attempt limit, awaiting retirement.
dead_letterpostgremq.queue.messages.dead_letter{message}; retained DLQ entries.
oldest_ready_age_secondspostgremq.queue.oldest_ready_ages; age since earliest ready visibility time, zero when no ready work or queue expired.

These are gauges with queue_name and topic_name attributes. Ready includes FIFO successors blocked behind the head and rows temporarily locked. Processing is not a count of active callbacks. Delayed, processing, exhausted, and dead-letter state can remain visible for expired queues.

Ready age excludes the original scheduled delay and changes with retry/release visibility. It is not publication age. Raw status counts from get_queue_statistics answer a different question and include completed history but not DLQ entries.

Client instruments​

NameKind / unitRecorded boundary
messaging.client.operation.durationHistogram / sOne logical operation, including pool acquisition and internal retries.
messaging.process.durationHistogram / sOne handler callback; excludes automatic settlement after return.
messaging.client.sent.messagesCounter / {message}Each attempted publish query, including failed attempts.
messaging.client.consumed.messagesCounter / {message}Each successfully decoded claimed delivery, including prefetch/redelivery.
postgremq.client.handlers.activeUpDownCounter / {handler}Callback entry adds one; exit removes one.
postgremq.client.renewal.lostCounter / {message}Automatic renewal retires a still-registered delivery whose lease is lost.

Duration bucket boundaries in seconds are 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10. Applications may override aggregation with their telemetry SDK.

Operations and attributes​

Operation names are publish, consume, ack, nack, release, extend, extend_batch, and keep_alive. Handler observations use process. Empty consume queries count; batch renewal produces one observation per batch, not per entry. TypeScript does not record the automatic keep_alive operation in this contract.

Common attributes are messaging.system = postgremq, operation name/type, and destination name. Publish uses the topic; single-queue operations use the queue. Cross-queue renewal operations omit destination name. Every operation-duration and sent-message observation carries postgremq.transaction, set to true for caller-owned transactional operations and false otherwise; consumed deliveries carry postgremq.redelivered = true when their attempt exceeds one and false on the first attempt.

Failed operations use bounded error.type values: lease_lost, queue_not_found, validation, connection_closed, cancelled, deadline_exceeded, or other. Handler failures use handler_error; cancellation has its own outcome. Raw SQL, payloads, tokens, message IDs, and arbitrary error text are not metric attributes.

Interpretation boundaries​

A publish retry can add two sent attempts and one logical-operation duration. A transactional query can record success before the caller rolls back. Sent metrics therefore cannot establish committed message counts. Go includes failed driver query acquisition in send attempts; TypeScript and Rust acquire first, so failed pre-query acquisition adds no send attempt there.

Stream consumers have no automatic callback duration or active-handler count. Explicit settlement inside a handler contributes to callback time and also records its own operation. A normal handler return is not independent proof of business success or committed settlement.

Renewal loss is not every stale-token error. Ordinary shutdown cancellation is not counted. Go and TypeScript can count renewal loss while settlement is still finishing; Rust excludes a delivery whose settlement started.

Cancellation/deadline classification depends on SDK visibility. TypeScript internal query deadlines map to other; Rust can record a dropped operation future as cancelled; Go reports context cancellation/deadline. Server statement cancellation is other in all three.

Use Application metrics for setup and Monitoring for scraper configuration and alerts. The machine-readable contract records scope, version, duration buckets, instrument names and units, and a test scenario. Instrument kinds and attributes are documented above and defined by the SDK instrumentation; they are not all present in that JSON file.