Skip to content

Fix an issue where tcpconnection metrics were duplicated#83

Merged
errm merged 3 commits intomasterfrom
errm/deduplicate-tcpconnection-metrics
Mar 2, 2026
Merged

Fix an issue where tcpconnection metrics were duplicated#83
errm merged 3 commits intomasterfrom
errm/deduplicate-tcpconnection-metrics

Conversation

@errm
Copy link
Owner

@errm errm commented Mar 2, 2026

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:port during 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.

@errm errm force-pushed the errm/deduplicate-tcpconnection-metrics branch from 0d3db6b to e8d98cd Compare March 2, 2026 16:51
@errm errm merged commit c34c499 into master Mar 2, 2026
15 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 110 to 114
# 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
`,
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
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.

2 participants