Skip to content
Snippets Groups Projects
Commit 3a862e2a authored by Vsevolod Stakhov's avatar Vsevolod Stakhov Committed by GitHub
Browse files

Add metrics timer for the `PerRequest` structure lifetime (#5108)

* Add metrics timer for the PerRequest structure lifetime

* Add custom buckets
parent d631f1de
Branches
No related merge requests found
......@@ -131,6 +131,13 @@ impl Metrics {
.as_ref()
.map(|metrics| metrics.collator_peer_count.set(collator_peers as u64));
}
/// Provide a timer for `PerRequest` structure which observes on drop.
fn time_collation_request_duration(
&self,
) -> Option<metrics::prometheus::prometheus::HistogramTimer> {
self.0.as_ref().map(|metrics| metrics.collation_request_duration.start_timer())
}
}
#[derive(Clone)]
......@@ -139,6 +146,7 @@ struct MetricsInner {
process_msg: prometheus::Histogram,
handle_collation_request_result: prometheus::Histogram,
collator_peer_count: prometheus::Gauge<prometheus::U64>,
collation_request_duration: prometheus::Histogram,
}
impl metrics::Metrics for Metrics {
......@@ -181,6 +189,15 @@ impl metrics::Metrics for Metrics {
)?,
registry,
)?,
collation_request_duration: prometheus::register(
prometheus::Histogram::with_opts(
prometheus::HistogramOpts::new(
"polkadot_parachain_collator_protocol_validator_collation_request_duration",
"Lifetime of the `PerRequest` structure",
).buckets(vec![0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.75, 0.9, 1.0, 1.2, 1.5, 1.75]),
)?,
registry,
)?,
};
Ok(Metrics(Some(metrics)))
......@@ -194,6 +211,8 @@ struct PerRequest {
to_requester: oneshot::Sender<(CandidateReceipt, PoV)>,
/// A jaeger span corresponding to the lifetime of the request.
span: Option<jaeger::Span>,
/// A metric histogram for the lifetime of the request
_lifetime_timer: Option<metrics::prometheus::prometheus::HistogramTimer>,
}
#[derive(Debug)]
......@@ -762,6 +781,7 @@ async fn request_collation<Context>(
.span_per_relay_parent
.get(&relay_parent)
.map(|s| s.child("collation-request").with_para_id(para_id)),
_lifetime_timer: state.metrics.time_collation_request_duration(),
};
state
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment