pub struct LoggerProviderBuilder { /* private fields */ }Expand description
Builder for provider attributes.
Implementations§
Source§impl LoggerProviderBuilder
impl LoggerProviderBuilder
Sourcepub fn with_simple_exporter<T: LogExporter + 'static>(self, exporter: T) -> Self
pub fn with_simple_exporter<T: LogExporter + 'static>(self, exporter: T) -> Self
Adds a SimpleLogProcessor with the configured exporter to the pipeline.
§Arguments
exporter- The exporter to be used by the SimpleLogProcessor.
§Returns
A new Builder instance with the SimpleLogProcessor added to the pipeline.
Processors are invoked in the order they are added.
Sourcepub fn with_batch_exporter<T: LogExporter + 'static>(self, exporter: T) -> Self
pub fn with_batch_exporter<T: LogExporter + 'static>(self, exporter: T) -> Self
Adds a BatchLogProcessor with the configured exporter to the pipeline, using the default super::BatchConfig.
The following environment variables can be used to configure the batching configuration:
OTEL_BLRP_SCHEDULE_DELAY- Corresponds towith_scheduled_delay.OTEL_BLRP_MAX_QUEUE_SIZE- Corresponds towith_max_queue_size.OTEL_BLRP_MAX_EXPORT_BATCH_SIZE- Corresponds towith_max_export_batch_size.
§Arguments
exporter- The exporter to be used by theBatchLogProcessor.
§Returns
A new LoggerProviderBuilder instance with the BatchLogProcessor added to the pipeline.
Processors are invoked in the order they are added.
Sourcepub fn with_log_processor<T: LogProcessor + 'static>(self, processor: T) -> Self
pub fn with_log_processor<T: LogProcessor + 'static>(self, processor: T) -> Self
Adds a custom LogProcessor to the pipeline.
§Arguments
processor- TheLogProcessorto be added.
§Returns
A new Builder instance with the custom LogProcessor added to the pipeline.
Processors are invoked in the order they are added.
Sourcepub fn with_resource(self, resource: Resource) -> Self
pub fn with_resource(self, resource: Resource) -> Self
Associates a Resource with a SdkLoggerProvider.
This Resource represents the entity producing telemetry and is associated
with all Loggers the SdkLoggerProvider will create.
By default, if this option is not used, the default Resource will be used.
When constructing a Resource, use Resource::builder() to preserve
SDK-provided defaults such as telemetry.sdk.* and service.name.
Using Resource::builder_empty() will not include these attributes.
§Example
use opentelemetry_sdk::{Resource, logs::SdkLoggerProvider};
use opentelemetry::KeyValue;
let provider = SdkLoggerProvider::builder()
.with_resource(
Resource::builder()
.with_service_name("my-service")
.with_attributes([KeyValue::new("deployment.environment.name", "production")])
.build(),
)
.build();Note: Calls to this method are additive, each call merges the provided resource with the previous one.
Sourcepub fn build(self) -> SdkLoggerProvider
pub fn build(self) -> SdkLoggerProvider
Create a new provider from this configuration.