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

feat: add compression support to metrics and RPC servers #4906

Merged
merged 3 commits into from
Oct 17, 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
138 changes: 96 additions & 42 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ tokio = { version = "1", features = ['full'] }
tokio-stream = { version = "0.1", features = ["fs", "io-util"] }
tokio-util = { version = "0.7", features = ["compat", "io-util"] }
toml = "0.8"
tower = { version = "0.5", features = ["full"] }
tower = { version = "0.4", features = ["util"] }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

downgrade tower to align with jsonrpsee

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hanabi1224 Should we put a comment here so that people avoid updating (and a similar one in the jsonrpsee so that people update it when needed).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LesnyRumcajs Now It does not compile if tower and jsonrpsee versions don't match

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LesnyRumcajs Now It does not compile if tower and jsonrpsee versions don't match

tower-http = { version = "0.6", features = ["compression-full", "sensitive-headers"] }
tracing = "0.1"
tracing-appender = "0.2"
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
Expand Down
2 changes: 2 additions & 0 deletions src/metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use prometheus_client::{
use std::sync::Arc;
use std::{path::PathBuf, time::Instant};
use tokio::net::TcpListener;
use tower_http::compression::CompressionLayer;
use tracing::warn;

static DEFAULT_REGISTRY: Lazy<RwLock<prometheus_client::registry::Registry>> =
Expand Down Expand Up @@ -91,6 +92,7 @@ where
let app = Router::new()
.route("/metrics", get(collect_prometheus_metrics))
.route("/stats/db", get(collect_db_metrics::<DB>))
.layer(CompressionLayer::new())
.with_state(db);

// Wait for server to exit
Expand Down
Loading
Loading