Skip to content

Commit fbabf73

Browse files
committed
increase batch processor limit
1 parent 5f00ec1 commit fbabf73

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/telemetry.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use opentelemetry::{trace::TracerProvider, KeyValue};
22
use opentelemetry_otlp::WithExportConfig;
33
use opentelemetry_sdk::{
44
propagation::TraceContextPropagator,
5-
trace::{RandomIdGenerator, Sampler},
5+
trace::{RandomIdGenerator, Sampler, BatchConfig},
66
Resource,
77
};
88
use std::env;
@@ -32,16 +32,27 @@ pub fn init_telemetry() -> anyhow::Result<()> {
3232
])
3333
.build();
3434

35-
// Create OTLP span exporter
35+
// Create OTLP span exporter with increased message size limits
3636
let span_exporter = opentelemetry_otlp::SpanExporter::builder()
3737
.with_tonic()
3838
.with_endpoint(otlp_endpoint)
3939
.with_timeout(Duration::from_secs(10))
40+
.with_channel(
41+
tonic::transport::Channel::builder(otlp_endpoint.parse()?)
42+
.max_decoding_message_size(32 * 1024 * 1024) // 32MB
43+
.max_encoding_message_size(32 * 1024 * 1024) // 32MB
44+
)
4045
.build()?;
4146

47+
// Configure batch processor to limit batch sizes
48+
let batch_config = BatchConfig::default()
49+
.with_max_export_batch_size(512) // Limit batch size to prevent large messages
50+
.with_scheduled_delay(Duration::from_secs(5))
51+
.with_max_queue_size(2048);
52+
4253
// Build the tracer provider
4354
let tracer_provider = opentelemetry_sdk::trace::SdkTracerProvider::builder()
44-
.with_batch_exporter(span_exporter)
55+
.with_batch_exporter(span_exporter, batch_config)
4556
.with_sampler(Sampler::AlwaysOn)
4657
.with_id_generator(RandomIdGenerator::default())
4758
.with_resource(resource)

0 commit comments

Comments
 (0)