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

Improve metrics hook setup #12672

Open
mattsse opened this issue Nov 19, 2024 · 1 comment · May be fixed by #12684
Open

Improve metrics hook setup #12672

mattsse opened this issue Nov 19, 2024 · 1 comment · May be fixed by #12684
Labels
C-debt Refactor of code section that is hard to understand or maintain C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started

Comments

@mattsse
Copy link
Collaborator

mattsse commented Nov 19, 2024

Describe the feature

currently we do:

pub struct Hooks {
inner: Arc<Vec<Box<dyn Hook<Output = ()>>>>,
}

which makes the metrics crate depend on

use reth_provider::providers::StaticFileProvider;

we can improve this api with a builder API

HooksBuilder {
  Vec<Box<dyn Hook<Output = ()>>>
}

and replace the new function

pub fn new<Metrics, N>(db: Metrics, static_file_provider: StaticFileProvider<N>) -> Self

with something like

fn with(mut self, hook: impl Hook)

then we need to change how this type is instantiated and effectively push these:

Box::new(move || db.report_metrics()),
Box::new(move || {
let _ = static_file_provider.report_metrics().map_err(
|error| tracing::error!(%error, "Failed to report static file provider metrics"),
);
}),

to the callsite

Additional context

No response

@mattsse mattsse added C-enhancement New feature or request S-needs-triage This issue needs to be labelled labels Nov 19, 2024
@mattsse mattsse added C-debt Refactor of code section that is hard to understand or maintain D-good-first-issue Nice and easy! A great choice to get started and removed S-needs-triage This issue needs to be labelled labels Nov 19, 2024
@nils-mathieu
Copy link

May I take this?

@nils-mathieu nils-mathieu linked a pull request Nov 19, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-debt Refactor of code section that is hard to understand or maintain C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

2 participants