pub struct MetricsDispenser { /* private fields */ }Expand description
Wraps an inner OpDispenser to publish per-cycle synthetic
metrics declared in the op template’s metrics: map
(SRD-40b §6).
Per-cycle responsibilities (in order, matching SRD-40b §5.2 → §6 pipeline):
- Await the inner dispenser’s
execute. With acrate::wrappers::ResultDispenserin the wrapper stack between the inner adapter and this one, declaredresult:wires are already written throughctx.wires.writeto the per-fiber kernel by the time we run. - For each declared metric, read the value through
ctx.wires.get(name)(bare-binding-name canonical form per SRD-40b §1). The read pulls fresh through the eval cone so any computed output (e.g.row_count := count) reflects this cycle’s value. - Apply the optional [
metric_format::FormatSpec] sanitiser to round to the configured precision (Phase B). - Dispatch to the kind-specific instrument record method
(SRD-40b §6.1):
- [
MetricKind::Gauge] → [ValueGauge::set] (f64). - [
MetricKind::Histogram] → [Histogram::record] (truncated to u64 after format rounding). - [
MetricKind::Counter] → [Counter::inc_by] (u64); non-positive values warn and skip — counters are monotonic by definition.
- [
Non-bare-name expressions (factor * 2.0, if(...), …) are
deferred — the wrap step errors when spec.value is not
a bare identifier.
Implementations§
Source§impl MetricsDispenser
impl MetricsDispenser
Sourcepub fn wrap(
inner: Arc<dyn OpDispenser>,
metrics: &HashMap<String, MetricSpec>,
component: &mut Component,
component_arc: &Arc<RwLock<Component>>,
fx: &mut ScopeFixture,
) -> Result<Arc<dyn OpDispenser>, String>
pub fn wrap( inner: Arc<dyn OpDispenser>, metrics: &HashMap<String, MetricSpec>, component: &mut Component, component_arc: &Arc<RwLock<Component>>, fx: &mut ScopeFixture, ) -> Result<Arc<dyn OpDispenser>, String>
Wrap an inner dispenser with synthetic-metric publication
for the op template’s metrics: declarations.
Init steps (SRD-40b §6 init):
- Empty declaration → return
innerunchanged. No overhead for ops that don’t publish synthetic metrics. - For each
(name, spec), allocate the kind-specific instrument and register it on the component viaComponent::register_instrument. A duplicate-family collision (§7.2) errors here, before any cycle runs. - Pre-parse the optional
format:string into a [FormatSpec].
component is borrowed mutably so register_instrument
can claim the family slot atomically with the instrument
allocation. The same Arc<...> is held both on the
component (for cadence-reporter capture) and in the
returned dispenser’s slots (for per-cycle record).
Trait Implementations§
Source§impl OpDispenser for MetricsDispenser
impl OpDispenser for MetricsDispenser
Source§fn execute<'a>(
&'a self,
cycle: u64,
ctx: &'a ExecCtx<'a>,
) -> Pin<Box<dyn Future<Output = Result<OpResult, ExecutionError>> + Send + 'a>>
fn execute<'a>( &'a self, cycle: u64, ctx: &'a ExecCtx<'a>, ) -> Pin<Box<dyn Future<Output = Result<OpResult, ExecutionError>> + Send + 'a>>
Execute an operation for the given cycle. Read more
Source§fn inner_dispenser(&self) -> Option<&dyn OpDispenser>
fn inner_dispenser(&self) -> Option<&dyn OpDispenser>
Returns the wrapped dispenser when this is a
wrapper,
None when this is a leaf (the adapter’s
base dispenser — e.g. CQL raw / prepared / batch,
HTTP, stdout, plotter, …). Read moreSource§fn describe(&self) -> Option<String>
fn describe(&self) -> Option<String>
One-line description of the op this dispenser
represents — typically the statement text /
request shape with bind-point placeholders left
unresolved (
{table}, {key}, ?, …). Read moreSource§fn describe_resolved(&self, wires: &dyn WireSource) -> Option<String>
fn describe_resolved(&self, wires: &dyn WireSource) -> Option<String>
Render the actual op the dispenser would fire for the given
cycle — the dryrun-equivalent view of the statement after
every bind point is interpolated. Read more
Source§fn canonical_kernel(&self) -> Option<&Arc<dyn Kernel>>
fn canonical_kernel(&self) -> Option<&Arc<dyn Kernel>>
SRD-68 invariant I-3 — the dispenser’s canonical Polydat Kernel,
established at construction by
map_op from its parent — the
parent itself, or a kernel bound under it. Any engine: the
executor finds the program to bind per fiber by program_id.
Returns None for dispensers that don’t own a kernel
(adapters with no Polydat needs, or wrappers that delegate to
an inner dispenser). Read moreSource§fn adapter_metrics(&self) -> Vec<(String, Labels, MetricValue)>
fn adapter_metrics(&self) -> Vec<(String, Labels, MetricValue)>
Snapshot adapter-specific metrics for inclusion in the capture
snapshot. Read more
Source§fn status_counters(&self) -> Vec<(&str, u64)>
fn status_counters(&self) -> Vec<(&str, u64)>
Adapter-specific status line entries (cumulative, non-destructive read). Read more
Source§fn rows_per_op(&self) -> usize
fn rows_per_op(&self) -> usize
The op’s uniform per-invocation cursor consumption — how many
consecutive wire ordinals one
execute call reads and covers. Read moreimpl WrappingDispenser for MetricsDispenser
Auto Trait Implementations§
impl !RefUnwindSafe for MetricsDispenser
impl !UnwindSafe for MetricsDispenser
impl Freeze for MetricsDispenser
impl Send for MetricsDispenser
impl Sync for MetricsDispenser
impl Unpin for MetricsDispenser
impl UnsafeUnpin for MetricsDispenser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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