Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

penumbra: use metrics@0.22 #3745

Merged
merged 3 commits into from
Feb 6, 2024
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
52 changes: 34 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/bin/pclientd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bytes = { version = "1", features = ["serde"] }
prost = "0.12.3"
futures = "0.3"
hex = "0.4"
metrics = "0.19.0"
metrics = "0.22"
async-stream = "0.2"
parking_lot = "0.12"
clap = { version = "3", features = ["derive", "env"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/bin/pd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ hex = "0.4"
rand = "0.8"
rand_chacha = "0.3.1"
rand_core = { version = "0.6.3", features = ["getrandom"] }
metrics = "0.19.0"
metrics = "0.22"
metrics-exporter-prometheus = { version = "0.10.0", features = [
"http-listener",
] }
Expand Down
12 changes: 2 additions & 10 deletions crates/bin/pd/src/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ impl Mempool {
Ok(events) => {
let elapsed = start.elapsed();
tracing::info!(?elapsed, "tx accepted");
metrics::increment_counter!(
metrics::MEMPOOL_CHECKTX_TOTAL,
"kind" => kind_str,
"code" => "0"
);
metrics::counter!(metrics::MEMPOOL_CHECKTX_TOTAL, "kind" => kind_str, "code" => "0").increment(1);
Ok(Response::CheckTx(CheckTxRsp {
events,
..Default::default()
Expand All @@ -73,11 +69,7 @@ impl Mempool {
Err(e) => {
let elapsed = start.elapsed();
tracing::info!(?e, ?elapsed, "tx rejected");
metrics::increment_counter!(
metrics::MEMPOOL_CHECKTX_TOTAL,
"kind" => kind_str,
"code" => "1"
);
metrics::counter!(metrics::MEMPOOL_CHECKTX_TOTAL, "kind" => kind_str, "code" => "1").increment(1);
Ok(Response::CheckTx(CheckTxRsp {
code: 1.into(),
// Use the alternate format specifier to include the chain of error causes.
Expand Down
1 change: 0 additions & 1 deletion crates/bin/pd/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ pub fn register_metrics() {
// This will register metrics for all components.
penumbra_app::register_metrics();

register_counter!(MEMPOOL_CHECKTX_TOTAL);
describe_counter!(
MEMPOOL_CHECKTX_TOTAL,
Unit::Count,
Expand Down
2 changes: 1 addition & 1 deletion crates/cnidarium/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ tracing = "0.1"
rocksdb = "0.21.0"
futures = "0.3"
hex = "0.4"
metrics = { version = "0.19.0", optional = true }
metrics = { version = "0.22", optional = true }
parking_lot = "0.12"
pin-project = "1.0.12"
smallvec = { version = "1.10", features = ["union", "const_generics"] }
Expand Down
2 changes: 0 additions & 2 deletions crates/cnidarium/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ pub use metrics::*;

/// Registers all metrics used by this crate.
pub fn register_metrics() {
register_histogram!(STORAGE_GET_RAW_DURATION);
describe_histogram!(
STORAGE_GET_RAW_DURATION,
Unit::Seconds,
"The duration of a get_raw request"
);
register_histogram!(STORAGE_NONCONSENSUS_GET_RAW_DURATION);
describe_histogram!(
STORAGE_NONCONSENSUS_GET_RAW_DURATION,
Unit::Seconds,
Expand Down
9 changes: 4 additions & 5 deletions crates/cnidarium/src/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ impl StateRead for Snapshot {
let _start = std::time::Instant::now();
let rsp = substore.get_jmt(key_hash);
#[cfg(feature = "metrics")]
metrics::histogram!(metrics::STORAGE_GET_RAW_DURATION, _start.elapsed());
metrics::histogram!(metrics::STORAGE_GET_RAW_DURATION)
.record(_start.elapsed());
rsp
})
})
Expand Down Expand Up @@ -273,10 +274,8 @@ impl StateRead for Snapshot {
.get_cf(cf_nonverifiable, key)
.map_err(Into::into);
#[cfg(feature = "metrics")]
metrics::histogram!(
metrics::STORAGE_NONCONSENSUS_GET_RAW_DURATION,
_start.elapsed()
);
metrics::histogram!(metrics::STORAGE_NONCONSENSUS_GET_RAW_DURATION)
.record(_start.elapsed());
rsp
})
})
Expand Down
2 changes: 1 addition & 1 deletion crates/core/app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ blake2b_simd = "0.5"
bincode = "1.3.3"
serde = { version = "1", features = ["derive"] }
serde_with = "2.2"
metrics = "0.19.0"
metrics = "0.22"
sha2 = "0.9"
serde_json = "1"
serde_unit_struct = "0.1"
Expand Down
2 changes: 1 addition & 1 deletion crates/core/component/community-pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ anyhow = "1"
tracing = "0.1"
prost = "0.12.3"
serde = { version = "1", features = ["derive"] }
metrics = "0.19.0"
metrics = "0.22"
pbjson-types = "0.6.0"
tendermint = "0.34.0"
tendermint-light-client-verifier = "0.34.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/core/component/compact-block/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ penumbra-sct = { path = "../sct", default-features = false }
# Crates.io dependencies
ark-ff = { version = "0.4", default_features = false }
decaf377-rdsa = { version = "0.7" }
metrics = "0.19.0"
metrics = "0.22"
serde = { version = "1", features = ["derive"] }
tracing = "0.1"
anyhow = "1"
Expand Down
5 changes: 0 additions & 5 deletions crates/core/component/compact-block/src/component/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,19 @@ pub use metrics::*;
///
/// The source code contains the metrics descriptions.
pub fn register_metrics() {
register_gauge!(COMPACT_BLOCK_RANGE_ACTIVE_CONNECTIONS);
describe_gauge!(
COMPACT_BLOCK_RANGE_ACTIVE_CONNECTIONS,
Unit::Count,
"The number of active connections streaming compact blocks"
);

register_counter!(COMPACT_BLOCK_RANGE_SERVED_TOTAL);
describe_counter!(
COMPACT_BLOCK_RANGE_SERVED_TOTAL,
Unit::Count,
"The total number of compact blocks served to clients"
);
}

// Sample code for reference -- delete when adding the first metric
// pub const MEMPOOL_CHECKTX_TOTAL: &str = "penumbra_pd_mempool_checktx_total";

pub const COMPACT_BLOCK_RANGE_ACTIVE_CONNECTIONS: &str =
"cnidarium_component_compact_block_compact_block_range_active_connections";

Expand Down
10 changes: 5 additions & 5 deletions crates/core/component/compact-block/src/component/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl QueryService for Server {
// outside of the `send_op` future, and investigate if long blocking sends can
// happen for benign reasons (i.e not caused by the client).
tx_blocks.send(Ok(compact_block.into())).await?;
metrics::increment_counter!(metrics::COMPACT_BLOCK_RANGE_SERVED_TOTAL,);
metrics::counter!(metrics::COMPACT_BLOCK_RANGE_SERVED_TOTAL).increment(1);
}

// If the client didn't request a keep-alive, we're done.
Expand Down Expand Up @@ -175,7 +175,7 @@ impl QueryService for Server {
.send(Ok(block.into()))
.await
.map_err(|_| tonic::Status::cancelled("client closed connection"))?;
metrics::increment_counter!(metrics::COMPACT_BLOCK_RANGE_SERVED_TOTAL,);
metrics::counter!(metrics::COMPACT_BLOCK_RANGE_SERVED_TOTAL).increment(1);
}

// Ensure that we don't hold a reference to the snapshot indefinitely
Expand Down Expand Up @@ -204,7 +204,7 @@ impl QueryService for Server {
.send(Ok(block.into()))
.await
.map_err(|_| tonic::Status::cancelled("channel closed"))?;
metrics::increment_counter!(metrics::COMPACT_BLOCK_RANGE_SERVED_TOTAL,);
metrics::counter!(metrics::COMPACT_BLOCK_RANGE_SERVED_TOTAL).increment(1);
}
}
.map_err(|e| async move {
Expand Down Expand Up @@ -240,13 +240,13 @@ struct CompactBlockConnectionCounter {}

impl CompactBlockConnectionCounter {
pub fn new() -> Self {
metrics::increment_gauge!(metrics::COMPACT_BLOCK_RANGE_ACTIVE_CONNECTIONS, 1.0);
metrics::gauge!(metrics::COMPACT_BLOCK_RANGE_ACTIVE_CONNECTIONS).increment(1.0);
CompactBlockConnectionCounter {}
}
}

impl Drop for CompactBlockConnectionCounter {
fn drop(&mut self) {
metrics::decrement_gauge!(metrics::COMPACT_BLOCK_RANGE_ACTIVE_CONNECTIONS, 1.0);
metrics::gauge!(metrics::COMPACT_BLOCK_RANGE_ACTIVE_CONNECTIONS).decrement(1.0);
}
}
2 changes: 1 addition & 1 deletion crates/core/component/dex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ tracing = "0.1"
prost = "0.12.3"
serde = { version = "1", features = ["derive"] }
serde_json = "1.0.96"
metrics = "0.19.0"
metrics = "0.22"
pbjson-types = "0.6.0"
tendermint = "0.34.0"
tendermint-light-client-verifier = "0.34.0"
Expand Down
Loading
Loading