Skip to content

Commit

Permalink
feat: add with_batch_processor_config for AgentPipeline
Browse files Browse the repository at this point in the history
Signed-off-by: zengxilong <zengxilonglh@gmail.com>
  • Loading branch information
zengxilong committed Aug 30, 2022
1 parent 32e13e9 commit 3fe4652
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
24 changes: 23 additions & 1 deletion opentelemetry-jaeger/src/exporter/config/agent.rs
Expand Up @@ -232,6 +232,24 @@ impl AgentPipeline {
self
}

/// Assign the batch span processor for the exporter pipeline.
///
/// # Examples
/// Set max queue size.
/// ```rust
/// use opentelemetry::sdk::trace::BatchConfig;
///
/// let pipeline = opentelemetry_jaeger::new_agent_pipeline()
/// .with_batch_processor_config(
/// BatchConfig::default().with_max_queue_size(200)
/// );
///
/// ```
pub fn with_batch_processor_config(mut self, config: BatchConfig) -> Self {
self.set_batch_config(config);
self
}

/// Build a `TracerProvider` using a blocking exporter and configurations from the pipeline.
///
/// The exporter will send each span to the agent upon the span ends.
Expand Down Expand Up @@ -279,10 +297,14 @@ impl AgentPipeline {
self.trace_config.take(),
self.transformation_config.service_name.take(),
);
let batch_config = self.batch_config.take();
let uploader = self.build_async_agent_uploader(runtime.clone())?;
let exporter = Exporter::new(process.into(), export_instrument_library, uploader);
let batch_processor = sdk::trace::BatchSpanProcessor::builder(exporter, runtime)
.with_batch_config(batch_config.unwrap_or_default())
.build();

builder = builder.with_batch_exporter(exporter, runtime);
builder = builder.with_span_processor(batch_processor);
builder = builder.with_config(config);

Ok(builder.build())
Expand Down
15 changes: 0 additions & 15 deletions opentelemetry-sdk/src/trace/span_processor.rs
Expand Up @@ -873,19 +873,4 @@ mod tests {
let shutdown_res = processor.shutdown();
assert!(shutdown_res.is_ok());
}

#[test]
fn test_batch_config_set_field() {
let batch = BatchConfig::default()
.with_max_export_batch_size(10)
.with_scheduled_delay(Duration::from_millis(10))
.with_max_export_timeout(Duration::from_millis(10))
.with_max_concurrent_exports(10)
.with_max_queue_size(10);
assert_eq!(batch.max_export_batch_size, 10);
assert_eq!(batch.scheduled_delay, Duration::from_millis(10));
assert_eq!(batch.max_export_timeout, Duration::from_millis(10));
assert_eq!(batch.max_concurrent_exports, 10);
assert_eq!(batch.max_queue_size, 10);
}
}

0 comments on commit 3fe4652

Please sign in to comment.