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
2 changes: 2 additions & 0 deletions crates/blockchain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ impl BlockChainServer {
}

fn produce_attestations(&mut self, slot: u64) {
let _timing = metrics::time_attestations_production();

// Produce attestation data once for all validators
let attestation_data = store::produce_attestation_data(&self.store, slot);

Expand Down
16 changes: 16 additions & 0 deletions crates/blockchain/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@ static LEAN_PQ_SIG_ATTESTATION_SIGNING_TIME_SECONDS: std::sync::LazyLock<Histogr
.unwrap()
});

static LEAN_ATTESTATIONS_PRODUCTION_TIME_SECONDS: std::sync::LazyLock<Histogram> =
std::sync::LazyLock::new(|| {
register_histogram!(
"lean_attestations_production_time_seconds",
"Time taken to produce attestation",
Comment thread
MegaRedHand marked this conversation as resolved.
vec![0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 0.75, 1.0]
)
.unwrap()
});

static LEAN_PQ_SIG_ATTESTATION_VERIFICATION_TIME_SECONDS: std::sync::LazyLock<Histogram> =
std::sync::LazyLock::new(|| {
register_histogram!(
Expand Down Expand Up @@ -381,6 +391,7 @@ pub fn init() {
std::sync::LazyLock::force(&LEAN_FORK_CHOICE_BLOCK_PROCESSING_TIME_SECONDS);
std::sync::LazyLock::force(&LEAN_ATTESTATION_VALIDATION_TIME_SECONDS);
std::sync::LazyLock::force(&LEAN_PQ_SIG_ATTESTATION_SIGNING_TIME_SECONDS);
std::sync::LazyLock::force(&LEAN_ATTESTATIONS_PRODUCTION_TIME_SECONDS);
std::sync::LazyLock::force(&LEAN_PQ_SIG_ATTESTATION_VERIFICATION_TIME_SECONDS);
std::sync::LazyLock::force(&LEAN_PQ_SIG_AGGREGATED_SIGNATURES_BUILDING_TIME_SECONDS);
std::sync::LazyLock::force(&LEAN_PQ_SIG_AGGREGATED_SIGNATURES_VERIFICATION_TIME_SECONDS);
Expand Down Expand Up @@ -499,6 +510,11 @@ pub fn time_pq_sig_attestation_signing() -> TimingGuard {
TimingGuard::new(&LEAN_PQ_SIG_ATTESTATION_SIGNING_TIME_SECONDS)
}

/// Start timing attestation production. Records duration when the guard is dropped.
pub fn time_attestations_production() -> TimingGuard {
TimingGuard::new(&LEAN_ATTESTATIONS_PRODUCTION_TIME_SECONDS)
}

/// Start timing individual attestation signature verification. Records duration when the guard is dropped.
pub fn time_pq_sig_attestation_verification() -> TimingGuard {
TimingGuard::new(&LEAN_PQ_SIG_ATTESTATION_VERIFICATION_TIME_SECONDS)
Expand Down
9 changes: 5 additions & 4 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ The exposed metrics follow [the leanMetrics specification](https://github.com/le

## Validator Metrics

| Name | Type | Usage | Sample collection event | Labels | Supported |
|--------|-------|-------|-------------------------|--------|-----------|
|`lean_validators_count`| Gauge | Number of validators managed by a node | On scrape | | ✅(*) |
|`lean_is_aggregator`| Gauge | Validator's `is_aggregator` status. True=1, False=0 | On node start | | ✅ |
| Name | Type | Usage | Sample collection event | Labels | Buckets | Supported |
|--------|-------|-------|-------------------------|--------|---------|-----------|
|`lean_validators_count`| Gauge | Number of validators managed by a node | On scrape | | | ✅(*) |
|`lean_is_aggregator`| Gauge | Validator's `is_aggregator` status. True=1, False=0 | On node start | | | ✅ |
|`lean_attestations_production_time_seconds`| Histogram | Time taken to produce attestation | On attestation production | | 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 0.75, 1 | ✅ |

## Network Metrics

Expand Down
Loading