Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions crates/blockchain/src/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,27 @@ fn cov_add(seen: &mut [bool], has_subnet: &mut [bool], bits: &AggregationBits) {
}

fn cov_record(section: &str, seen: &[bool], has_subnet: &[bool]) {
// TODO(#398): emit a per-subnet breakdown (subnet=subnet_N) alongside the
// subnet=combined total. `has_subnet` already tracks which subnets are
// covered, but we only report the aggregate count here; the per-subnet
// label is reserved in the metric definition and not yet populated.
metrics::set_attestation_aggregate_coverage_validators(
section,
"combined",
seen.iter().filter(|&&b| b).count() as i64,
);
let cc = has_subnet.len();
if cc > 0 {
let mut subnet_counts = vec![0i64; cc];
for (vid, &was_seen) in seen.iter().enumerate() {
if was_seen {
subnet_counts[vid % cc] += 1;
}
}
for (i, &count) in subnet_counts.iter().enumerate() {
metrics::set_attestation_aggregate_coverage_validators(
section,
&format!("subnet_{i}"),
count,
);
}
}
metrics::set_attestation_aggregate_coverage_subnets(
section,
has_subnet.iter().filter(|&&b| b).count() as i64,
Expand Down
5 changes: 2 additions & 3 deletions crates/blockchain/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,8 @@ static LEAN_ATTESTATION_AGGREGATE_COVERAGE_VALIDATORS: std::sync::LazyLock<IntGa
register_int_gauge_vec!(
"lean_attestation_aggregate_coverage_validators",
"Validator coverage in attestation aggregate reports, labeled by section and \
subnet. Only subnet=combined (the section total) is currently emitted; the \
subnet=subnet_N per-subnet breakdown is reserved and not yet populated. \
Updated each slot (slot is the X-axis).",
subnet. subnet=combined is the section total; subnet=subnet_N is the count of \
validators in subnet N that were seen. Updated each slot (slot is the X-axis).",
&["section", "subnet"]
)
.unwrap()
Expand Down
2 changes: 1 addition & 1 deletion docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Observability into how many validators/subnets are covered by the attestations t

| Name | Type | Usage | Sample collection event | Labels |
|------|------|-------|-------------------------|--------|
| `lean_attestation_aggregate_coverage_validators` | Gauge | Validator coverage in attestation aggregate reports | Per round, per section (see note above) | section=timely,late,block,combined,agg_start_new,proposal_combined<br>subnet=combined (per-subnet breakdown reserved, not yet populated) |
| `lean_attestation_aggregate_coverage_validators` | Gauge | Validator coverage in attestation aggregate reports | Per round, per section (see note above) | section=timely,late,block,combined,agg_start_new,proposal_combined<br>subnet=combined,subnet_0,subnet_1,…,subnet_N-1 |
| `lean_attestation_aggregate_coverage_subnets` | Gauge | Number of covered subnets in attestation aggregate reports | Per round, per section (see note above) | section=timely,late,block,combined,agg_start_new,proposal_combined |
| `lean_attestation_aggregate_coverage_diff_validators` | Gauge | Validators in the symmetric difference between block-included aggregates and locally-aggregated timely aggregates for the same slot | On block import, when the head carries the round's votes (see note above) | direction=block_only,timely_only |

Expand Down