-
Notifications
You must be signed in to change notification settings - Fork 1
refactor: Add derive macro and Metric
trait
#18
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
Conversation
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh-metrics/pr/18/docs/iroh_gossip/ Last updated: 2025-04-11T09:40:08Z |
34dedbc
to
2206f7a
Compare
2206f7a
to
7d3af42
Compare
47575bc
to
4f10df0
Compare
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.
Working through macros is always slightly mind bending.
Thanks for the tests, makes it so much easier to parse and understand.
👍
Description
Metric
trait that is implemented onGauge
andCounter
to provide a common interface.Iterable
that works similar tostruct_iterable
, but returns an iterator over&dyn Metric
and does not allocate for iteration.MetricsGroup
that expands to theIterable
impl and also implementsDefault
by callingFieldType::new(description)
for each field, wheredescription
is the first line of the field's doc comment, or a custom string set via#[metrics(description = "my description")]
. Also implementsMetricsGroup
, with aname
of either the struct name converted to camel_case, or a custom name set via#[metrics_group(name = "my_name")]
MetricsGroup
andMetricsGroupSet
by using the newMetric
trait and the dyn field iterator from the derivedIterable
implMetricDescription
types, those are not needed anymore.Breaking Changes
struct_iterable::Iterable
is no longer exported fromiroh-metrics
, and is no longer a supertrait ofMetricsGroup
MetricsGroup
now hasiroh_metrics::Iterable
andiroh_metrics::IntoIterable
supertraits. They can be implemented manually, but it is recommended to use the newMetricsGroup
orIterable
derive macros exported fromiroh_metrics
. See their docs for details.MetricsGroupSet::iter
is renamed toMetricsGroupSet::groups
MetricsGroup::values
andMetricsGroup::describe
are removed. UseMetricsGroup::iter
instead.MetricItem
struct changed, but still provides access to the same data, through thename()
method and its deref to&dyn Metric
.MetricDescription
is removed, everything there is now accessible overMetricItem
throughMetricsGroup::iter
.Notes & open questions
Change checklist