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: add method tracing to routing #715

Merged
merged 1 commit into from
Jan 13, 2025
Merged

feat: add method tracing to routing #715

merged 1 commit into from
Jan 13, 2025

Conversation

achingbrain
Copy link
Member

Adds a trace option to all routing methods that can be used with libp2p metrics implementations that support method tracing.

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

Adds a `trace` option to all routing methods that can be used with
libp2p metrics implementations that support method tracing.
@achingbrain achingbrain requested a review from a team as a code owner January 9, 2025 11:47
@achingbrain achingbrain merged commit 5784ceb into main Jan 13, 2025
18 checks passed
@achingbrain achingbrain deleted the feat/add-tracing branch January 13, 2025 16:45
optionsIndex: 1
}) ?? this.findProviders
this.provide = components.metrics?.traceFunction('helia.routing.provide', this.provide.bind(this), {
optionsIndex: 1
Copy link
Member

Choose a reason for hiding this comment

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

What's optionsIndex?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Even after having read that, I'm not sure how optionsIndex influences the trace context and what the value should be, e.g. why do some of the calls here use optionsIndex: 2

Copy link
Member Author

Choose a reason for hiding this comment

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

The metrics implementation has to know which argument is the options object in order to extract the trace context. It can't figure it out for itself so we have to tell it:

myTracedFunction(arg0, arg1, options)  // <-- optionsIndex = 2
myOtherTracedFunction(arg0, options)  // <-- optionsIndex = 1

@achingbrain achingbrain mentioned this pull request Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants