Skip to content

Commit acaa98d

Browse files
cijothomaslalitb
andauthored
Doc additions for Simple and Batch processors (open-telemetry#2529)
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
1 parent 90b0dd4 commit acaa98d

File tree

5 files changed

+97
-11
lines changed

5 files changed

+97
-11
lines changed

opentelemetry-sdk/src/lib.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@
4444
//! [examples]: https://github.com/open-telemetry/opentelemetry-rust/tree/main/examples
4545
//! [`trace`]: https://docs.rs/opentelemetry/latest/opentelemetry/trace/index.html
4646
//!
47-
//! # Metrics (Alpha)
48-
//!
49-
//! Note: the metrics implementation is **still in progress** and **subject to major
50-
//! changes**.
47+
//! # Metrics
5148
//!
5249
//! ### Creating instruments and recording measurements
5350
//!

opentelemetry-sdk/src/logs/log_emitter.rs

+33-3
Original file line numberDiff line numberDiff line change
@@ -185,21 +185,51 @@ pub struct Builder {
185185
}
186186

187187
impl Builder {
188-
/// The `LogExporter` that this provider should use.
188+
/// Adds a [SimpleLogProcessor] with the configured exporter to the pipeline.
189+
///
190+
/// # Arguments
191+
///
192+
/// * `exporter` - The exporter to be used by the SimpleLogProcessor.
193+
///
194+
/// # Returns
195+
///
196+
/// A new `Builder` instance with the SimpleLogProcessor added to the pipeline.
197+
///
198+
/// Processors are invoked in the order they are added.
189199
pub fn with_simple_exporter<T: LogExporter + 'static>(self, exporter: T) -> Self {
190200
let mut processors = self.processors;
191201
processors.push(Box::new(SimpleLogProcessor::new(exporter)));
192202

193203
Builder { processors, ..self }
194204
}
195205

196-
/// The `LogExporter` setup using a default `BatchLogProcessor` that this provider should use.
206+
/// Adds a [BatchLogProcessor] with the configured exporter to the pipeline.
207+
///
208+
/// # Arguments
209+
///
210+
/// * `exporter` - The exporter to be used by the BatchLogProcessor.
211+
///
212+
/// # Returns
213+
///
214+
/// A new `Builder` instance with the BatchLogProcessor added to the pipeline.
215+
///
216+
/// Processors are invoked in the order they are added.
197217
pub fn with_batch_exporter<T: LogExporter + 'static>(self, exporter: T) -> Self {
198218
let batch = BatchLogProcessor::builder(exporter).build();
199219
self.with_log_processor(batch)
200220
}
201221

202-
/// The `LogProcessor` that this provider should use.
222+
/// Adds a custom [LogProcessor] to the pipeline.
223+
///
224+
/// # Arguments
225+
///
226+
/// * `processor` - The `LogProcessor` to be added.
227+
///
228+
/// # Returns
229+
///
230+
/// A new `Builder` instance with the custom `LogProcessor` added to the pipeline.
231+
///
232+
/// Processors are invoked in the order they are added.
203233
pub fn with_log_processor<T: LogProcessor + 'static>(self, processor: T) -> Self {
204234
let mut processors = self.processors;
205235
processors.push(Box::new(processor));

opentelemetry-sdk/src/logs/log_processor.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,18 @@ pub trait LogProcessor: Send + Sync + Debug {
104104
}
105105

106106
/// A [`LogProcessor`] designed for testing and debugging purpose, that immediately
107-
/// exports log records as they are emitted.
107+
/// exports log records as they are emitted. Log records are exported synchronously
108+
/// in the same thread that emits the log record.
109+
/// When using this processor with the OTLP Exporter, the following exporter
110+
/// features are supported:
111+
/// - `grpc-tonic`: This requires LoggerProvider to be created within a tokio
112+
/// runtime. Logs can be emitted from any thread, including tokio runtime
113+
/// threads.
114+
/// - `reqwest-blocking-client`: LoggerProvider may be created anywhere, but
115+
/// logs must be emitted from a non-tokio runtime thread.
116+
/// - `reqwest-client`: LoggerProvider may be created anywhere, but logs must be
117+
/// emitted from a tokio runtime thread.
118+
///
108119
/// ## Example
109120
///
110121
/// ### Using a SimpleLogProcessor

opentelemetry-sdk/src/trace/provider.rs

+33-3
Original file line numberDiff line numberDiff line change
@@ -280,21 +280,51 @@ pub struct Builder {
280280
}
281281

282282
impl Builder {
283-
/// The `SpanExporter` that this provider should use.
283+
/// Adds a [SimpleSpanProcessor] with the configured exporter to the pipeline.
284+
///
285+
/// # Arguments
286+
///
287+
/// * `exporter` - The exporter to be used by the SimpleSpanProcessor.
288+
///
289+
/// # Returns
290+
///
291+
/// A new `Builder` instance with the SimpleSpanProcessor added to the pipeline.
292+
///
293+
/// Processors are invoked in the order they are added.
284294
pub fn with_simple_exporter<T: SpanExporter + 'static>(self, exporter: T) -> Self {
285295
let mut processors = self.processors;
286296
processors.push(Box::new(SimpleSpanProcessor::new(Box::new(exporter))));
287297

288298
Builder { processors, ..self }
289299
}
290300

291-
/// The [`SpanExporter`] setup using a default [`BatchSpanProcessor`] that this provider should use.
301+
/// Adds a [BatchSpanProcessor] with the configured exporter to the pipeline.
302+
///
303+
/// # Arguments
304+
///
305+
/// * `exporter` - The exporter to be used by the BatchSpanProcessor.
306+
///
307+
/// # Returns
308+
///
309+
/// A new `Builder` instance with the BatchSpanProcessor added to the pipeline.
310+
///
311+
/// Processors are invoked in the order they are added.
292312
pub fn with_batch_exporter<T: SpanExporter + 'static>(self, exporter: T) -> Self {
293313
let batch = BatchSpanProcessor::builder(exporter).build();
294314
self.with_span_processor(batch)
295315
}
296316

297-
/// The [`SpanProcessor`] that this provider should use.
317+
/// Adds a custom [SpanProcessor] to the pipeline.
318+
///
319+
/// # Arguments
320+
///
321+
/// * `processor` - The `SpanProcessor` to be added.
322+
///
323+
/// # Returns
324+
///
325+
/// A new `Builder` instance with the custom `SpanProcessor` added to the pipeline.
326+
///
327+
/// Processors are invoked in the order they are added.
298328
pub fn with_span_processor<T: SpanProcessor + 'static>(self, processor: T) -> Self {
299329
let mut processors = self.processors;
300330
processors.push(Box::new(processor));

opentelemetry-sdk/src/trace/span_processor.rs

+18
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,17 @@ pub trait SpanProcessor: Send + Sync + std::fmt::Debug {
102102
/// `SpanExporter`, as soon as they are finished, without any batching. This is
103103
/// typically useful for debugging and testing. For scenarios requiring higher
104104
/// performance/throughput, consider using [BatchSpanProcessor].
105+
/// Spans are exported synchronously
106+
/// in the same thread that emits the log record.
107+
/// When using this processor with the OTLP Exporter, the following exporter
108+
/// features are supported:
109+
/// - `grpc-tonic`: This requires TracerProvider to be created within a tokio
110+
/// runtime. Spans can be emitted from any thread, including tokio runtime
111+
/// threads.
112+
/// - `reqwest-blocking-client`: TracerProvider may be created anywhere, but
113+
/// spans must be emitted from a non-tokio runtime thread.
114+
/// - `reqwest-client`: TracerProvider may be created anywhere, but spans must be
115+
/// emitted from a tokio runtime thread.
105116
#[derive(Debug)]
106117
pub struct SimpleSpanProcessor {
107118
exporter: Mutex<Box<dyn SpanExporter>>,
@@ -171,6 +182,13 @@ use crate::export::trace::ExportResult;
171182
/// individually. It uses a **dedicated background thread** to manage and export spans
172183
/// asynchronously, ensuring that the application's main execution flow is not blocked.
173184
///
185+
/// When using this processor with the OTLP Exporter, the following exporter
186+
/// features are supported:
187+
/// - `grpc-tonic`: This requires `TracerProvider` to be created within a tokio
188+
/// runtime.
189+
/// - `reqwest-blocking-client`: Works with a regular `main` or `tokio::main`.
190+
///
191+
/// In other words, other clients like `reqwest` and `hyper` are not supported.
174192
/// /// # Example
175193
///
176194
/// This example demonstrates how to configure and use the `BatchSpanProcessor`

0 commit comments

Comments
 (0)