Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from logging import getLogger
from threading import Lock
from time import time_ns
from typing import Dict, List, Optional, Sequence
from typing import Dict, List, Optional, Sequence, cast

from opentelemetry.metrics import Instrument
from opentelemetry.sdk.metrics._internal.aggregation import (
Expand Down Expand Up @@ -76,10 +76,16 @@ def conflicts(self, other: "_ViewInstrumentMatch") -> bool:
# type since they are functionally equivalent.
and self._aggregation.__class__ == other._aggregation.__class__
)
if not result:
return result

if isinstance(self._aggregation, _SumAggregation):
# if result is True the two aggregation are of the same type
self._aggregation = cast(_SumAggregation, self._aggregation)
other._aggregation = cast(_SumAggregation, other._aggregation)

result = (
result
and self._aggregation._instrument_is_monotonic
self._aggregation._instrument_is_monotonic
== other._aggregation._instrument_is_monotonic
and self._aggregation._instrument_aggregation_temporality
== other._aggregation._instrument_aggregation_temporality
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
Sequence,
Type,
TypeVar,
cast,
)

from opentelemetry.metrics import (
Expand Down Expand Up @@ -968,6 +969,14 @@ def collect(
if scale is None and self._previous_scale is not None:
scale = self._previous_scale

# here self._previous_value_negative and self._previous_value_positive are not Optional anymore
self._previous_value_negative = cast(
Buckets, self._previous_value_negative
)
self._previous_value_positive = cast(
Buckets, self._previous_value_positive
)

min_scale = min(self._previous_scale, scale)

low_positive, high_positive = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ def copy_empty(self) -> "Buckets":
# pylint: disable=protected-access
# pylint: disable=attribute-defined-outside-init
# pylint: disable=invalid-name
copy._Buckets__index_base = self._Buckets__index_base
copy._Buckets__index_start = self._Buckets__index_start
copy._Buckets__index_end = self._Buckets__index_end
copy._Buckets__index_base = self._Buckets__index_base # type: ignore[reportArgumentType]
copy._Buckets__index_start = self._Buckets__index_start # type: ignore[reportArgumentType]
copy._Buckets__index_end = self._Buckets__index_end # type: ignore[reportArgumentType]
copy._counts = [0 for _ in self._counts]

return copy
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,20 @@
# limitations under the License.

from abc import ABC, abstractmethod
from threading import Lock


class Mapping(ABC):
"""
Parent class for `LogarithmMapping` and `ExponentialMapping`.
"""

_mappings: dict[int, "Mapping"]
_mappings_lock: Lock

_min_scale = int
_max_scale = int

# pylint: disable=no-member
def __new__(cls, scale: int):
with cls._mappings_lock:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def collect(
class SynchronousMeasurementConsumer(MeasurementConsumer):
def __init__(
self,
sdk_config: "opentelemetry.sdk.metrics._internal.SdkConfiguration",
sdk_config: "opentelemetry.sdk.metrics._internal.sdk_configuration.SdkConfiguration",
) -> None:
self._lock = Lock()
self._sdk_config = sdk_config
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,8 @@ exclude = [
"opentelemetry-sdk/tests",
"opentelemetry-sdk/src/opentelemetry/sdk/_events",
"opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/__init__.py",
"opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/_view_instrument_match.py",
"opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/aggregation.py",
"opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/exemplar/exemplar_reservoir.py",
"opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/exponential_histogram/",
"opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/export/",
"opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/instrument.py",
"opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/measurement_consumer.py",
Expand Down
Loading