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

Update metrics to version 0.17 #2937

Closed
wants to merge 7 commits into from
Closed
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: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ panic = "abort"

# awaiting stable versions which all depend on tokio 1.0, see #1086 for details
hyper = { git = "https://github.com/hyperium/hyper", rev = "ed2b22a7f66899d338691552fbcb6c0f2f4e06b9" }
metrics = { git = "https://github.com/ZcashFoundation/metrics", rev = "971133128e5aebe3ad177acffc6154449736cfa2" }
metrics-exporter-prometheus = { git = "https://github.com/ZcashFoundation/metrics", rev = "971133128e5aebe3ad177acffc6154449736cfa2" }
tower = { git = "https://github.com/tower-rs/tower", rev = "d4d1c67c6a0e4213a52abcc2b9df6cc58276ee39" }

# TODO: remove these after a new librustzcash release.
Expand Down
2 changes: 1 addition & 1 deletion zebra-consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ serde = { version = "1", features = ["serde_derive"] }

futures = "0.3.17"
futures-util = "0.3.17"
metrics = "0.13.0-alpha.8"
metrics = "0.17.0"
thiserror = "1.0.30"
tokio = { version = "0.3.6", features = ["time", "sync", "stream", "tracing"] }
tower = { version = "0.4", features = ["timeout", "util", "buffer"] }
Expand Down
2 changes: 1 addition & 1 deletion zebra-network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ tokio = { version = "0.3.6", features = ["net", "time", "stream", "tracing", "ma
tokio-util = { version = "0.5", features = ["codec"] }
tower = { version = "0.4", features = ["retry", "discover", "load", "load-shed", "timeout", "util", "buffer"] }

metrics = "0.13.0-alpha.8"
metrics = "0.17.0"
tracing = "0.1"
tracing-futures = "0.2"
tracing-error = { version = "0.1.2", features = ["traced-error"] }
Expand Down
2 changes: 1 addition & 1 deletion zebra-state/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ serde = { version = "1", features = ["serde_derive"] }
bincode = "1"

futures = "0.3.17"
metrics = "0.13.0-alpha.8"
metrics = "0.17.0"
tower = { version = "0.4", features = ["buffer", "util"] }
tracing = "0.1"
thiserror = "1.0.30"
Expand Down
4 changes: 2 additions & 2 deletions zebrad/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ tracing-flame = "0.1.0"
tracing-journald = "0.1.0"
tracing-subscriber = { version = "0.2.25", features = ["tracing-log"] }
tracing-error = "0.1.2"
metrics = "0.13.0-alpha.8"
metrics-exporter-prometheus = "0.1.0-alpha.7"
metrics = "0.17.0"
metrics-exporter-prometheus = "0.6.1"

dirs = "4.0.0"
inferno = { version = "0.10.7", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion zebrad/src/components/mempool/storage/verified_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,6 @@ impl VerifiedSet {
"zcash.mempool.size.bytes",
self.transactions_serialized_size as _
);
metrics::gauge!("zcash.mempool.cost.bytes", u64::from(self.total_cost) as _);
metrics::gauge!("zcash.mempool.cost.bytes", self.total_cost as _);
}
}
22 changes: 4 additions & 18 deletions zebrad/src/components/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,10 @@ impl MetricsEndpoint {
// Expose binary metadata to metrics, using a single time series with
// value 1:
// https://www.robustperception.io/exposing-the-software-version-to-prometheus
//
// We manually expand the metrics::increment!() macro because it only
// supports string literals for metrics names, preventing us from
// using concat!() to build the name.
static METRIC_NAME: [metrics::SharedString; 2] = [
metrics::SharedString::const_str(env!("CARGO_PKG_NAME")),
metrics::SharedString::const_str("build.info"),
];
static METRIC_LABELS: [metrics::Label; 1] =
[metrics::Label::from_static_parts(
"version",
env!("CARGO_PKG_VERSION"),
)];
static METRIC_KEY: metrics::KeyData =
metrics::KeyData::from_static_parts(&METRIC_NAME, &METRIC_LABELS);
if let Some(recorder) = metrics::try_recorder() {
recorder.increment_counter(metrics::Key::Borrowed(&METRIC_KEY), 1);
}
metrics::increment_counter!(
format!("{}.build.info", env!("CARGO_PKG_NAME")),
"version" => env!("CARGO_PKG_VERSION")
);
}
Err(e) => panic!(
"Opening metrics endpoint listener {:?} failed: {:?}. \
Expand Down
4 changes: 2 additions & 2 deletions zebrad/src/components/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ where
let new_download_len = download_set.len();
let new_hashes = new_download_len - prev_download_len;
tracing::debug!(new_hashes, "added hashes to download set");
metrics::histogram!("sync.obtain.response.hash.count", new_hashes as u64);
metrics::histogram!("sync.obtain.response.hash.count", new_hashes as f64);
}
Ok(_) => unreachable!("network returned wrong response"),
// We ignore this error because we made multiple fanout requests.
Expand Down Expand Up @@ -621,7 +621,7 @@ where
let new_download_len = download_set.len();
let new_hashes = new_download_len - prev_download_len;
tracing::debug!(new_hashes, "added hashes to download set");
metrics::histogram!("sync.extend.response.hash.count", new_hashes as u64);
metrics::histogram!("sync.extend.response.hash.count", new_hashes as f64);
}
Ok(_) => unreachable!("network returned wrong response"),
// We ignore this error because we made multiple fanout requests.
Expand Down
2 changes: 1 addition & 1 deletion zebrad/tests/acceptance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ async fn metrics_endpoint() -> Result<()> {
let output = output.assert_failure()?;

output.any_output_line_contains(
"metrics snapshot",
"# TYPE zebrad_build_info counter",
&body,
"metrics exporter response",
"the metrics response header",
Expand Down