Skip to content

Commit

Permalink
Merge pull request #4 from vincenzopalazzo/macros/set-batch-processor
Browse files Browse the repository at this point in the history
core: increate batch configuration
  • Loading branch information
vincenzopalazzo authored Oct 30, 2024
2 parents 86c8059 + 7d702a3 commit f785cab
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 f785cab

Please sign in to comment.