Skip to content

feat: add method tracing to routing#715

Merged
achingbrain merged 1 commit intomainfrom
feat/add-tracing
Jan 13, 2025
Merged

feat: add method tracing to routing#715
achingbrain merged 1 commit intomainfrom
feat/add-tracing

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
@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

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