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 2, 2024
1 parent 2c8ea68 commit 106c871
Show file tree
Hide file tree
Showing 10 changed files with 191 additions and 135 deletions.
266 changes: 154 additions & 112 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.81"
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.13.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 = "8.1.1"
log = "0.4.21"
merged_range = "0.1.0"
nix = "0.27.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.25"
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 @@ -144,7 +144,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 @@ -186,6 +186,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

0 comments on commit 106c871

Please sign in to comment.