Skip to content

Commit

Permalink
refactor: bump the tonic and opentelemetry to the latest version
Browse files Browse the repository at this point in the history
Signed-off-by: Phoeniix Zhao <[email protected]>
  • Loading branch information
Phoenix500526 committed Apr 22, 2024
1 parent 4c587b6 commit c1f8775
Show file tree
Hide file tree
Showing 11 changed files with 431 additions and 483 deletions.
838 changes: 388 additions & 450 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion crates/benchmark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ repository = "https://github.com/xline-kv/Xline/tree/master/benchmark"
anyhow = "1.0.82"
clap = { version = "4", features = ["derive"] }
clippy-utilities = "0.2.0"
etcd-client = { version = "0.12.1", features = ["tls"] }
# TODO: switch to the original etcd-client crate when new version is released
etcd-client = { git = "https://github.com/Phoenix500526/etcd-client", branch = "update-tonic", features = ["tls"] }
indicatif = "0.17.8"
rand = "0.8.5"
thiserror = "1.0.58"
Expand Down
12 changes: 9 additions & 3 deletions crates/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ clippy-utilities = "0.2.0"
dashmap = "5.5.3"
derive_builder = "0.20.0"
getset = "0.1"
opentelemetry = { version = "0.21.0", features = ["trace"] }
opentelemetry = { version = "0.22.0", features = ["trace"] }
opentelemetry_sdk = { version = "0.22.1", features = ["trace"] }
parking_lot = { version = "0.12.1", optional = true }
pbkdf2 = { version = "0.12.2", features = ["simple"] }
Expand All @@ -40,10 +40,16 @@ toml = "0.8.8"
tonic = { version = "0.4.1", package = "madsim-tonic" }
tracing = "0.1.37"
tracing-appender = "0.2"
tracing-opentelemetry = "0.22.0"
tracing-opentelemetry = "0.23.0"
workspace-hack = { version = "0.1", path = "../../workspace-hack" }

[dev-dependencies]
opentelemetry-jaeger = "0.20.0"
opentelemetry = { version = "0.22.0", features = ["trace"] }
opentelemetry-jaeger = "0.21.0"
opentelemetry-otlp = { version = "0.15.0", features = [
"metrics",
"http-proto",
"reqwest-client",
] }
test-macros = { path = "../test-macros" }
tracing-subscriber = "0.3.16"
6 changes: 4 additions & 2 deletions crates/utils/src/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ mod test {

/// init tracing subscriber
fn init() -> Result<(), Box<dyn std::error::Error>> {
let jaeger_online_layer = opentelemetry_jaeger::new_agent_pipeline()
.with_service_name("test")
let otlp_exporter = opentelemetry_otlp::new_exporter().tonic();
let jaeger_online_layer = opentelemetry_otlp::new_pipeline()
.tracing()
.with_exporter(otlp_exporter)
.install_simple()
.map(|tracer| tracing_opentelemetry::layer().with_tracer(tracer))?;
tracing_subscriber::registry()
Expand Down
2 changes: 1 addition & 1 deletion crates/xline-test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ tokio = { version = "0.2.23", package = "madsim-tokio", features = [
"net",
"signal",
] }
tonic = "0.10.2"
tonic = "0.11.0"
utils = { path = "../utils", features = ["parking_lot"] }
workspace-hack = { version = "0.1", path = "../../workspace-hack" }
xline = { path = "../xline" }
Expand Down
18 changes: 9 additions & 9 deletions crates/xline/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,17 @@ jsonwebtoken = "9.3.0"
log = "0.4.21"
merged_range = "0.1.0"
nix = "0.28.0"
opentelemetry = { version = "0.21.0", features = ["metrics"] }
opentelemetry-contrib = { version = "0.13.0", features = [
opentelemetry = { version = "0.22.0", features = ["metrics"] }
opentelemetry-contrib = { version = "0.14.0", features = [
"jaeger_json_exporter",
"rt-tokio",
] }
opentelemetry-jaeger = { version = "0.20.0", features = ["rt-tokio"] }
opentelemetry-otlp = { version = "0.14.0", features = [
opentelemetry-otlp = { version = "0.15.0", features = [
"metrics",
"http-proto",
"reqwest-client",
] }
opentelemetry-prometheus = { version = "0.14.1" }
opentelemetry-prometheus = { version = "0.15.0" }
opentelemetry_sdk = { version = "0.22.1", features = ["metrics", "rt-tokio"] }
parking_lot = "0.12.0"
pbkdf2 = { version = "0.12.2", features = ["simple"] }
Expand All @@ -62,11 +61,11 @@ tokio = { version = "0.2.23", package = "madsim-tokio", features = [
tokio-stream = { git = "https://github.com/madsim-rs/tokio.git", rev = "ab251ad" }
tokio-util = { version = "0.7.8", features = ["io"] }
toml = "0.8.8"
tonic = { version = "0.4.1", package = "madsim-tonic" }
tonic-health = "0.10.2"
tonic = "0.11.0"
tonic-health = "0.11.0"
tracing = "0.1.37"
tracing-appender = "0.2"
tracing-opentelemetry = "0.22.0"
tracing-opentelemetry = "0.23.0"
tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
utils = { path = "../utils", features = ["parking_lot"] }
uuid = { version = "1.1.2", features = ["v4"] }
Expand All @@ -78,7 +77,8 @@ xlineapi = { path = "../xlineapi" }
tonic-build = { version = "0.4.2", package = "madsim-tonic-build" }

[dev-dependencies]
etcd-client = { version = "0.12.1", features = ["tls"] }
# TODO: switch to the original etcd-client crate when new version is released
etcd-client = { git = "https://github.com/Phoenix500526/etcd-client", branch = "update-tonic", features = ["tls"] }
mockall = "0.12.1"
rand = "0.8.5"
strum = "0.26"
Expand Down
7 changes: 5 additions & 2 deletions crates/xline/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
)]

use anyhow::Result;
use opentelemetry::global;
use opentelemetry::{global, metrics::noop::NoopMeterProvider};
use opentelemetry_sdk::propagation::TraceContextPropagator;
use tracing::{debug, info};
use xline::{
Expand Down Expand Up @@ -185,6 +185,9 @@ async fn main() -> Result<()> {
}

global::shutdown_tracer_provider();
global::shutdown_meter_provider();
// TODO: Since the `shutdown_meter_provider` has removed in the latest version of opentelemetry, we use `NoopMeterProvider` to replace it.
// FYI: https://github.com/open-telemetry/opentelemetry-rust/pull/1623
// We will replace `set_meter_provider` with `shutdown_meter_provider` when the new version release
global::set_meter_provider(NoopMeterProvider::new());
Ok(())
}
4 changes: 2 additions & 2 deletions crates/xline/src/utils/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use opentelemetry::global;
use opentelemetry_otlp::WithExportConfig;
use opentelemetry_sdk::{metrics::MeterProvider, runtime::Tokio};
use opentelemetry_sdk::{metrics::SdkMeterProvider, runtime::Tokio};
use tracing::info;
use utils::config::{MetricsConfig, MetricsPushProtocol};

Expand Down Expand Up @@ -44,7 +44,7 @@ pub fn init_metrics(config: &MetricsConfig) -> anyhow::Result<()> {
let exporter = opentelemetry_prometheus::exporter()
.with_registry(prometheus::default_registry().clone())
.build()?;
let provider = MeterProvider::builder().with_reader(exporter).build();
let provider = SdkMeterProvider::builder().with_reader(exporter).build();
global::set_meter_provider(provider);

let addr = format!("0.0.0.0:{}", config.port())
Expand Down
6 changes: 4 additions & 2 deletions crates/xline/src/utils/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ pub fn init_subscriber(
let jaeger_online_layer = trace_config
.jaeger_online()
.then(|| {
opentelemetry_jaeger::new_agent_pipeline()
.with_service_name(name)
let otlp_exporter = opentelemetry_otlp::new_exporter().tonic();
opentelemetry_otlp::new_pipeline()
.tracing()
.with_exporter(otlp_exporter)
.install_batch(Tokio)
.ok()
})
Expand Down
2 changes: 1 addition & 1 deletion crates/xlinectl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ serde = { version = "1.0.137", features = ["derive"] }
serde_json = "1.0.107"
shlex = "1.3.0"
tokio = "1"
tonic = "0.10.2"
tonic = "0.11.0"
utils = { path = "../utils" }
workspace-hack = { version = "0.1", path = "../../workspace-hack" }
xline-client = { path = "../xline-client" }
Expand Down
16 changes: 6 additions & 10 deletions workspace-hack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,41 @@ publish = false
### BEGIN HAKARI SECTION
[dependencies]
axum = { version = "0.6" }
bitflags = { version = "2", default-features = false, features = ["std"] }
bytes = { version = "1" }
clap = { version = "4", features = ["derive"] }
crypto-common = { version = "0.1", default-features = false, features = ["std"] }
digest = { version = "0.10", features = ["mac", "std"] }
either = { version = "1" }
either = { version = "1", default-features = false, features = ["use_std"] }
futures-channel = { version = "0.3", features = ["sink"] }
futures-util = { version = "0.3", features = ["channel", "io", "sink"] }
getrandom = { version = "0.2", default-features = false, features = ["js", "rdrand", "std"] }
itertools = { version = "0.11" }
libc = { version = "0.2", features = ["extra_traits"] }
log = { version = "0.4", default-features = false, features = ["std"] }
madsim-tokio = { version = "0.2", default-features = false, features = ["fs", "io-util", "macros", "net", "rt", "rt-multi-thread", "signal", "sync", "time"] }
madsim-tonic = { version = "0.4", default-features = false, features = ["tls"] }
memchr = { version = "2" }
num-traits = { version = "0.2", default-features = false, features = ["i128", "std"] }
opentelemetry-jaeger = { version = "0.20", features = ["rt-tokio"] }
opentelemetry_sdk = { version = "0.21", features = ["metrics", "rt-tokio"] }
opentelemetry_sdk = { version = "0.22", features = ["metrics", "rt-tokio"] }
petgraph = { version = "0.6" }
predicates = { version = "3", default-features = false, features = ["diff"] }
rand = { version = "0.8", features = ["small_rng"] }
serde = { version = "1", features = ["derive", "rc"] }
serde_json = { version = "1", features = ["raw_value"] }
sha2 = { version = "0.10" }
time = { version = "0.3", features = ["formatting", "macros", "parsing"] }
tokio = { version = "1", features = ["fs", "io-std", "io-util", "macros", "net", "rt-multi-thread", "signal", "sync", "time"] }
tokio-util = { version = "0.7", features = ["codec", "io"] }
tonic = { version = "0.10", features = ["tls"] }
tonic = { version = "0.11", features = ["tls"] }
tower = { version = "0.4", features = ["balance", "buffer", "filter", "limit", "timeout", "util"] }
tracing = { version = "0.1", features = ["log"] }
tracing-log = { version = "0.2", default-features = false, features = ["log-tracer", "std"] }
tracing-subscriber = { version = "0.3", features = ["env-filter", "time"] }
zeroize = { version = "1", features = ["derive"] }

[build-dependencies]
bitflags = { version = "2", default-features = false, features = ["std"] }
bytes = { version = "1" }
cc = { version = "1", default-features = false, features = ["parallel"] }
either = { version = "1" }
itertools = { version = "0.11" }
either = { version = "1", default-features = false, features = ["use_std"] }
itertools = { version = "0.12", default-features = false, features = ["use_alloc"] }
libc = { version = "0.2", features = ["extra_traits"] }
log = { version = "0.4", default-features = false, features = ["std"] }
memchr = { version = "2" }
Expand Down

0 comments on commit c1f8775

Please sign in to comment.