Fix an issue where tcpconnection metrics were duplicated#83
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses duplicated tcpconnections metrics by de-duplicating repeated TCP_LISTEN entries returned from netlink before emitting Prometheus metrics.
Changes:
- De-duplicate listeners using a map keyed by
address:portduring collection. - Add a regression test covering duplicate listener entries coming from netlink.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| exporter/tcpconnections/collector.go | De-duplicates listener discovery and returns metrics derived from the de-duplicated set. |
| exporter/tcpconnections/collector_test.go | Adds a test case ensuring repeated listener entries don’t produce duplicated metrics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0d3db6b to
e8d98cd
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # HELP tcp_queued_connections Number of connections in queue | ||
| # TYPE tcp_queued_connections gauge | ||
| tcp_queued_connections{listener="0.0.0.0:3000"} 0 | ||
| tcp_queued_connections{listener="127.0.0.1:8080"} 0 | ||
| tcp_queued_connections{listener="0.0.0.0:8080"} 0 | ||
| `, |
There was a problem hiding this comment.
In the "multiple listeners" test, the expected queued metric label uses listener="10.0.0.0:8080", but the listener objects for 8080 are bound to 0.0.0.0 and the collector hard-codes the listener address to 0.0.0.0. This expectation looks like a typo and will fail the test (or mask regressions).
No description provided.