Skip to content

feat(metrics): lookup/resolver stats - #4411

Open
Arqu wants to merge 4 commits into
mainfrom
arqu/resolver_metrics
Open

feat(metrics): lookup/resolver stats#4411
Arqu wants to merge 4 commits into
mainfrom
arqu/resolver_metrics

Conversation

@Arqu

@Arqu Arqu commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Description

Adds counters to track lookup success rates and also tracks it by type of resolver.

Breaking Changes

Notes & open questions

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • All breaking changes documented.
  • This PR was created by a human that thought critically about the
    proposed change and wrote an as clear and concise description as
    they could.
  • This PR isn't slop, and is carefully crafted to do have the
    intented effect.

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/4411/docs/iroh/

Last updated: 2026-07-24T12:12:05Z

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

Netsim report & logs for this PR have been generated and is available at: LOGS
This report will remain available for 3 days.

Last updated for commit: 508c7ae

@Arqu
Arqu requested review from Frando and flub and removed request for flub July 14, 2026 10:57
@n0bot n0bot Bot added this to iroh Jul 14, 2026
@github-project-automation github-project-automation Bot moved this to 🚑 Needs Triage in iroh Jul 14, 2026
Comment thread iroh/src/address_lookup.rs Outdated
Comment on lines +483 to +489
/// Creates a new registry that records resolution outcomes in the given metrics.
pub fn with_metrics(metrics: Arc<Metrics>) -> Self {
Self {
metrics,
..Default::default()
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I can't find any APIs where the user can use this type. As far as I can find it is only returned by some Endpoint::address_lookup and that's it. The rest that is pub is just there for inspection by users.

So I don't think this constructor should be pub.

Comment thread iroh/src/address_lookup.rs Outdated
Comment on lines +491 to +494
/// Returns the metrics tracking per-service resolution outcomes.
pub fn metrics(&self) -> &Arc<Metrics> {
&self.metrics
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is going to sound very pedantic. The order in which functions are declared in the code is the order they are documented in by rustdoc. This means generally that the most important functions should come first. This is not the most important function.

Yeah I know, neither is set_addr_filter. But let's not make things worse. Can we put it afer len? That is the only other "inspection"-like API on this type so seems like it should belong together.

Comment thread iroh/src/address_lookup/metrics.rs Outdated
/// Number of successful resolutions, labeled by the service that produced the result.
pub resolve_success: Family<ServiceLabels, Counter>,
/// Number of failed resolutions, labeled by the service that produced the error.
pub resolve_error: Family<ServiceLabels, Counter>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These are very confusing. lookups vs resolve? But lookup gets incremented in the resolve() method. IIUC resolve is for results returned and you can get multiple results per lookup. So a lookup is like a request. and resolve is like a yielded item. lookups_failed is a failure to process the lookup request I think.

I'm not saying these as suggestions, I don't really know what to suggest. I'm only trying to understand their meaning.

@github-project-automation github-project-automation Bot moved this from 🚑 Needs Triage to 🏗 In progress in iroh Jul 14, 2026
@Arqu
Arqu force-pushed the arqu/resolver_metrics branch from 115bd32 to 07cdb41 Compare July 22, 2026 11:24
@Arqu
Arqu requested a review from flub July 22, 2026 11:29
@Arqu Arqu moved this from 🏗 In progress to 👀 In review in iroh Jul 22, 2026
/// (e.g. once a connection is established) are not counted.
pub lookups_failed: Counter,
/// Results yielded per service.
pub service_results: Family<ServiceLabels, Counter>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is probably my rust brain. but errors are a sub-set of results. maybe "items" is better? but i admit this is mostly bikeshedding.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Hmmm items also sounds off. responses?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

in an attempt to find more inspiration i found that the existing docs and APIs literally call these item: https://docs.rs/iroh/latest/iroh/address_lookup/struct.Item.html and https://docs.rs/iroh/latest/iroh/address_lookup/trait.AddressLookup.html#method.resolve

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

also, does this need to be singular? does service_results end up as a service_results_count? Probably service_result_count (or service_item_count) makes more sense?

///
/// Includes lookups with no services configured. Lookups abandoned early
/// (e.g. once a connection is established) are not counted.
pub lookups_failed: Counter,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Misses lookups_success?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

lookups - lookups_failed ?

@Frando Frando Jul 25, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Only roughly correct over time, because it would count inflight lookups too. But maybe good enough. To me it would be clearer to count success too and then inflight is lookups - (failed + success)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fair point

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

3 participants