Skip to content
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

Merged
merged 5 commits into from
Aug 16, 2024

Conversation

supernovahs
Copy link
Collaborator

Currently , user could only input the tracinglogger, added option to add nooplogger also for testing purposes

static LOGGER: OnceCell<TracingLogger> = OnceCell::new();
static LOGGER: OnceCell<EigenLogger> = OnceCell::new();

#[derive(Debug, Clone, Default)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docs

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

crates/logging/src/lib.rs Outdated Show resolved Hide resolved
&["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(
Copy link
Collaborator

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?

Copy link
Collaborator Author

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 ?

Copy link
Collaborator

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?

Copy link
Collaborator

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@supernovahs supernovahs merged commit ddb0136 into main Aug 16, 2024
1 check failed
@supernovahs supernovahs deleted the supernovahs/use_noop_logger_for_testing branch August 16, 2024 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request testing-utils
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants