|
17 | 17 | OpenTelemetry Base Instrumentor
|
18 | 18 | """
|
19 | 19 |
|
| 20 | +from __future__ import annotations |
| 21 | + |
20 | 22 | from abc import ABC, abstractmethod
|
21 | 23 | from logging import getLogger
|
22 |
| -from typing import Collection, Optional |
| 24 | +from typing import Any, Collection |
23 | 25 |
|
24 | 26 | from opentelemetry.instrumentation._semconv import (
|
25 | 27 | _OpenTelemetrySemanticConventionStability,
|
|
33 | 35 |
|
34 | 36 |
|
35 | 37 | class BaseInstrumentor(ABC):
|
36 |
| - """An ABC for instrumentors |
| 38 | + """An ABC for instrumentors. |
37 | 39 |
|
38 | 40 | Child classes of this ABC should instrument specific third
|
39 | 41 | party libraries or frameworks either by using the
|
@@ -74,18 +76,18 @@ def instrumentation_dependencies(self) -> Collection[str]:
|
74 | 76 | is present in the environment.
|
75 | 77 | """
|
76 | 78 |
|
77 |
| - def _instrument(self, **kwargs): |
| 79 | + def _instrument(self, **kwargs: Any): |
78 | 80 | """Instrument the library"""
|
79 | 81 |
|
80 | 82 | @abstractmethod
|
81 |
| - def _uninstrument(self, **kwargs): |
| 83 | + def _uninstrument(self, **kwargs: Any): |
82 | 84 | """Uninstrument the library"""
|
83 | 85 |
|
84 |
| - def _check_dependency_conflicts(self) -> Optional[DependencyConflict]: |
| 86 | + def _check_dependency_conflicts(self) -> DependencyConflict | None: |
85 | 87 | dependencies = self.instrumentation_dependencies()
|
86 | 88 | return get_dependency_conflicts(dependencies)
|
87 | 89 |
|
88 |
| - def instrument(self, **kwargs): |
| 90 | + def instrument(self, **kwargs: Any): |
89 | 91 | """Instrument the library
|
90 | 92 |
|
91 | 93 | This method will be called without any optional arguments by the
|
@@ -117,7 +119,7 @@ def instrument(self, **kwargs):
|
117 | 119 | self._is_instrumented_by_opentelemetry = True
|
118 | 120 | return result
|
119 | 121 |
|
120 |
| - def uninstrument(self, **kwargs): |
| 122 | + def uninstrument(self, **kwargs: Any): |
121 | 123 | """Uninstrument the library
|
122 | 124 |
|
123 | 125 | See ``BaseInstrumentor.instrument`` for more information regarding the
|
|
0 commit comments