def _get_runtime_gc_count(self, observer: metrics.SumObserver) -> None:
        """Observer callback for garbage collection

        Args:
            observer: the observer to update
        """
        for index, count in enumerate(gc.get_count()):
            self._runtime_gc_count_labels["count"] = str(index)
            observer.observe(count, self._runtime_gc_count_labels)
Пример #2
0
    def _get_runtime_cpu_time(self, observer: metrics.SumObserver) -> None:
        """Observer callback for runtime CPU time

        Args:
            observer: the observer to update
        """
        proc_cpu = self._proc.cpu_times()
        for metric in self._config["runtime.cpu.time"]:
            self._runtime_cpu_time_labels["type"] = metric
            observer.observe(
                getattr(proc_cpu, metric),
                self._runtime_cpu_time_labels,
            )
Пример #3
0
    def _get_runtime_memory(self, observer: metrics.SumObserver) -> None:
        """Observer callback for runtime memory

        Args:
            observer: the observer to update
        """
        proc_memory = self._proc.memory_info()
        for metric in self._config["runtime.memory"]:
            self._runtime_memory_labels["type"] = metric
            observer.observe(
                getattr(proc_memory, metric),
                self._runtime_memory_labels,
            )
Пример #4
0
    def _get_system_disk_time(self, observer: metrics.SumObserver) -> None:
        """Observer callback for disk time

        Args:
            observer: the observer to update
        """
        for device, counters in psutil.disk_io_counters(perdisk=True).items():
            for metric in self._config["system.disk.time"]:
                self._system_disk_time_labels["device"] = device
                self._system_disk_time_labels["direction"] = metric
                observer.observe(
                    getattr(counters, "{}_time".format(metric)) / 1000,
                    self._system_disk_time_labels,
                )
    def _get_system_disk_operations(self,
                                    observer: metrics.SumObserver) -> None:
        """Observer callback for disk operations

        Args:
            observer: the observer to update
        """
        for device, counters in psutil.disk_io_counters(perdisk=True).items():
            for metric in self._config["system.disk.operations"]:
                if hasattr(counters, "{}_count".format(metric)):
                    self._system_disk_operations_labels["device"] = device
                    self._system_disk_operations_labels["direction"] = metric
                    observer.observe(
                        getattr(counters, "{}_count".format(metric)),
                        self._system_disk_operations_labels,
                    )
Пример #6
0
    def _get_system_network_io(self, observer: metrics.SumObserver) -> None:
        """Observer callback for network IO

        Args:
            observer: the observer to update
        """

        for device, counters in psutil.net_io_counters(pernic=True).items():
            for metric in self._config["system.network.dropped.packets"]:
                recv_sent = {"receive": "recv", "transmit": "sent"}[metric]
                self._system_network_io_labels["device"] = device
                self._system_network_io_labels["direction"] = metric
                observer.observe(
                    getattr(counters, "bytes_{}".format(recv_sent)),
                    self._system_network_io_labels,
                )
Пример #7
0
    def _get_system_network_errors(self,
                                   observer: metrics.SumObserver) -> None:
        """Observer callback for network errors

        Args:
            observer: the observer to update
        """
        for device, counters in psutil.net_io_counters(pernic=True).items():
            for metric in self._config["system.network.errors"]:
                in_out = {"receive": "in", "transmit": "out"}[metric]
                self._system_network_errors_labels["device"] = device
                self._system_network_errors_labels["direction"] = metric
                observer.observe(
                    getattr(counters, "err{}".format(in_out)),
                    self._system_network_errors_labels,
                )
Пример #8
0
    def _get_system_disk_merged(self, observer: metrics.SumObserver) -> None:
        """Observer callback for disk merged operations

        Args:
            observer: the observer to update
        """

        # FIXME The units in the spec is 1, it seems like it should be
        # operations or the value type should be Double

        for device, counters in psutil.disk_io_counters(perdisk=True).items():
            for metric in self._config["system.disk.time"]:
                self._system_disk_merged_labels["device"] = device
                self._system_disk_merged_labels["direction"] = metric
                observer.observe(
                    getattr(counters, "{}_merged_count".format(metric)),
                    self._system_disk_merged_labels,
                )