feat: add traceFunction call to metrics#2898
Merged
achingbrain merged 3 commits intomainfrom Jan 7, 2025
Merged
Conversation
73887f2 to
fc5f1a5
Compare
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.
fc5f1a5 to
086c5c5
Compare
3 tasks
Merged
achingbrain
added a commit
that referenced
this pull request
Jan 7, 2025
Adds a `Metrics` interface implementation that is powered by an OpenTelemetry backend. It tracks the same metrics as `@libp2p/prometheus-metrics` but also supports the new function tracing added in #2898. See the readme for a usage example.
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allow tracing method calls using a metrics implementation.
Adds tracing support to
libp2p.contentRouting.*andlibp2p.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