From 7960689ef76c370cbeb62c1690eba79f5f4b849b Mon Sep 17 00:00:00 2001 From: Tim Zhang Date: Wed, 14 Jul 2021 10:59:16 +0800 Subject: [PATCH] tracing: replace SimpleSpanProcessor with BatchSpanProcessor This change make tokio could be use in vsock-exporter. Signed-off-by: Tim Zhang --- src/agent/Cargo.lock | 13 +++++++++++++ src/agent/Cargo.toml | 2 +- src/agent/src/tracer.rs | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/agent/Cargo.lock b/src/agent/Cargo.lock index 4fd8c0917b..16ddaca605 100644 --- a/src/agent/Cargo.lock +++ b/src/agent/Cargo.lock @@ -872,6 +872,8 @@ dependencies = [ "rand", "serde", "thiserror", + "tokio", + "tokio-stream", ] [[package]] @@ -1577,6 +1579,17 @@ dependencies = [ "syn 1.0.72", ] +[[package]] +name = "tokio-stream" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8864d706fdb3cc0843a49647ac892720dac98a6eeb818b77190592cf4994066" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + [[package]] name = "tokio-util" version = "0.6.7" diff --git a/src/agent/Cargo.toml b/src/agent/Cargo.toml index 6e987fa855..e6a1981db3 100644 --- a/src/agent/Cargo.toml +++ b/src/agent/Cargo.toml @@ -54,7 +54,7 @@ cgroups = { package = "cgroups-rs", version = "0.2.5" } tracing = "0.1.26" tracing-subscriber = "0.2.18" tracing-opentelemetry = "0.13.0" -opentelemetry = "0.14.0" +opentelemetry = { version = "0.14.0", features = ["rt-tokio-current-thread"]} vsock-exporter = { path = "vsock-exporter" } [dev-dependencies] diff --git a/src/agent/src/tracer.rs b/src/agent/src/tracer.rs index 2e53fbea9c..5edbf300d3 100644 --- a/src/agent/src/tracer.rs +++ b/src/agent/src/tracer.rs @@ -66,7 +66,7 @@ pub fn setup_tracing(name: &'static str, logger: &Logger, _agent_cfg: &AgentConf let config = Config::default(); let builder = opentelemetry::sdk::trace::TracerProvider::builder() - .with_simple_exporter(exporter) + .with_batch_exporter(exporter, opentelemetry::runtime::TokioCurrentThread) .with_config(config); let provider = builder.build();