Skip to content

Commit cac9893

Browse files
authored
Create BatchSpanProcessor from env in TracerProvider (#445)
This allows for configuring BSP when just `with_exporter` is used, instead of requiring users to create the BSP themselves when they want to pull from the environment.
1 parent 6e123c8 commit cac9893

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

opentelemetry/src/sdk/trace/provider.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ impl Builder {
116116
// drop. We cannot assume we are in a multi-threaded tokio runtime here, so use
117117
// `spawn_blocking` to avoid blocking the main thread.
118118
let spawn = |fut| tokio::task::spawn_blocking(|| futures::executor::block_on(fut));
119-
let batch = sdk::trace::BatchSpanProcessor::builder(
119+
let batch = sdk::trace::BatchSpanProcessor::from_env(
120120
exporter,
121121
spawn,
122-
tokio::time::sleep,
123122
crate::util::tokio_interval_stream,
123+
tokio::time::sleep,
124124
);
125125
self.with_batch_exporter(batch.build())
126126
}
@@ -129,11 +129,11 @@ impl Builder {
129129
#[cfg(all(feature = "async-std", not(feature = "tokio")))]
130130
#[cfg_attr(docsrs, doc(cfg(feature = "async-std")))]
131131
pub fn with_exporter<T: SpanExporter + 'static>(self, exporter: T) -> Self {
132-
let batch = sdk::trace::BatchSpanProcessor::builder(
132+
let batch = sdk::trace::BatchSpanProcessor::from_env(
133133
exporter,
134134
async_std::task::spawn,
135-
async_std::task::sleep,
136135
async_std::stream::interval,
136+
async_std::task::sleep,
137137
);
138138
self.with_batch_exporter(batch.build())
139139
}

0 commit comments

Comments
 (0)