@@ -42,6 +42,7 @@ impl OtlpPipeline {
42
42
OtlpLogPipeline {
43
43
log_config : None ,
44
44
exporter_builder : NoExporterConfig ( ( ) ) ,
45
+ batch_config : None ,
45
46
}
46
47
}
47
48
}
@@ -124,6 +125,7 @@ impl opentelemetry_sdk::export::logs::LogExporter for LogExporter {
124
125
pub struct OtlpLogPipeline < EB > {
125
126
exporter_builder : EB ,
126
127
log_config : Option < opentelemetry_sdk:: logs:: Config > ,
128
+ batch_config : Option < opentelemetry_sdk:: logs:: BatchConfig > ,
127
129
}
128
130
129
131
impl < EB > OtlpLogPipeline < EB > {
@@ -132,6 +134,12 @@ impl<EB> OtlpLogPipeline<EB> {
132
134
self . log_config = Some ( log_config) ;
133
135
self
134
136
}
137
+
138
+ /// Set the batch log processor configuration, and it will override the env vars.
139
+ pub fn with_batch_config ( mut self , batch_config : opentelemetry_sdk:: logs:: BatchConfig ) -> Self {
140
+ self . batch_config = Some ( batch_config) ;
141
+ self
142
+ }
135
143
}
136
144
137
145
impl OtlpLogPipeline < NoExporterConfig > {
@@ -143,6 +151,7 @@ impl OtlpLogPipeline<NoExporterConfig> {
143
151
OtlpLogPipeline {
144
152
exporter_builder : pipeline. into ( ) ,
145
153
log_config : self . log_config ,
154
+ batch_config : self . batch_config ,
146
155
}
147
156
}
148
157
}
@@ -160,7 +169,7 @@ impl OtlpLogPipeline<LogExporterBuilder> {
160
169
) )
161
170
}
162
171
163
- /// Install the configured log exporter and a batch span processor using the
172
+ /// Install the configured log exporter and a batch log processor using the
164
173
/// specified runtime.
165
174
///
166
175
/// Returns a [`Logger`] with the name `opentelemetry-otlp` and the current crate version.
@@ -174,6 +183,7 @@ impl OtlpLogPipeline<LogExporterBuilder> {
174
183
self . exporter_builder . build_log_exporter ( ) ?,
175
184
self . log_config ,
176
185
runtime,
186
+ self . batch_config ,
177
187
) )
178
188
}
179
189
}
@@ -202,9 +212,14 @@ fn build_batch_with_exporter<R: RuntimeChannel>(
202
212
exporter : LogExporter ,
203
213
log_config : Option < opentelemetry_sdk:: logs:: Config > ,
204
214
runtime : R ,
215
+ batch_config : Option < opentelemetry_sdk:: logs:: BatchConfig > ,
205
216
) -> opentelemetry_sdk:: logs:: Logger {
206
- let mut provider_builder =
207
- opentelemetry_sdk:: logs:: LoggerProvider :: builder ( ) . with_batch_exporter ( exporter, runtime) ;
217
+ let mut provider_builder = opentelemetry_sdk:: logs:: LoggerProvider :: builder ( ) ;
218
+ let batch_processor = opentelemetry_sdk:: logs:: BatchLogProcessor :: builder ( exporter, runtime)
219
+ . with_batch_config ( batch_config. unwrap_or_default ( ) )
220
+ . build ( ) ;
221
+ provider_builder = provider_builder. with_log_processor ( batch_processor) ;
222
+
208
223
if let Some ( config) = log_config {
209
224
provider_builder = provider_builder. with_config ( config) ;
210
225
}
0 commit comments