Skip to content

Commit

Permalink
core: increate batch configuration
Browse files Browse the repository at this point in the history
This should solve the error that we start to see on some application
and possibly should solve some crash that we noted somewhere

```
OpenTelemetry log error occurred. cannot send message to batch processor as the channel is full
```

Link: open-telemetry/opentelemetry-rust#2177
Signed-off-by: Vincenzo Palazzo <[email protected]>
  • Loading branch information
vincenzopalazzo committed Oct 30, 2024
1 parent 86c8059 commit 7d702a3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
//! - `http_exporter`: Creates a new HTTP exporter builder for OpenTelemetry.
use std::str::FromStr;
use std::sync::Arc;
use std::time::Duration;

use opentelemetry::KeyValue;
use opentelemetry_appender_log::OpenTelemetryLogBridge;
use opentelemetry_otlp::HttpExporterBuilder;
use opentelemetry_otlp::Protocol;
use opentelemetry_otlp::WithExportConfig;
use opentelemetry_sdk::logs::BatchConfigBuilder;
use opentelemetry_sdk::Resource;

use crate::Opentelemetry;
Expand All @@ -25,12 +27,20 @@ pub fn init(
level: &str,
exporter_endpoint: &str,
) -> anyhow::Result<()> {
// FIXME: make this configurable from the API level
let batch_config = BatchConfigBuilder::default()
.with_max_export_timeout(Duration::from_secs(1))
.with_max_queue_size(10_000)
.with_max_export_batch_size(100_000);
let batch_config = batch_config.build();

let logger_provider = opentelemetry_otlp::new_pipeline()
.logging()
.with_resource(Resource::new(vec![KeyValue::new(
opentelemetry_semantic_conventions::resource::SERVICE_NAME,
tag,
)]))
.with_batch_config(batch_config)
.with_exporter(
http_exporter()
.with_protocol(Protocol::HttpBinary) //can be changed to `Protocol::HttpJson` to export in JSON format
Expand Down

0 comments on commit 7d702a3

Please sign in to comment.