Skip to content

Commit

Permalink
Implement timeout for force_flush and shutdown.
Browse files Browse the repository at this point in the history
Note that the spec only has configuration for maximum time to export data. So the timeout is based on the export time.
  • Loading branch information
TommyCpp committed Nov 14, 2020
1 parent 310df35 commit 177f763
Show file tree
Hide file tree
Showing 3 changed files with 221 additions and 48 deletions.
7 changes: 4 additions & 3 deletions opentelemetry/Cargo.toml
Expand Up @@ -21,17 +21,17 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
async-std = { version = "1.6", features = ["unstable"], default-features = false, optional = true }
async-std = { version = "1.6", features = ["unstable"], default-features = false, optional = true }
async-trait = { version = "0.1", optional = true }
bincode = { version = "1.2", optional = true }
dashmap = { version = "4.0.0-rc6", optional = true }
fnv = { version = "1.0", optional = true }
futures = "0.3"
futures = { version = "0.3", features = ["std"] }
lazy_static = "1.4"
percent-encoding = { version = "2.0", optional = true }
pin-project = { version = "0.4", optional = true }
rand = { version = "0.7", default-features = false, features = ["std"], optional = true }
regex = { version = "1.3", default-features = false, features = ["std", "perf"], optional = true}
regex = { version = "1.3", default-features = false, features = ["std", "perf"], optional = true }
serde = { version = "1.0", features = ["derive", "rc"], optional = true }
http = { version = "0.2", optional = true }
thiserror = { version = "1.0", optional = true }
Expand All @@ -44,6 +44,7 @@ surf = { version = "2.0", default-features = false, optional = true }
criterion = "0.3.1"
rand_distr = "0.3.0"
tokio = { version = "0.2", features = ["full"] }
async-std = { version = "1.6", features = ["unstable"] }

[features]
default = ["trace"]
Expand Down
8 changes: 7 additions & 1 deletion opentelemetry/src/sdk/trace/provider.rs
Expand Up @@ -116,7 +116,12 @@ impl Builder {
// drop. We cannot assume we are in a multi-threaded tokio runtime here, so use
// `spawn_blocking` to avoid blocking the main thread.
let spawn = |fut| tokio::task::spawn_blocking(|| futures::executor::block_on(fut));
let batch = sdk::trace::BatchSpanProcessor::builder(exporter, spawn, tokio::time::interval);
let batch = sdk::trace::BatchSpanProcessor::builder(
exporter,
spawn,
tokio::time::delay_for,
tokio::time::interval,
);
self.with_batch_exporter(batch.build())
}

Expand All @@ -127,6 +132,7 @@ impl Builder {
let batch = sdk::trace::BatchSpanProcessor::builder(
exporter,
async_std::task::spawn,
async_std::task::sleep,
async_std::stream::interval,
);
self.with_batch_exporter(batch.build())
Expand Down

0 comments on commit 177f763

Please sign in to comment.