Skip to content

[receiver/hostmetrics] Add system.network.connection.count metric to network scraper#48988

Open
GlqEason wants to merge 1 commit into
open-telemetry:mainfrom
GlqEason:feat/network-connection-metric
Open

[receiver/hostmetrics] Add system.network.connection.count metric to network scraper#48988
GlqEason wants to merge 1 commit into
open-telemetry:mainfrom
GlqEason:feat/network-connection-metric

Conversation

@GlqEason

@GlqEason GlqEason commented Jun 10, 2026

Copy link
Copy Markdown

Description

Add a new metric system.network.connection.count to the network scraper
in hostmetricsreceiver. This metric provides a gauge of ESTABLISHED TCP
connections, grouped by process name, remote address, and remote port.

The metric supports filtering via configuration:

  • include_processes / exclude_processes: filter by process name
  • include_ports / exclude_ports: filter by remote port
  • exclude_localhost: exclude local and loopback remote addresses
  • exclude_listen_ports: exclude connections from local listening ports

New configuration types:

  • ConnectionConfig: connection metric settings under connections
  • ProcessMatchConfig: process name filter with filterset support

Testing

  • TestScrapeNetworkConnectionCountMetric: validates full filter chain
  • TestScrapeNetworkConnectionCountDisabledSkipsDetailLookups: ensures no
      detail lookups when metric is disabled
  • TestScrapeNetworkConnectionsErrorCountsEnabledMetrics: validates partial
      scrape error count
  • TestCreateMetrics_Error: added cases for invalid process filters
  • All 21 existing test cases extended and passing

Documentation

documentation.md auto-generated by mdatagen

…aper

in hostmetricsreceiver. This metric provides a gauge of ESTABLISHED TCP
connections, grouped by process name, remote address, and remote port.

The metric supports filtering via configuration:
- include_processes / exclude_processes: filter by process name
- include_ports / exclude_ports: filter by remote port
- exclude_localhost: exclude local and loopback remote addresses
- exclude_listen_ports: exclude connections from local listening ports

New configuration types:
- ConnectionConfig: connection metric settings under connections
- ProcessMatchConfig: process name filter with filterset support

- TestScrapeNetworkConnectionCountMetric: validates full filter chain
- TestScrapeNetworkConnectionCountDisabledSkipsDetailLookups: ensures no
  detail lookups when metric is disabled
- TestScrapeNetworkConnectionsErrorCountsEnabledMetrics: validates partial
  scrape error count
- TestCreateMetrics_Error: added cases for invalid process filters
- All 21 existing test cases extended and passing

documentation.md auto-generated by mdatagen
@GlqEason GlqEason requested review from a team, braydonk and dmitryax as code owners June 10, 2026 03:36
@github-actions github-actions Bot added the first-time contributor PRs made by new contributors label Jun 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Welcome, contributor! Thank you for your contribution to opentelemetry-collector-contrib.

Important reminders:

  • Read our Contributing Guidelines.
  • Sign the CLA if you haven't already.
  • First-time contributors should have at most one PR not marked as draft until their first PR is merged.
  • If your change isn't one of our priority components, reviews may take more time.
  • Give reviewers at least a few days before pinging them for feedback.
  • If you need help or struggle to move your PR forward:

@github-actions github-actions Bot requested a review from rogercoll June 10, 2026 03:36
@GlqEason GlqEason changed the title Add a new metric system.network.connection.count to the network scr… [receiver/hostmetrics] Add system.network.connection.count metric to network scraper Jun 10, 2026
stability: development
gauge:
value_type: int
attributes: [process.name, server.address, server.port]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems that we are merging 2 levels of metrics, i would suggest removing process name from this metric & via seperate pr introducing a process equivalent of this system metric like we have for other metrics.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It does not collect the data of all processes. only process which start a connection from local OS should be collect.
So if separate process name to create a new metric like system.network.process, That is not my intention.
And currently, there is a processscraper.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Then it becomes a process metric and not system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants