-
Notifications
You must be signed in to change notification settings - Fork 16
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
add support for noop logger also #77
Conversation
crates/logging/src/lib.rs
Outdated
static LOGGER: OnceCell<TracingLogger> = OnceCell::new(); | ||
static LOGGER: OnceCell<EigenLogger> = OnceCell::new(); | ||
|
||
#[derive(Debug, Clone, Default)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
&["eigen-metrics-collectors-rpc-calls.set_rpc_request_duration_seconds"], | ||
) | ||
match (&self.logger.tracing_logger, &self.logger.noop_logger) { | ||
(Some(tracing_logger), _) => tracing_logger.debug( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems very verbose, could you abstract the logger away, so that you decide on a type of logger in the beginning and then that's the one used without the caller knowing which is the current one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The user will initialize their logger once in the beginning, and share it .
From 2 options : Tracing logger, or Noop Logger
Logger needs to be shared across the crates, so it can't be removed from the structs (if that 's what you meant by abstracting away the logger).
There is a way to allow user to use any of the logger by using the Logger trait , instead of EigenLogger struct , but that would mean some complexity in DevEx .
Something like this
pub struct EigenPerformanceMetrics<'a, L: Logger> {
/// The performance metric is a score between 0 and 100 and each developer can define their own way of calculating the score.
/// The score is calculated based on the performance of the AVS Node and the performance of the backing services.
eigen_metrics: EigenPerformance,
logger: &'a L,
}
Should i follow the above pattern ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you make the logger an Arc and thus avoid the lifetimes issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could even typedef it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Currently , user could only input the tracinglogger, added option to add nooplogger also for testing purposes