You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While it is possible to implement custom LogProcessor to avoid the second dynamic dispatch, the first dynamic dispatch remains unavoidable. This overhead should be eliminated.
This issue has been created to track the necessary improvements.
Add static dispatch for SimpleLogProcessor and SimpleConcurrentProcessor because their types are known at compile time.
We require dynamic dispatch for BatchLogProcessor as its runtime type can vary based on configuration, making it difficult to use a static type.
Any other custom log processor would be dispatched at runtime.
enumLogProcessorEnum{SimpleLogProcessor(SimpleLogProcessor),SimpleConcurrentProcessor(SimpleConcurrentProcessor),Batch(BatchLogProcessor<Box<dynRuntimeChannel>>),DynLogProcessor(Box<dynLogProcessor>),}implLogProcessorforLogProcessorEnum{fnemit(&self,data:&mutLogData){matchself{LogProcessorEnum::SimpleLogProcessor(p) => p.emit(data),LogProcessorEnum::SimpleConcurrentProcessor(p) => p.emit(data),LogProcessorEnum::Batch(p) => p.emit(data),LogProcessorEnum::DynLogProcessor(p) => p.emit(data),}}// --- and other methods ForceFlush() and Shutdown() similarly implemented.}#[derive(Debug)]structLoggerProviderInner{processors:Vec<LogProcessorEnum>,resource:Resource,}
Because of the async-runtime dependency, it is difficult to have the static dispatch for Batch Processor. However, it can be implemented through some macro , which would register this processor with async-runtime at compile time. Something like:
macro_rules! register_batch_log_processor {($runtime:ty) => {enumLogProcessorEnum{Simple(SimpleLogProcessor),
Batch(BatchLogProcessor<$runtime>),
// and others}/// and called as:
register_batch_log_processor!(TokioRuntime);
Currently, the log pipeline employs dynamic dispatching within its workflow:
While it is possible to implement custom
LogProcessor
to avoid the second dynamic dispatch, the first dynamic dispatch remains unavoidable. This overhead should be eliminated.This issue has been created to track the necessary improvements.
Reference:
LogEmitter.rs:
opentelemetry-rust/opentelemetry-sdk/src/logs/log_emitter.rs
Lines 140 to 144 in a9b8621
SimpleLogProcessor:
opentelemetry-rust/opentelemetry-sdk/src/logs/log_processor.rs
Lines 78 to 81 in a9b8621
BatchLogProcessor:
opentelemetry-rust/opentelemetry-sdk/src/logs/log_processor.rs
Lines 200 to 202 in a9b8621
The text was updated successfully, but these errors were encountered: