Skip to content
Open
8 changes: 3 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

- Add type hints to SDK resources
([#4360](https://github.com/open-telemetry/opentelemetry-python/pull/4360))
- Add `attributes` field in `metrics.get_meter` wrapper function
([#4364](https://github.com/open-telemetry/opentelemetry-python/pull/4364))
- Add Python 3.13 support
Expand Down Expand Up @@ -279,7 +281,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Version 1.21.0/0.42b0 (2023-11-01)

- Fix `SumAggregation`
([#3390](https://github.com/open-telemetry/opentelemetry-python/pull/3390))
([#3390](https://github.com/open-telemetry/opentelemetry-python/pull/3390))
- Fix handling of empty metric collection cycles
([#3335](https://github.com/open-telemetry/opentelemetry-python/pull/3335))
- Fix error when no LoggerProvider configured for LoggingHandler
Expand All @@ -299,7 +301,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Implement Process Resource detector
([#3472](https://github.com/open-telemetry/opentelemetry-python/pull/3472))


## Version 1.20.0/0.41b0 (2023-09-04)

- Modify Prometheus exporter to translate non-monotonic Sums into Gauges
Expand Down Expand Up @@ -328,7 +329,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Default LogRecord observed_timestamp to current timestamp
[#3377](https://github.com/open-telemetry/opentelemetry-python/pull/3377))


## Version 1.18.0/0.39b0 (2023-05-19)

- Select histogram aggregation with an environment variable
Expand All @@ -348,7 +348,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add benchmark tests for metrics
([#3267](https://github.com/open-telemetry/opentelemetry-python/pull/3267))


## Version 1.17.0/0.38b0 (2023-03-22)

- Implement LowMemory temporality
Expand Down Expand Up @@ -1696,7 +1695,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Remove dependency on 'backoff' library
([#3679](https://github.com/open-telemetry/opentelemetry-python/pull/3679))


- Make create_gauge non-abstract method
([#3817](https://github.com/open-telemetry/opentelemetry-python/pull/3817))
- Make `tracer.start_as_current_span()` decorator work with async functions
Expand Down
8 changes: 4 additions & 4 deletions opentelemetry-api/src/opentelemetry/context/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def _load_runtime_context() -> _RuntimeContext:

try:
return next( # type: ignore
iter( # type: ignore
entry_points( # type: ignore
iter(
entry_points(
group="opentelemetry_context",
name=configured_context,
)
Expand All @@ -55,8 +55,8 @@ def _load_runtime_context() -> _RuntimeContext:
default_context,
)
return next( # type: ignore
iter( # type: ignore
entry_points( # type: ignore
iter(
entry_points(
group="opentelemetry_context",
name=default_context,
)
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-api/src/opentelemetry/propagate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ def inject(
try:
propagators.append( # type: ignore
next( # type: ignore
iter( # type: ignore
entry_points( # type: ignore
iter(
entry_points(
group="opentelemetry_propagator",
name=propagator,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# FIXME: Use importlib.metadata when support for 3.11 is dropped if the rest of
# the supported versions at that time have the same API.
from importlib_metadata import ( # type: ignore
from importlib.metadata import (
Distribution,
EntryPoint,
EntryPoints,
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-api/src/opentelemetry/util/_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def _load_provider(

return cast(
Provider,
next( # type: ignore
iter( # type: ignore
entry_points( # type: ignore
next(
iter(
entry_points(
group=f"opentelemetry_{provider}",
name=provider_name,
)
Expand Down
23 changes: 12 additions & 11 deletions opentelemetry-sdk/src/opentelemetry/sdk/error_handler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def _handle(self, error: Exception, *args, **kwargs):

from abc import ABC, abstractmethod
from logging import getLogger
from typing import Optional
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather prefer to use from __future__ import annotations on the top of the imports, and use pipe (|) annotation.


from opentelemetry.util._importlib_metadata import entry_points

Expand All @@ -69,7 +70,7 @@ def _handle(self, error: Exception, *args, **kwargs):

class ErrorHandler(ABC):
@abstractmethod
def _handle(self, error: Exception, *args, **kwargs):
def _handle(self, error: Exception, *args, **kwargs) -> None: # type: ignore
"""
Handle an exception
"""
Expand All @@ -83,7 +84,7 @@ class _DefaultErrorHandler(ErrorHandler):
"""

# pylint: disable=useless-return
def _handle(self, error: Exception, *args, **kwargs):
def _handle(self, error: Exception, *args, **kwargs) -> None: # type: ignore
logger.exception("Error handled by default error handler: ")
return None

Expand All @@ -105,12 +106,12 @@ def __new__(cls) -> "GlobalErrorHandler":

return cls._instance

def __enter__(self):
def __enter__(self) -> None:
pass

# pylint: disable=no-self-use
def __exit__(self, exc_type, exc_value, traceback):
if exc_value is None:
def __exit__(self, exc_type, exc_value, traceback) -> Optional[bool]: # type: ignore
if exc_value is None: # type: ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If above applied, the ignore is not needed.

Suggested change
if exc_value is None: # type: ignore
if exc_value is None:

return None

plugin_handled = False
Expand All @@ -120,11 +121,11 @@ def __exit__(self, exc_type, exc_value, traceback):
)

for error_handler_entry_point in error_handler_entry_points:
error_handler_class = error_handler_entry_point.load()
error_handler_class = error_handler_entry_point.load() # type: ignore

if issubclass(error_handler_class, exc_value.__class__):
if issubclass(error_handler_class, exc_value.__class__): # type: ignore
try:
error_handler_class()._handle(exc_value)
error_handler_class()._handle(exc_value) # type: ignore
plugin_handled = True

# pylint: disable=broad-exception-caught
Expand All @@ -133,11 +134,11 @@ def __exit__(self, exc_type, exc_value, traceback):
"%s error while handling error"
" %s by error handler %s",
error_handling_error.__class__.__name__,
exc_value.__class__.__name__,
error_handler_class.__name__,
exc_value.__class__.__name__, # type: ignore
error_handler_class.__name__, # type: ignore
)

if not plugin_handled:
_DefaultErrorHandler()._handle(exc_value)
_DefaultErrorHandler()._handle(exc_value) # type: ignore

return True
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def collect(self, point_attributes: Attributes) -> Optional[Exemplar]:
{
k: v
for k, v in self.__attributes.items()
if k not in point_attributes
if k not in point_attributes # type: ignore
}
if self.__attributes
else None
Expand Down Expand Up @@ -162,8 +162,8 @@ class BucketIndexError(ValueError):
class FixedSizeExemplarReservoirABC(ExemplarReservoir):
"""Abstract class for a reservoir with fixed size."""

def __init__(self, size: int, **kwargs) -> None:
super().__init__(**kwargs)
def __init__(self, size: int, **kwargs) -> None: # type: ignore
super().__init__(**kwargs) # type: ignore
self._size: int = size
self._reservoir_storage: Mapping[int, ExemplarBucket] = defaultdict(
ExemplarBucket
Expand Down Expand Up @@ -257,8 +257,8 @@ class SimpleFixedSizeExemplarReservoir(FixedSizeExemplarReservoirABC):
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#simplefixedsizeexemplarreservoir
"""

def __init__(self, size: int = 1, **kwargs) -> None:
super().__init__(size, **kwargs)
def __init__(self, size: int = 1, **kwargs) -> None: # type: ignore
super().__init__(size, **kwargs) # type: ignore
self._measurements_seen: int = 0

def _reset(self) -> None:
Expand Down Expand Up @@ -292,8 +292,8 @@ class AlignedHistogramBucketExemplarReservoir(FixedSizeExemplarReservoirABC):
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#alignedhistogrambucketexemplarreservoir
"""

def __init__(self, boundaries: Sequence[float], **kwargs) -> None:
super().__init__(len(boundaries) + 1, **kwargs)
def __init__(self, boundaries: Sequence[float], **kwargs) -> None: # type: ignore
super().__init__(len(boundaries) + 1, **kwargs) # type: ignore
self._boundaries: Sequence[float] = boundaries

def offer(
Expand Down