mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-30 21:56:07 +08:00
Support PEP 561 to opentelemetry-instrumentation-system-metrics
(#3132)
This commit is contained in:

committed by
GitHub

parent
16c041e22b
commit
3e394a4814
@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
([#3100](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3100))
|
||||
- Add support to database stability opt-in in `_semconv` utilities and add tests
|
||||
([#3111](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3111))
|
||||
- `opentelemetry-instrumentation-system-metrics` Add `py.typed` file to enable PEP 561
|
||||
([#3132](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3132))
|
||||
- `opentelemetry-opentelemetry-sqlite3` Add `py.typed` file to enable PEP 561
|
||||
([#3133](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3133))
|
||||
- `opentelemetry-instrumentation-falcon` add support version to v4
|
||||
|
@ -76,18 +76,18 @@ API
|
||||
---
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import gc
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import threading
|
||||
from platform import python_implementation
|
||||
from typing import Collection, Dict, Iterable, List, Optional
|
||||
from typing import Any, Collection, Iterable
|
||||
|
||||
import psutil
|
||||
|
||||
# FIXME Remove this pylint disabling line when Github issue is cleared
|
||||
# pylint: disable=no-name-in-module
|
||||
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
||||
from opentelemetry.instrumentation.system_metrics.package import _instruments
|
||||
from opentelemetry.instrumentation.system_metrics.version import __version__
|
||||
@ -96,7 +96,7 @@ from opentelemetry.metrics import CallbackOptions, Observation, get_meter
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
_DEFAULT_CONFIG = {
|
||||
_DEFAULT_CONFIG: dict[str, list[str] | None] = {
|
||||
"system.cpu.time": ["idle", "user", "system", "irq"],
|
||||
"system.cpu.utilization": ["idle", "user", "system", "irq"],
|
||||
"system.memory.usage": ["used", "free", "cached"],
|
||||
@ -129,8 +129,8 @@ if sys.platform == "darwin":
|
||||
class SystemMetricsInstrumentor(BaseInstrumentor):
|
||||
def __init__(
|
||||
self,
|
||||
labels: Optional[Dict[str, str]] = None,
|
||||
config: Optional[Dict[str, List[str]]] = None,
|
||||
labels: dict[str, str] | None = None,
|
||||
config: dict[str, list[str] | None] | None = None,
|
||||
):
|
||||
super().__init__()
|
||||
if config is None:
|
||||
@ -176,7 +176,7 @@ class SystemMetricsInstrumentor(BaseInstrumentor):
|
||||
def instrumentation_dependencies(self) -> Collection[str]:
|
||||
return _instruments
|
||||
|
||||
def _instrument(self, **kwargs):
|
||||
def _instrument(self, **kwargs: Any):
|
||||
# pylint: disable=too-many-branches
|
||||
meter_provider = kwargs.get("meter_provider")
|
||||
self._meter = get_meter(
|
||||
@ -408,7 +408,7 @@ class SystemMetricsInstrumentor(BaseInstrumentor):
|
||||
description="Number of file descriptors in use by the process.",
|
||||
)
|
||||
|
||||
def _uninstrument(self, **__):
|
||||
def _uninstrument(self, **kwargs: Any):
|
||||
pass
|
||||
|
||||
def _get_open_file_descriptors(
|
||||
|
Reference in New Issue
Block a user