Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: increate batch configuration #4

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading