Skip to content

Commit

Permalink
Added the logger to warn users process.runtime.gc_count won't be coll…
Browse files Browse the repository at this point in the history
…ected in case of PyPy
  • Loading branch information
rahulhacker authored Oct 24, 2023
1 parent 979d793 commit dbee3a1
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@

import gc
import os
import logging
import threading
from platform import python_implementation
from typing import Collection, Dict, Iterable, List, Optional
Expand All @@ -91,6 +92,9 @@
from opentelemetry.metrics import CallbackOptions, Observation, get_meter
from opentelemetry.sdk.util import get_dict_as_key

logger = logging.getLogger(__name__)


_DEFAULT_CONFIG = {
"system.cpu.time": ["idle", "user", "system", "irq"],
"system.cpu.utilization": ["idle", "user", "system", "irq"],
Expand Down Expand Up @@ -351,6 +355,9 @@ def _instrument(self, **kwargs):
)

if "process.runtime.gc_count" in self._config and self._python_implementation != "pypy":
logger.warning(
"The process.runtime.gc_count metric won't be collected because the interpreter is PyPy"
)
self._meter.create_observable_counter(
name=f"process.runtime.{self._python_implementation}.gc_count",
callbacks=[self._get_runtime_gc_count],
Expand Down

0 comments on commit dbee3a1

Please sign in to comment.