mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 01:41:09 +00:00
Add metrics timer for the PerRequest structure lifetime (#5108)
* Add metrics timer for the PerRequest structure lifetime * Add custom buckets
This commit is contained in:
@@ -131,6 +131,13 @@ impl Metrics {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|metrics| metrics.collator_peer_count.set(collator_peers as u64));
|
.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)]
|
#[derive(Clone)]
|
||||||
@@ -139,6 +146,7 @@ struct MetricsInner {
|
|||||||
process_msg: prometheus::Histogram,
|
process_msg: prometheus::Histogram,
|
||||||
handle_collation_request_result: prometheus::Histogram,
|
handle_collation_request_result: prometheus::Histogram,
|
||||||
collator_peer_count: prometheus::Gauge<prometheus::U64>,
|
collator_peer_count: prometheus::Gauge<prometheus::U64>,
|
||||||
|
collation_request_duration: prometheus::Histogram,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl metrics::Metrics for Metrics {
|
impl metrics::Metrics for Metrics {
|
||||||
@@ -181,6 +189,15 @@ impl metrics::Metrics for Metrics {
|
|||||||
)?,
|
)?,
|
||||||
registry,
|
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)))
|
Ok(Metrics(Some(metrics)))
|
||||||
@@ -194,6 +211,8 @@ struct PerRequest {
|
|||||||
to_requester: oneshot::Sender<(CandidateReceipt, PoV)>,
|
to_requester: oneshot::Sender<(CandidateReceipt, PoV)>,
|
||||||
/// A jaeger span corresponding to the lifetime of the request.
|
/// A jaeger span corresponding to the lifetime of the request.
|
||||||
span: Option<jaeger::Span>,
|
span: Option<jaeger::Span>,
|
||||||
|
/// A metric histogram for the lifetime of the request
|
||||||
|
_lifetime_timer: Option<metrics::prometheus::prometheus::HistogramTimer>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -762,6 +781,7 @@ async fn request_collation<Context>(
|
|||||||
.span_per_relay_parent
|
.span_per_relay_parent
|
||||||
.get(&relay_parent)
|
.get(&relay_parent)
|
||||||
.map(|s| s.child("collation-request").with_para_id(para_id)),
|
.map(|s| s.child("collation-request").with_para_id(para_id)),
|
||||||
|
_lifetime_timer: state.metrics.time_collation_request_duration(),
|
||||||
};
|
};
|
||||||
|
|
||||||
state
|
state
|
||||||
|
|||||||
Reference in New Issue
Block a user