-
Notifications
You must be signed in to change notification settings - Fork 75
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 metrics property to helia interface #512
Conversation
To allow collecting metrics about arbitrary parts of the Helia stack, add an optional `.metrics` property for stat collection. This can be used with implementations such as `@libp2p/prometheus-metrics` and/or others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved, but we should update readme with explainers on metrics collected, or a list of them at a minimum
* A metrics object that can be used to collected arbitrary stats about node | ||
* usage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we use libp2p metrics config object directly. Should we link to https://github.com/libp2p/js-libp2p/blob/main/doc/CONFIGURATION.md#configuring-metrics ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those docs need some updating, they're not correct any more.
|
||
/** | ||
* A metrics object that can be used to collected arbitrary stats about node | ||
* usage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto on linking to https://github.com/libp2p/js-libp2p/blob/main/doc/CONFIGURATION.md#configuring-metrics ?
blocksSent: components.metrics?.registerCounter('helia_bitswap_sent_blocks_total'), | ||
dataSent: components.metrics?.registerCounter('helia_bitswap_sent_data_bytes_total') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should update readme with a list of metrics that we add when metrics are enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be good, though prone to being out of date very quickly. It'd be nice if we could automate this somehow.
this.blocksReceived = components.metrics?.registerMetricGroup('helia_bitswap_received_blocks') | ||
this.duplicateBlocksReceived = components.metrics?.registerMetricGroup('helia_bitswap_duplicate_received_blocks') | ||
this.dataReceived = components.metrics?.registerMetricGroup('helia_bitswap_data_received_bytes') | ||
this.duplicateDataReceived = components.metrics?.registerMetricGroup('helia_bitswap_duplicate_data_received_bytes') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should update readme with a list of metrics that we add when metrics are enabled.
To allow collecting metrics about arbitrary parts of the Helia stack, add an optional
.metrics
property for stat collection.This can be used with implementations such as
@libp2p/prometheus-metrics
and/or others.Change checklist