pub fn new<F>(function: F) -> impl GaugeExpand description
A Gauge that calls function, standing in for a Java lambda
implementing Gauge (e.g. (config, now) -> metrics.size()): function
is MetricValueProvider::value. A method Java adds later as an overload
of value gets its own factory, with_<parameter>.
§Arguments
function- computes the value from the config and the time in milliseconds
§Returns
The gauge calling function.
use confluent_kafka::common::MetricValue;
use confluent_kafka::common::metrics::{gauge, Metrics};
let metrics = Metrics::new();
let name = metrics.metric_name("answer", "example");
metrics
.add_metric_with_metric_value_provider(name, Box::new(gauge::new(|_config, _now| MetricValue::Int(42))))
.unwrap();