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

Expose log batchconfig #1471

Merged
merged 13 commits into from Jan 22, 2024
21 changes: 18 additions & 3 deletions opentelemetry-otlp/src/logs.rs
Expand Up @@ -42,6 +42,7 @@
OtlpLogPipeline {
log_config: None,
exporter_builder: NoExporterConfig(()),
batch_config: None,

Check warning on line 45 in opentelemetry-otlp/src/logs.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/logs.rs#L45

Added line #L45 was not covered by tests
}
}
}
Expand Down Expand Up @@ -124,6 +125,7 @@
pub struct OtlpLogPipeline<EB> {
exporter_builder: EB,
log_config: Option<opentelemetry_sdk::logs::Config>,
batch_config: Option<opentelemetry_sdk::logs::BatchConfig>,
}

impl<EB> OtlpLogPipeline<EB> {
Expand All @@ -132,6 +134,12 @@
self.log_config = Some(log_config);
self
}

/// Set the batch log processor configuration, and it will override the env vars.
pub fn with_batch_config(mut self, batch_config: opentelemetry_sdk::logs::BatchConfig) -> Self {
self.batch_config = Some(batch_config);
self
}

Check warning on line 142 in opentelemetry-otlp/src/logs.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/logs.rs#L139-L142

Added lines #L139 - L142 were not covered by tests
}

impl OtlpLogPipeline<NoExporterConfig> {
Expand All @@ -143,6 +151,7 @@
OtlpLogPipeline {
exporter_builder: pipeline.into(),
log_config: self.log_config,
batch_config: self.batch_config,

Check warning on line 154 in opentelemetry-otlp/src/logs.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/logs.rs#L154

Added line #L154 was not covered by tests
}
}
}
Expand All @@ -160,7 +169,7 @@
))
}

/// Install the configured log exporter and a batch span processor using the
/// Install the configured log exporter and a batch log processor using the
/// specified runtime.
///
/// Returns a [`Logger`] with the name `opentelemetry-otlp` and the current crate version.
Expand All @@ -174,6 +183,7 @@
self.exporter_builder.build_log_exporter()?,
self.log_config,
runtime,
self.batch_config,

Check warning on line 186 in opentelemetry-otlp/src/logs.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/logs.rs#L186

Added line #L186 was not covered by tests
))
}
}
Expand Down Expand Up @@ -202,9 +212,14 @@
exporter: LogExporter,
log_config: Option<opentelemetry_sdk::logs::Config>,
runtime: R,
batch_config: Option<opentelemetry_sdk::logs::BatchConfig>,

Check warning on line 215 in opentelemetry-otlp/src/logs.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/logs.rs#L215

Added line #L215 was not covered by tests
) -> opentelemetry_sdk::logs::Logger {
let mut provider_builder =
opentelemetry_sdk::logs::LoggerProvider::builder().with_batch_exporter(exporter, runtime);
let mut provider_builder = opentelemetry_sdk::logs::LoggerProvider::builder();
let batch_processor = opentelemetry_sdk::logs::BatchLogProcessor::builder(exporter, runtime)
.with_batch_config(batch_config.unwrap_or_default())
.build();
provider_builder = provider_builder.with_log_processor(batch_processor);

Check warning on line 221 in opentelemetry-otlp/src/logs.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/logs.rs#L217-L221

Added lines #L217 - L221 were not covered by tests

if let Some(config) = log_config {
provider_builder = provider_builder.with_config(config);
}
Expand Down
1 change: 1 addition & 0 deletions opentelemetry-sdk/CHANGELOG.md
Expand Up @@ -5,6 +5,7 @@
### Added

- [#1410](https://github.com/open-telemetry/opentelemetry-rust/pull/1410) Add experimental synchronous gauge
- [#1471](https://github.com/open-telemetry/opentelemetry-rust/pull/1471) Configure batch log record processor via [`OTEL_BLRP_*`](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#batch-logrecord-processor) environment variables and via `OtlpLogPipeline::with_batch_config`

### Changed

Expand Down