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 traceFunction call to metrics #2898

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

achingbrain
Copy link
Member

@achingbrain achingbrain commented Dec 19, 2024

Allow tracing method calls using a metrics implementation.

const libp2p = await createLibp2p()

for await (const foo of libp2p.contentRouting.findProviders(cid, {
  context: libp2p.metrics?.createTraceContext(),
  signal: AbortSignal.timeout(20_000)
}) {
  //...
}

Adds tracing support to libp2p.contentRouting.* and libp2p.peerRouting.* to start with, other methods can have it added when necessary.

Traces can have attributes set on them to give context to a call (input args, output values, yielded results, etc).

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

@achingbrain achingbrain requested a review from a team as a code owner December 19, 2024 18:03
@achingbrain achingbrain force-pushed the feat/add-trace-function-to-metrics branch from 73887f2 to fc5f1a5 Compare December 19, 2024 18:11
Allow tracing method calls using a metrics implementation.

```js
const libp2p = await createLibp2p()

for await (const foo of libp2p.contentRouting.findProviders(cid, {
  context: libp2p.metrics?.createTraceContext()
  signal: AbortSignal.timeout(20_000)
}) {
  //...
}
```

Adds tracing support to `libp2p.contentRouting.*` and
`libp2p.peerRouting.*` to start with, other methods can have it added
when necessary.
@achingbrain achingbrain force-pushed the feat/add-trace-function-to-metrics branch from fc5f1a5 to 086c5c5 Compare December 19, 2024 18:13
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.

1 participant