是否可以增加OpenTelemetry span批处理器的通道大小?
我目前在高流量情况下收到OpenTelemetry trace error occurred. cannot send span to the batch span processor because the channel is full
错误。
下面是我的配置代码:
let mut exporter_metadata = MetadataMap::new();
exporter_metadata.insert(
"api-key",
"<redacted>".parse()?,
);
let exporter = opentelemetry_otlp::new_exporter()
.tonic()
.with_endpoint("https://otlp.nr-data.net:4317")
.with_tls_config(ClientTlsConfig::default())
.with_metadata(exporter_metadata);
let trace_config = opentelemetry::sdk::trace::config()
.with_resource(Resource::new(vec![
KeyValue::new(
opentelemetry_semantic_conventions::resource::SERVICE_NAME,
"worker",
),
KeyValue::new(
opentelemetry_semantic_conventions::resource::SERVICE_INSTANCE_ID,
"dev-instance",
),
KeyValue::new("kind", "server"),
]))
.with_sampler(Sampler::TraceIdRatioBased(1.0));
let tracer = opentelemetry_otlp::new_pipeline()
.tracing()
.with_exporter(exporter)
.with_trace_config(trace_config)
.install_batch(opentelemetry::runtime::Tokio)?;
let otel_filter = Targets::new().with_target("worker", LevelFilter::INFO);
let otel_layer = tracing_opentelemetry::layer()
.with_tracer(tracer)
.with_filter(otel_filter);
我已经看过了文档,但是没有提到通道大小的配置。
1条答案
按热度按时间ryevplcw1#
在深入研究了源代码之后,我提出了以下解决方案:
在
batch_config.rs
中,声明新特征并为OtlpTracePipeline
实现它:然后像这样使用它:
粗略地说,
install_batch_manual
相当于调用.with_exporter().with_trace_config().install_batch
,但带有可自定义的BatchConfig选项。