Skip to content

Commit 3e394a4

Browse files
authored
Support PEP 561 to opentelemetry-instrumentation-system-metrics (#3132)
1 parent 16c041e commit 3e394a4

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
([#3100](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3100))
1818
- Add support to database stability opt-in in `_semconv` utilities and add tests
1919
([#3111](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3111))
20+
- `opentelemetry-instrumentation-system-metrics` Add `py.typed` file to enable PEP 561
21+
([#3132](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3132))
2022
- `opentelemetry-opentelemetry-sqlite3` Add `py.typed` file to enable PEP 561
2123
([#3133](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3133))
2224
- `opentelemetry-instrumentation-falcon` add support version to v4

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,18 @@
7676
---
7777
"""
7878

79+
from __future__ import annotations
80+
7981
import gc
8082
import logging
8183
import os
8284
import sys
8385
import threading
8486
from platform import python_implementation
85-
from typing import Collection, Dict, Iterable, List, Optional
87+
from typing import Any, Collection, Iterable
8688

8789
import psutil
8890

89-
# FIXME Remove this pylint disabling line when Github issue is cleared
90-
# pylint: disable=no-name-in-module
9191
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
9292
from opentelemetry.instrumentation.system_metrics.package import _instruments
9393
from opentelemetry.instrumentation.system_metrics.version import __version__
@@ -96,7 +96,7 @@
9696
_logger = logging.getLogger(__name__)
9797

9898

99-
_DEFAULT_CONFIG = {
99+
_DEFAULT_CONFIG: dict[str, list[str] | None] = {
100100
"system.cpu.time": ["idle", "user", "system", "irq"],
101101
"system.cpu.utilization": ["idle", "user", "system", "irq"],
102102
"system.memory.usage": ["used", "free", "cached"],
@@ -129,8 +129,8 @@
129129
class SystemMetricsInstrumentor(BaseInstrumentor):
130130
def __init__(
131131
self,
132-
labels: Optional[Dict[str, str]] = None,
133-
config: Optional[Dict[str, List[str]]] = None,
132+
labels: dict[str, str] | None = None,
133+
config: dict[str, list[str] | None] | None = None,
134134
):
135135
super().__init__()
136136
if config is None:
@@ -176,7 +176,7 @@ def __init__(
176176
def instrumentation_dependencies(self) -> Collection[str]:
177177
return _instruments
178178

179-
def _instrument(self, **kwargs):
179+
def _instrument(self, **kwargs: Any):
180180
# pylint: disable=too-many-branches
181181
meter_provider = kwargs.get("meter_provider")
182182
self._meter = get_meter(
@@ -408,7 +408,7 @@ def _instrument(self, **kwargs):
408408
description="Number of file descriptors in use by the process.",
409409
)
410410

411-
def _uninstrument(self, **__):
411+
def _uninstrument(self, **kwargs: Any):
412412
pass
413413

414414
def _get_open_file_descriptors(

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

Whitespace-only changes.

0 commit comments

Comments
 (0)