Skip to content

Commit

Permalink
feat: add compression support to metrics and RPC servers (#4906)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 authored Oct 17, 2024
1 parent 01589d2 commit efca75f
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 43 deletions.
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"] }
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

0 comments on commit efca75f

Please sign in to comment.