You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#[derive(prometheus_metric_storage::MetricStorage)]#[metric(subsystem = "transport", labels("endpoint"))]structMetrics{/// Number of requests that are currently inflight.inflight: prometheus::IntGauge,/// Number of finished requests by response code.#[metric(labels("status"))]requests_finished: prometheus::IntCounterVec,/// Number of finished requests by total processing duration.#[metric(buckets(0.1, 0.2, 0.5, 1, 2, 4, 8))]requests_duration_seconds: prometheus::Histogram,}fnmain(){let metrics = Metrics::new(
prometheus::default_registry(),/* endpoint = */"0.0.0.0:8080").unwrap();
metrics.inflight.inc();
metrics.requests_finished.with_label_values(&["200"]).inc();
metrics.requests_duration_seconds.observe(0.015);}
This would enable to not forget to register metrics that are in a struct into the registry.
The text was updated successfully, but these errors were encountered:
Do I understand correctly, that this would generate the metric registration logic? I am not opposed to adding this to this crate. That said, given that it would be a proc derive macro, I suggest doing so out-of-tree, potentially only for now.
Do I understand correctly, that this would generate the metric registration logic?
Yes, currently it's pretty boilerplateish and error-prone when you have a significant set of metrics held in a struct that need to be registered, so that would make it really great on both aspects 😊
It would be super useful to have derives for metrics storages, like was done for the
prometheus
crate (essentially porting https://crates.io/crates/prometheus-metric-storage).This would enable to not forget to register metrics that are in a struct into the registry.
The text was updated successfully, but these errors were encountered: