Skip to content

Commit fc878a6

Browse files
committed
Log warning on Mac if 'system.network.connections' was added and remove it
1 parent 0e8e68f commit fc878a6

File tree

1 file changed

+10
-0
lines changed
  • instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics

1 file changed

+10
-0
lines changed

instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,16 @@ def __init__(
168168
self._meter = None
169169
self._python_implementation = python_implementation().lower()
170170

171+
# If 'system.network.connections' is found in the config at this time,
172+
# then the user chose to explicitly add it themselves.
173+
# We therefore remove the metric and issue a warning.
174+
if psutil.MACOS and "system.network.connections" in self._config:
175+
_logger.warning(
176+
"'psutil.net_connections' can not reliably be computed on macOS! "
177+
"'system.network.connections' will be excluded from metrics."
178+
)
179+
self._config.pop("system.network.connections")
180+
171181
self._proc = psutil.Process(os.getpid())
172182

173183
self._system_cpu_time_labels = self._labels.copy()

0 commit comments

Comments
 (0)