API refactor
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-10-07 16:25:52 +09:00
parent 76d0d86211
commit 91c7e04474
1171 changed files with 81940 additions and 44117 deletions

View File

@@ -1,4 +1,4 @@
from typing import Dict, NamedTuple, Optional, Union
from typing import Dict, NamedTuple, Optional, Sequence, Union
class Timestamp:
@@ -28,7 +28,16 @@ class Timestamp:
return not self == other
def __gt__(self, other: "Timestamp") -> bool:
return self.sec > other.sec or self.nsec > other.nsec
return self.nsec > other.nsec if self.sec == other.sec else self.sec > other.sec
def __lt__(self, other: "Timestamp") -> bool:
return self.nsec < other.nsec if self.sec == other.sec else self.sec < other.sec
# BucketSpan is experimental and subject to change at any time.
class BucketSpan(NamedTuple):
offset: int
length: int
# Timestamp and exemplar are optional.
@@ -42,9 +51,24 @@ class Exemplar(NamedTuple):
timestamp: Optional[Union[float, Timestamp]] = None
# NativeHistogram is experimental and subject to change at any time.
class NativeHistogram(NamedTuple):
count_value: float
sum_value: float
schema: int
zero_threshold: float
zero_count: float
pos_spans: Optional[Sequence[BucketSpan]] = None
neg_spans: Optional[Sequence[BucketSpan]] = None
pos_deltas: Optional[Sequence[int]] = None
neg_deltas: Optional[Sequence[int]] = None
nh_exemplars: Optional[Sequence[Exemplar]] = None
class Sample(NamedTuple):
name: str
labels: Dict[str, str]
value: float
timestamp: Optional[Union[float, Timestamp]] = None
exemplar: Optional[Exemplar] = None
native_histogram: Optional[NativeHistogram] = None