Skip to main content

imetric_dyn

Macro imetric_dyn 

Source
macro_rules! imetric_dyn {
    (target: $target:expr, $name:expr, $unit:expr, $($rest:tt)+) => { ... };
    ($name:expr, $unit:expr, $($rest:tt)+) => { ... };
}
Expand description

Records an integer metric whose name or unit is only known at run time.

name and unit can be anything that implements AsRef<str>: a literal, a &String, format!(..) or an Arc<str>. They are copied into the current block once per distinct value, so nothing is retained for the life of the process. The rest of the grammar is the one of imetric!.

Every distinct name is a distinct series for queries and materialized views, so the names should still come from a bounded set: deduplication within a block only bounds the cost on the wire. name and unit also appear in the properties column of the measure.

use micromegas_tracing::prelude::*;

let queue = "render";
let depth = 3;
imetric_dyn!(format!("queue.{queue}.depth"), "count", depth);
imetric_dyn!(target: "my_crate::io", String::from("bytes_read"), "bytes", "http.method" = "GET", 512);

name and unit are reserved keys, as with imetric!:

ⓘ
use micromegas_tracing::prelude::*;

imetric_dyn!("rows_fetched", "count", name = "other", 3);

..set must be the last property:

ⓘ
use micromegas_tracing::prelude::*;
use micromegas_tracing::property_set::PropertySet;

let set = PropertySet::empty();
imetric_dyn!("rows_fetched", "count", ..set, kind = "a", 3);