Skip to content

Commit af3dfa8

Browse files
committed
round
1 parent f934870 commit af3dfa8

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"process.runtime.memory": ["rss", "vms"],
4545
"process.runtime.cpu.time": ["user", "system"],
4646
"process.runtime.gc_count": None,
47+
"cpython.gc.collections": None,
4748
"process.runtime.thread_count": None,
4849
"process.runtime.cpu.utilization": None,
4950
"process.runtime.context_switches": ["involuntary", "voluntary"],
@@ -136,6 +137,7 @@
136137
"process.runtime.memory": ["rss", "vms"],
137138
"process.runtime.cpu.time": ["user", "system"],
138139
"process.runtime.gc_count": None,
140+
"cpython.gc.collections": None,
139141
"process.runtime.thread_count": None,
140142
"process.runtime.cpu.utilization": None,
141143
"process.runtime.context_switches": ["involuntary", "voluntary"],
@@ -470,8 +472,15 @@ def _instrument(self, **kwargs: Any):
470472
description=f"Runtime {self._python_implementation} GC count",
471473
unit="By",
472474
)
475+
476+
if "cpython.gc.collections" in self._config:
477+
if self._python_implementation == "pypy":
478+
_logger.warning(
479+
"The cpython.gc.collections metric won't be collected because the interpreter is PyPy"
480+
)
481+
else:
473482
self._meter.create_observable_counter(
474-
name=f"process.runtime.{self._python_implementation}.gc_count",
483+
name="cpython.gc.collections",
475484
callbacks=[self._get_runtime_gc_collections],
476485
description="The number of times a generation was collected since interpreter start.",
477486
unit="{collection}",

instrumentation/opentelemetry-instrumentation-system-metrics/tests/test_system_metrics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def test_system_metrics_instrument(self):
138138
f"process.runtime.{self.implementation}.gc_count",
139139
)
140140
observer_names.append(
141-
f"process.runtime.{self.implementation}.gc_count",
141+
"cpython.gc.collections",
142142
)
143143

144144
self.assertEqual(sorted(metric_names), sorted(observer_names))
@@ -962,7 +962,7 @@ def test_runtime_get_count(self, mock_gc_get_count):
962962
_SystemMetricsResult({"generation": "2"}, 3),
963963
]
964964
self._test_metrics(
965-
f"process.runtime.{self.implementation}.gc_collections",
965+
"cpython.gc.collections",
966966
expected_gc_collections,
967967
)
968968

0 commit comments

Comments
 (0)