Skip to content

Commit 8acc2c1

Browse files
committed
some metrics and logs polishes
1 parent 0ed57f8 commit 8acc2c1

File tree

4 files changed

+35
-6
lines changed

4 files changed

+35
-6
lines changed

polkadot/node/network/availability-recovery/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,6 @@ pub fn log_error(result: Result<()>) -> std::result::Result<(), FatalError> {
8686
impl JfyiError {
8787
/// Log a `JfyiError`.
8888
pub fn log(self) {
89-
gum::warn!(target: LOG_TARGET, error = ?self);
89+
gum::warn!(target: LOG_TARGET, "{}", self);
9090
}
9191
}

polkadot/node/network/availability-recovery/src/metrics.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ struct MetricsInner {
5555
/// - `success`
5656
chunk_requests_finished: CounterVec<U64>,
5757

58+
/// A counter for successful chunk requests, split by the network protocol version.
59+
chunk_request_protocols: CounterVec<U64>,
60+
5861
/// Number of sent available data requests.
5962
full_data_requests_issued: Counter<U64>,
6063

@@ -202,6 +205,20 @@ impl Metrics {
202205
}
203206
}
204207

208+
/// A chunk response was received on the v1 protocol.
209+
pub fn on_chunk_response_v1(&self) {
210+
if let Some(metrics) = &self.0 {
211+
metrics.chunk_request_protocols.with_label_values(&["v1"]).inc()
212+
}
213+
}
214+
215+
/// A chunk response was received on the v2 protocol.
216+
pub fn on_chunk_response_v2(&self) {
217+
if let Some(metrics) = &self.0 {
218+
metrics.chunk_request_protocols.with_label_values(&["v2"]).inc()
219+
}
220+
}
221+
205222
/// A full data request succeeded.
206223
pub fn on_full_request_succeeded(&self) {
207224
if let Some(metrics) = &self.0 {
@@ -314,6 +331,16 @@ impl metrics::Metrics for Metrics {
314331
)?,
315332
registry,
316333
)?,
334+
chunk_request_protocols: prometheus::register(
335+
CounterVec::new(
336+
Opts::new(
337+
"polkadot_parachain_availability_recovery_chunk_request_protocols",
338+
"Total number of successful chunk requests, mapped by the protocol version (v1 or v2).",
339+
),
340+
&["protocol"],
341+
)?,
342+
registry,
343+
)?,
317344
full_data_requests_finished: prometheus::register(
318345
CounterVec::new(
319346
Opts::new(

polkadot/node/network/availability-recovery/src/task/strategy/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,21 +384,23 @@ impl State {
384384
let res = match res.await {
385385
Ok((bytes, protocol)) =>
386386
if v2_protocol_name == protocol {
387+
params.metrics.on_chunk_response_v2();
387388
match req_res::v2::ChunkFetchingResponse::decode(&mut &bytes[..]) {
388389
Ok(req_res::v2::ChunkFetchingResponse::Chunk(chunk)) =>
389390
Ok(Some(chunk.into())),
390391
Ok(req_res::v2::ChunkFetchingResponse::NoSuchChunk) => Ok(None),
391392
Err(e) => Err(RequestError::InvalidResponse(e)),
392393
}
393394
} else if v1_protocol_name == protocol {
395+
params.metrics.on_chunk_response_v1();
394396
// V1 protocol version must not be used when chunk mapping node
395397
// feature is enabled, because we can't know the real index of the
396398
// returned chunk.
397399
// This case should never be reached as long as the
398400
// `AvailabilityChunkMapping` feature is only enabled after the
399401
// v1 version is removed. Still, log this.
400402
if chunk_mapping_enabled {
401-
gum::warn!(
403+
gum::info!(
402404
target: LOG_TARGET,
403405
?candidate_hash,
404406
authority_id = ?authority_id_clone,

polkadot/node/subsystem-bench/examples/availability_read.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
TestConfiguration:
22
# Test 1
33
- objective: !DataAvailabilityRead
4-
fetch_from_backers: true
5-
n_validators: 300
4+
strategy: FullFromBackers
5+
n_validators: 500
66
n_cores: 20
77
min_pov_size: 5120
88
max_pov_size: 5120
@@ -16,7 +16,7 @@ TestConfiguration:
1616

1717
# Test 2
1818
- objective: !DataAvailabilityRead
19-
fetch_from_backers: true
19+
strategy: FullFromBackers
2020
n_validators: 500
2121
n_cores: 20
2222
min_pov_size: 5120
@@ -31,7 +31,7 @@ TestConfiguration:
3131

3232
# Test 3
3333
- objective: !DataAvailabilityRead
34-
fetch_from_backers: true
34+
strategy: FullFromBackers
3535
n_validators: 1000
3636
n_cores: 20
3737
min_pov_size: 5120

0 commit comments

Comments
 (0)