-
Notifications
You must be signed in to change notification settings - Fork 431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eliminate Dynamic Dispatching in Log Pipeline for Performance Optimization #1942
Comments
Assuming SimpleConcurrentProcessor is part of the specs. The simple solution could be
enum LogProcessorEnum {
SimpleLogProcessor(SimpleLogProcessor),
SimpleConcurrentProcessor(SimpleConcurrentProcessor),
Batch(BatchLogProcessor<Box<dyn RuntimeChannel>>),
DynLogProcessor(Box<dyn LogProcessor>),
}
impl LogProcessor for LogProcessorEnum {
fn emit(&self, data: &mut LogData) {
match self {
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)]
struct LoggerProviderInner {
processors: Vec<LogProcessorEnum>,
resource: Resource,
} Because of the macro_rules! register_batch_log_processor {
($runtime:ty) => {
enum LogProcessorEnum {
Simple(SimpleLogProcessor),
Batch(BatchLogProcessor<$runtime>),
// and others
}
/// and called as:
register_batch_log_processor!(TokioRuntime); |
We don't need it to be part of the spec, it is sufficient that it is part of opentelemtry-sdk crate. Spec does not prohibit additional processors. |
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: