Skip to main content

AwaMetrics

Struct AwaMetrics 

Source
pub struct AwaMetrics {
Show 49 fields pub jobs_inserted: Counter<u64>, pub enqueue_batch_size: Histogram<u64>, pub enqueue_duration_seconds: Histogram<f64>, pub jobs_completed: Counter<u64>, pub jobs_failed: Counter<u64>, pub jobs_retried: Counter<u64>, pub jobs_cancelled: Counter<u64>, pub jobs_claimed: Counter<u64>, pub claim_batches: Counter<u64>, pub dispatch_wakeups: Counter<u64>, pub dispatch_wake_to_claim_seconds: Histogram<f64>, pub dispatch_capacity_available: Histogram<u64>, pub dispatch_empty_claims: Counter<u64>, pub dispatch_unused_permits: Counter<u64>, pub dispatch_rate_limited: Counter<u64>, pub claim_batch_size: Histogram<u64>, pub claim_duration_seconds: Histogram<f64>, pub job_duration_seconds: Histogram<f64>, pub completion_flushes: Counter<u64>, pub completion_flush_batch_size: Histogram<u64>, pub completion_flush_duration_seconds: Histogram<f64>, pub promotion_batches: Counter<u64>, pub promotion_batch_size: Histogram<u64>, pub promotion_duration_seconds: Histogram<f64>, pub jobs_in_flight: UpDownCounter<i64>, pub heartbeat_batches: Counter<u64>, pub maintenance_rescues: Counter<u64>, pub jobs_waiting_external: Counter<u64>, pub queue_depth: Gauge<i64>, pub queue_lag_seconds: Gauge<f64>, pub wait_duration_seconds: Histogram<f64>, pub dlq_moved: Counter<u64>, pub dlq_retried: Counter<u64>, pub dlq_purged: Counter<u64>, pub dlq_depth: Gauge<i64>, pub queue_info: Gauge<i64>, pub job_kind_info: Gauge<i64>, pub storage_transition_ready: Gauge<i64>, pub storage_canonical_live_backlog: Gauge<i64>, pub storage_live_runtime_capability: Gauge<i64>, pub storage_state: Gauge<i64>, pub maintenance_rotate_attempts: Counter<u64>, pub maintenance_rotate_skipped_rows: Histogram<u64>, pub maintenance_prune_attempts: Counter<u64>, pub maintenance_prune_skipped_rows: Histogram<u64>, pub maintenance_branch_duration_seconds: Histogram<f64>, pub maintenance_branch_overrun_total: Counter<u64>, pub ring_current_slot: Gauge<i64>, pub ring_generation: Gauge<i64>,
}
Expand description

Awa worker metrics backed by OpenTelemetry.

Fields§

§jobs_inserted: Counter<u64>

Total jobs inserted.

§enqueue_batch_size: Histogram<u64>

Per-batch size distribution for the direct queue-storage COPY enqueue path (QueueStorage::enqueue_params_copy / Python Client.enqueue_many_copy). Lets producers see how chunky their batches actually land — useful when a target enqueue rate isn’t being hit and you need to disambiguate “batches are tiny” from “batches are slow.”

§enqueue_duration_seconds: Histogram<f64>

Per-batch wall-clock duration for the direct queue-storage COPY enqueue path. Pair with enqueue_batch_size to read jobs-per-second and per-batch latency in one Grafana row.

§jobs_completed: Counter<u64>

Total jobs completed successfully.

§jobs_failed: Counter<u64>

Total jobs that failed (terminal).

§jobs_retried: Counter<u64>

Total jobs marked retryable.

§jobs_cancelled: Counter<u64>

Total jobs cancelled.

§jobs_claimed: Counter<u64>

Total jobs claimed (dequeued) for execution.

§claim_batches: Counter<u64>

Number of dispatcher claim queries executed.

§dispatch_wakeups: Counter<u64>

Number of dispatcher wake-ups by reason.

§dispatch_wake_to_claim_seconds: Histogram<f64>

Time from wake-up to the first claim attempt.

§dispatch_capacity_available: Histogram<u64>

Number of permits available when a dispatcher wake is processed.

§dispatch_empty_claims: Counter<u64>

Number of wakes that found no jobs despite available capacity.

§dispatch_unused_permits: Counter<u64>

Number of pre-acquired permits released unused after a claim round.

§dispatch_rate_limited: Counter<u64>

Number of wakes that were blocked by rate limiting.

§claim_batch_size: Histogram<u64>

Claim batch size distribution.

§claim_duration_seconds: Histogram<f64>

Claim query duration.

§job_duration_seconds: Histogram<f64>

Job execution duration.

§completion_flushes: Counter<u64>

Number of completion batch flushes executed.

§completion_flush_batch_size: Histogram<u64>

Completion flush batch size distribution.

§completion_flush_duration_seconds: Histogram<f64>

Completion flush duration.

§promotion_batches: Counter<u64>

Number of scheduled/retryable promotion batches executed.

§promotion_batch_size: Histogram<u64>

Promotion batch size distribution.

§promotion_duration_seconds: Histogram<f64>

Promotion query duration.

§jobs_in_flight: UpDownCounter<i64>

Current in-flight jobs (can go up and down).

§heartbeat_batches: Counter<u64>

Total heartbeat batches sent.

§maintenance_rescues: Counter<u64>

Total maintenance rescue operations.

§jobs_waiting_external: Counter<u64>

Total jobs parked for external callback.

§queue_depth: Gauge<i64>

Current queue depth per state — how many jobs are in each state per queue.

§queue_lag_seconds: Gauge<f64>

Queue lag — age of the oldest available job per queue.

§wait_duration_seconds: Histogram<f64>

Time from job creation to claim — the user-visible queuing latency.

§dlq_moved: Counter<u64>

Total jobs moved into the Dead Letter Queue.

§dlq_retried: Counter<u64>

Total jobs retried out of the Dead Letter Queue.

§dlq_purged: Counter<u64>

Total DLQ rows purged.

§dlq_depth: Gauge<i64>

Current DLQ depth per queue.

§queue_info: Gauge<i64>

Info gauge for declared queue descriptors — value is always 1, the useful payload is the attribute set (display_name, owner, tags). Dashboards join it into throughput / latency panels with a * on(awa_job_queue) group_left(awa_queue_display_name, awa_queue_owner) Prometheus expression, which keeps descriptor fields out of the high-cardinality per-metric label set.

§job_kind_info: Gauge<i64>

Info gauge for declared job-kind descriptors. Same pattern as queue_info.

§storage_transition_ready: Gauge<i64>

Readiness gauge for storage transition actions such as enter_mixed_transition and finalize (1 = ready, 0 = blocked).

§storage_canonical_live_backlog: Gauge<i64>

Current canonical live backlog observed by queue-storage-capable runtimes.

§storage_live_runtime_capability: Gauge<i64>

Current live runtime count per reported storage capability.

§storage_state: Gauge<i64>

One-hot info gauge for the current storage transition state and engines.

§maintenance_rotate_attempts: Counter<u64>

Maintenance ring rotation attempts, attributed to (ring, outcome, blocker). For Rotated outcomes the awa.ring.blocker attribute is “none”; for SkippedBusy it carries the per-ring blocker label (“queue.ready_rows”, “queue.claim_attempt_batches”, “queue.done_rows”, “queue.tombstone_rows”, “queue.ready_segments”, “queue.receipt_completion_batch_rows”, “queue.receipt_completion_tombstone_rows”, “queue.terminal_delta_rows”, “lease.rows”, “claim.rows”, “claim.closure_rows”, “claim.closure_batch_rows”). One increment per non-zero blocker means a single SkippedBusy with multiple populated fields emits multiple events; that’s intentional so dashboards can attribute blame independently.

§maintenance_rotate_skipped_rows: Histogram<u64>

Magnitudes of the per-blocker row counts when a rotation is SkippedBusy. Histogram so dashboards can show whether the ring is pinned by handfuls of stragglers or by mountains of unfinished work.

§maintenance_prune_attempts: Counter<u64>

Maintenance ring prune attempts, attributed to (ring, outcome, reason). reason=“none” for Pruned/Noop/Blocked; otherwise carries the SkipReason discriminator (e.g. “queue.active_leases”, “queue.pending_ready”, “claim.open”).

§maintenance_prune_skipped_rows: Histogram<u64>

Magnitude of the reason count when prune returns SkippedActive.

§maintenance_branch_duration_seconds: Histogram<f64>

Per-branch wall-clock duration for the maintenance leader’s main tokio::select! loop, attributed by awa.maintenance.branch. Records the time from the moment a select arm fires to the moment its body returns — so each sample is the body’s contribution to head-of-line delay for every other branch on the same loop. Dashboards alert on histogram_quantile(0.99, ...) per branch to see whether any one branch is dominating select-loop time. Issue #242.

§maintenance_branch_overrun_total: Counter<u64>

Counter of “delayed tick” transitions per maintenance branch. One increment is emitted when a branch fires after running longer than its own tick interval in the previous iteration — i.e. the timer was already overdue at the moment it fired. Emits on transition (on-time -> delayed) only, not on every subsequent overrun tick, so a sustained slow branch produces one event per “overrun episode” rather than one per tick. Fleets alert on this rather than scraping the matching tracing::warn! line. Issue #242.

§ring_current_slot: Gauge<i64>

Current ring current_slot per ring, sampled from each rotate call. The slot number itself isn’t meaningful but the rate of advance is — dashboards plot rate(slot_changes) to see whether rotation is healthy or pinned.

§ring_generation: Gauge<i64>

Current ring generation per ring. Always-increasing; dashboards show its derivative as “rotations per minute”.

Implementations§

Source§

impl AwaMetrics

Source

pub fn new(meter: &Meter) -> AwaMetrics

Create metrics from an OpenTelemetry meter.

Instrument names come from names so the public constants and the registered instruments can’t drift — a rename in names::* updates the registration too.

Source

pub fn from_global() -> AwaMetrics

Create metrics using the global OTel meter provider with meter name “awa”.

Source

pub fn record_job_completed(&self, kind: &str, queue: &str, duration: Duration)

Record a job completion with duration and attributes.

Source

pub fn record_job_failed(&self, kind: &str, queue: &str, terminal: bool)

Record a job failure.

Source

pub fn record_job_retried(&self, kind: &str, queue: &str)

Record a job retry.

Source

pub fn record_enqueue_batch( &self, queue: &str, batch_size: u64, duration: Duration, )

Record a producer batch through the direct queue-storage COPY enqueue path (QueueStorage::enqueue_params_copy / Python Client.enqueue_many_copy).

batch_size is the row count that COPY actually wrote; duration is the wall-clock time the producer spent in the COPY call (start to commit), not including pre-batch row preparation.

At batch_size = 0 this is a no-op — empty batches are valid callers and don’t need a metric sample.

Source

pub fn record_job_claimed(&self, queue: &str, batch_size: u64)

Record a job claimed from queue.

Use this for the canonical engine, which has no per-shard concept. The queue-storage engine uses record_job_claimed_by_shard so dashboards can read per-shard fairness directly.

Source

pub fn record_job_claimed_by_shard( &self, queue: &str, enqueue_shard: i16, batch_size: u64, )

Record a job claimed from queue, decorated with the enqueue shard.

Used by the queue-storage path so dashboards can sum awa.job.claimed by awa.enqueue.shard and confirm the claim ordering is rotating across shards rather than starving the higher-numbered ones. At enqueue_shards > 1 this is the only fairness signal that the operator gets from telemetry alone; at enqueue_shards = 1 the attribute is always 0 and the series is identical to the un-decorated form.

Call sites must not double-emit — invoke either this OR record_job_claimed, never both for the same claim, or the awa.job.claimed total will count each claim twice when dashboards sum across all attribute combinations.

Source

pub fn record_claim_batch( &self, queue: &str, batch_size: u64, duration: Duration, )

Record a dispatcher claim query batch and its latency.

Source

pub fn record_dispatch_wake(&self, queue: &str, reason: &str)

Record a dispatcher wake-up reason.

Source

pub fn record_dispatch_wake_to_claim( &self, queue: &str, reason: &str, duration: Duration, )

Record time from wake-up to the first claim attempt.

Source

pub fn record_dispatch_capacity_available( &self, queue: &str, reason: &str, permits: u64, )

Record how many permits were available on a dispatcher wake.

Source

pub fn record_dispatch_empty_claim(&self, queue: &str, reason: &str)

Record a dispatcher wake that found no jobs.

Source

pub fn record_dispatch_unused_permits(&self, queue: &str, count: u64)

Record permits released unused after a claim round.

Source

pub fn record_dispatch_rate_limited(&self, queue: &str, reason: &str)

Record a wake that could not claim because of rate limiting.

Source

pub fn record_completion_flush( &self, shard: usize, batch_size: u64, duration: Duration, )

Record a completion batch flush.

Source

pub fn record_promotion_batch( &self, state: &str, batch_size: u64, duration: Duration, )

Record a scheduled/retryable promotion batch.

Source

pub fn record_in_flight_change(&self, queue: &str, delta: i64)

Record in-flight change.

Source

pub fn record_queue_depth(&self, queue: &str, state: &str, count: i64)

Record queue depth for a specific state.

Source

pub fn record_queue_lag(&self, queue: &str, lag_seconds: f64)

Record queue lag (age of oldest available job).

Source

pub fn record_wait_duration(&self, queue: &str, seconds: f64)

Record job wait duration (time from creation to claim).

Source

pub fn record_dlq_moved(&self, kind: &str, queue: &str, reason: &str)

Record a job moved into the DLQ.

Source

pub fn record_dlq_moved_bulk( &self, kind: Option<&str>, queue: Option<&str>, reason: &str, count: u64, )

Record a bulk admin move into the DLQ.

Source

pub fn record_dlq_retried(&self, queue: Option<&str>, count: u64)

Record jobs retried out of the DLQ.

Source

pub fn record_dlq_purged(&self, queue: Option<&str>, count: u64)

Record DLQ rows purged.

Source

pub fn record_dlq_depth(&self, queue: &str, count: i64)

Record current DLQ depth for a queue.

Source

pub fn record_queue_info( &self, queue: &str, display_name: Option<&str>, description: Option<&str>, owner: Option<&str>, docs_url: Option<&str>, tags: &[String], )

Emit the info gauge for a declared queue descriptor. Called once per descriptor on every runtime snapshot tick — constant value of 1 with the descriptor fields as attributes. Optional fields that are None are elided so we don’t produce display_name="" series.

Source

pub fn record_job_kind_info( &self, kind: &str, display_name: Option<&str>, description: Option<&str>, owner: Option<&str>, docs_url: Option<&str>, tags: &[String], )

Emit the info gauge for a declared job-kind descriptor. Same shape as record_queue_info.

Source

pub fn record_storage_transition_ready(&self, action: &str, ready: bool)

Record whether a storage transition action is currently ready.

Source

pub fn record_storage_canonical_live_backlog(&self, count: i64)

Record canonical live backlog for the storage transition.

Source

pub fn record_storage_live_runtime_capability( &self, capability: &str, count: i64, )

Record the number of live runtimes reporting a given storage capability.

Source

pub fn record_storage_state(&self, status: &StorageStatus)

Emit the current storage transition state as a one-hot info gauge.

Source

pub fn record_rotate_outcome(&self, ring: &'static str, outcome: &RotateOutcome)

Record a ring rotation outcome.

ring is one of “queue” / “lease” / “claim” — set by the caller based on which rotate fn returned the outcome. For SkippedBusy, every non-zero blocker count emits its own counter increment plus a histogram sample, so a queue rotate skipped on (ready=42, done=17) produces two events with different awa.ring.blocker labels. This makes sum by (awa.ring.blocker) (rate(...)) work cleanly in Grafana.

Source

pub fn record_maintenance_branch_duration( &self, branch: &'static str, duration: Duration, )

Record the wall-clock duration of one maintenance tokio::select! arm. branch is a static name (e.g. "promote_scheduled", "rescue_stale_heartbeats") so the attribute set stays bounded. Issue #242.

Source

pub fn record_maintenance_branch_overrun(&self, branch: &'static str)

Record one maintenance branch overrun episode — a transition from “on-time” to “delayed” for branch. Increments awa.maintenance.branch.overrun (Prometheus: awa_maintenance_branch_overrun_total{branch="<name>"}). Issue #242.

Source

pub fn record_prune_outcome(&self, ring: &'static str, outcome: &PruneOutcome)

Record a ring prune outcome.

Trait Implementations§

Source§

impl Clone for AwaMetrics

Source§

fn clone(&self) -> AwaMetrics

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for AwaMetrics

No-op metrics for when OTel is not configured.

Source§

fn default() -> AwaMetrics

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more