[receiver/hostmetrics] Add system.network.bandwidth.limit metric#49361
[receiver/hostmetrics] Add system.network.bandwidth.limit metric#49361emmayusufu wants to merge 2 commits into
Conversation
The network scraper exposed byte, packet, error, and conntrack metrics but nothing for link capacity, so consumers could not compute interface saturation. This adds an optional, disabled-by-default system.network.bandwidth.limit gauge that reads the NIC link speed from sysfs on Linux and reports it in bytes/s. Signed-off-by: Emmanuel Yusufu Kimaswa <kimaswaemma36@gmail.com>
|
Welcome, contributor! Thank you for your contribution to opentelemetry-collector-contrib. Important reminders:
|
| stability: development | ||
| gauge: | ||
| value_type: int | ||
| attributes: [device] |
There was a problem hiding this comment.
We should be using network.interface.name & network.io.direction attributes.
|
Thanks for the review. For the interface attribute, I used On |
|
Actually the guidance in the developers docs is to use the semconv and that is what alot of other scrapers/receivers do. In relation to limit, the use cases is as described in https://opentelemetry.io/docs/specs/semconv/general/naming/#instrument-naming which is the limit metric pairs with usage metric to give utilization. |
Switch to network.interface.name and network.io.direction per review. The limit is emitted per direction since a full-duplex link carries the capacity each way, which pairs with system.network.io for utilization. Signed-off-by: Emmanuel Yusufu Kimaswa <kimaswaemma36@gmail.com>
|
Fair enough, you're right. nfsscraper already uses |
Description
The network scraper exposes byte, packet, error, dropped, connection, and conntrack metrics, but nothing for link capacity. Consumers can derive byte rates from
system.network.iobut can't compute interface saturation without the NIC link speed.This adds an optional, disabled-by-default
system.network.bandwidth.limitgauge (unitBy/s, attributedevice). On Linux it reads the interface link speed from/sys/class/net/<device>/speed(honoringHOST_SYS) and converts Mbit/s to bytes/s. It's a no-op on other platforms, and interfaces that report-1(virtual or down links) are skipped.I scoped this to the bandwidth limit only. The utilization metric from the issue can follow once the limit lands, since it needs prev-sample delta tracking.
Link to tracking issue
Part of #49169
Testing
Added a unit test for the sysfs speed read (valid speed,
-1, unparseable, missing interface). Regenerated with mdatagen;go test ./...andGOOS=linux go vet ./...pass.Documentation
Regenerated
documentation.mdvia mdatagen and added a changelog entry.