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

feat(pruner, metrics): skip attribute for metrics derive macro #4069

Merged
merged 7 commits into from
Aug 9, 2023

Conversation

shekhirin
Copy link
Collaborator

@shekhirin shekhirin commented Aug 4, 2023

Allows to skip certain struct fields which are not intended to be parsed as metrics:

#[derive(Metrics)]
#[metrics(scope = "pruner")]
pub(crate) struct Metrics {
/// Pruning duration
pub(crate) duration_seconds: Histogram,
#[metric(skip)]
prune_parts: HashMap<PrunePart, PrunerPartMetrics>,
}

@shekhirin shekhirin marked this pull request as draft August 4, 2023 18:06
@shekhirin shekhirin removed request for onbjerg and gakonst August 4, 2023 18:06
@codecov
Copy link

codecov bot commented Aug 7, 2023

Codecov Report

Merging #4069 (04cb464) into main (6752db8) will decrease coverage by 0.03%.
The diff coverage is 90.35%.

Impacted file tree graph

Files Changed Coverage Δ
crates/metrics/metrics-derive/src/expand.rs 84.17% <90.09%> (+0.26%) ⬆️
crates/prune/src/metrics.rs 16.66% <100.00%> (-6.42%) ⬇️
crates/prune/src/pruner.rs 82.83% <100.00%> (ø)

... and 8 files with indirect coverage changes

Flag Coverage Δ
integration-tests 16.92% <87.71%> (+0.03%) ⬆️
unit-tests 63.93% <90.35%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
reth binary 25.83% <90.09%> (+0.54%) ⬆️
blockchain tree 83.04% <ø> (ø)
pipeline 90.07% <ø> (ø)
storage (db) 74.63% <ø> (ø)
trie 94.71% <ø> (ø)
txpool 47.59% <ø> (-0.60%) ⬇️
networking 77.39% <ø> (-0.02%) ⬇️
rpc 58.67% <ø> (-0.01%) ⬇️
consensus 63.76% <ø> (ø)
revm 32.26% <ø> (ø)
payload builder 6.57% <ø> (ø)
primitives 87.89% <ø> (-0.04%) ⬇️

@shekhirin shekhirin requested review from mattsse and rkrasiuk August 7, 2023 10:22
@shekhirin shekhirin marked this pull request as ready for review August 7, 2023 10:22
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

reasonable feature.

lgtm

Comment on lines +317 to +321
Meta::Path(path) if path.is_ident("skip") => skip = true,
Meta::NameValue(kv) => {
let lit = match kv.value {
Expr::Lit(ref expr) => &expr.lit,
_ => continue,
Copy link
Collaborator

Choose a reason for hiding this comment

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

simple

@mattsse mattsse added C-enhancement New feature or request A-observability Related to tracing, metrics, logs and other observability tools labels Aug 7, 2023
Copy link
Member

@rkrasiuk rkrasiuk left a comment

Choose a reason for hiding this comment

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

one smol nit. could we also get tests the skip fields being at the end of the struct, in the middle and having multiple consecutive/separate skip fields

.fold(
(vec![], vec![], vec![]),
|(mut defaults, mut labeled_defaults, mut describes),
(default, labeled_default, describe)| {
Copy link
Member

Choose a reason for hiding this comment

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

let's avoid using keywords as var names

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ah, didn't know it's a keyword from nightly feature, fixed

@shekhirin shekhirin requested a review from rkrasiuk August 7, 2023 14:27
Copy link
Member

@rkrasiuk rkrasiuk left a comment

Choose a reason for hiding this comment

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

beautiful

@shekhirin shekhirin added this pull request to the merge queue Aug 9, 2023
Merged via the queue into main with commit e925cbc Aug 9, 2023
@shekhirin shekhirin deleted the alexey/metrics-derive-skip branch August 9, 2023 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-observability Related to tracing, metrics, logs and other observability tools C-enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants