aboutsummaryrefslogtreecommitdiff
path: root/.venv/lib/python3.12/site-packages/opentelemetry/sdk/util/__init__.pyi
blob: 55042fcf0ee1412aac21491ee6df30daa40962dd (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import (
    Iterable,
    Iterator,
    Mapping,
    MutableMapping,
    Sequence,
    TypeVar,
    overload,
)

from opentelemetry.util.types import AttributesAsKey, AttributeValue

_T = TypeVar("_T")
_KT = TypeVar("_KT")
_VT = TypeVar("_VT")

def ns_to_iso_str(nanoseconds: int) -> str: ...
def get_dict_as_key(
    labels: Mapping[str, AttributeValue],
) -> AttributesAsKey: ...

# pylint: disable=no-self-use
class BoundedList(Sequence[_T]):
    """An append only list with a fixed max size.

    Calls to `append` and `extend` will drop the oldest elements if there is
    not enough room.
    """

    dropped: int
    def __init__(self, maxlen: int): ...
    def insert(self, index: int, value: _T) -> None: ...
    @overload
    def __getitem__(self, i: int) -> _T: ...
    @overload
    def __getitem__(self, s: slice) -> Sequence[_T]: ...
    def __len__(self) -> int: ...
    def append(self, item: _T) -> None: ...
    def extend(self, seq: Sequence[_T]) -> None: ...
    @classmethod
    def from_seq(cls, maxlen: int, seq: Iterable[_T]) -> BoundedList[_T]: ...  # pylint: disable=undefined-variable

class BoundedDict(MutableMapping[_KT, _VT]):
    """An ordered dict with a fixed max capacity.

    Oldest elements are dropped when the dict is full and a new element is
    added.
    """

    dropped: int
    def __init__(self, maxlen: int): ...
    def __getitem__(self, k: _KT) -> _VT: ...
    def __setitem__(self, k: _KT, v: _VT) -> None: ...
    def __delitem__(self, v: _KT) -> None: ...
    def __iter__(self) -> Iterator[_KT]: ...
    def __len__(self) -> int: ...
    @classmethod
    def from_map(
        cls, maxlen: int, mapping: Mapping[_KT, _VT]
    ) -> BoundedDict[_KT, _VT]: ...  # pylint: disable=undefined-variable