Skip to content

Commit ba36c8f

Browse files
committed
update doc comment
1 parent 67a1b32 commit ba36c8f

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

opentelemetry-sdk/src/logs/log_processor.rs

+13-12
Original file line numberDiff line numberDiff line change
@@ -264,20 +264,21 @@ type LogsData = Box<(LogRecord, InstrumentationScope)>;
264264
/// .with_log_processor(processor)
265265
/// .build();
266266
///
267-
///
267+
///
268268
// **Memory Management in BatchLogProcessor**
269269
//
270270
// The `BatchLogProcessor` manages memory through the following stages of log processing:
271271
//
272272
// 1. **Record Ingestion**:
273273
// - Each `LogRecord` is **cloned** upon entering the processor.
274274
// - `LogRecordAttributes` utilize a hybrid memory model:
275-
// - Attributes up to `PREALLOCATED_ATTRIBUTE_CAPACITY` are **stack-allocated**.
276-
// - Exceeding attributes trigger **heap allocation** in a dynamically growing vector.
275+
// - First 5 attributes are **stack-allocated**.
276+
// - Adding additional attribtues trigger **heap allocation** in a dynamically growing vector.
277277
// - The `LogRecord` and its associated `InstrumentationScope` are **boxed together**
278278
// to allocate them on the heap before entering the queue. This means:
279-
// - The entire `LogRecord` object, including its stack-allocated inline attributes, is moved to the heap.
280-
// - Any overflow attributes already on the heap remain unaffected.
279+
// - The `LogRecord`'s inline attributes (if any) are moved to the heap as part of the boxed structure.
280+
// - Any dynamically allocated data already on the heap (e.g., strings, overflow attributes) remains unaffected.
281+
// - Ownership of the boxed data is transferred to the queue, ensuring it can be processed independently of the original objects.
281282
//
282283
// 2. **Queue Management**:
283284
// - Uses **two bounded synchronous channels** (`sync_channel`):
@@ -311,19 +312,19 @@ type LogsData = Box<(LogRecord, InstrumentationScope)>;
311312
// - During the export process:
312313
// - The worker thread retrieves records from the log record queue until `max_export_batch_size` is reached or the queue is empty.
313314
// - The retrieved records are processed in batches and passed to the exporter.
314-
// - The `ExportLog` message in the control queue explicitly triggers an export operation:
315-
// - It is generated when the current batch size reaches `max_export_batch_size`.
316-
// - A flag ensures only one `ExportLog` message is sent at a time to prevent redundant processing.
317-
// - This message prompts the worker thread to process and export the current batch immediately, regardless of the scheduled delay.
318315
// - The exporter's `export()` method receives references to the log records and `InstrumentationScope`.
319316
// - If the exporter requires retaining the log records (e.g., for retries or asynchronous operations), it must **clone** the records inside the `export()` implementation.
320317
// - After successful export:
321318
// - The original boxed records are dropped, releasing heap memory.
322319
// - Export is triggered in the following scenarios:
323-
// - When the batch size reaches `max_export_batch_size`.
320+
// - When the batch size reaches `max_export_batch_size`, resulting in `ExportLog` control message being sent to the worker thread.
324321
// - When the scheduled delay timer expires.
325-
// - When `force_flush` is called.
326-
// - During processor shutdown.
322+
// - When `force_flush` is called by the application, resulting in a `ForceFlush` control message being sent to the worker thread.
323+
// - During processor shutdown initiated by the application, resulting in a `Shutdown` control message being sent to the worker thread.
324+
// - Generation of `ExportLog` control message:
325+
// - The `ExportLog` control message is generated by the application thread when a new record is added to the log record queue, and the current batch size reaches `max_export_batch_size`.
326+
// - To prevent redundant messages, the `ExportLog` message is only sent if the previous one has been processed by the worker thread.
327+
// - Upon receiving this message, the worker thread immediately processes and exports the current batch, overriding any scheduled delay.
327328
//
328329
// 5. **Memory Limits**:
329330
// - **Worst-Case Memory Usage**:

0 commit comments

Comments
 (0)