Skip to content

Commit

Permalink
Add more documentation (open-telemetry#2641)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl authored Apr 26, 2022
1 parent 24ac96e commit ebdc101
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
4 changes: 3 additions & 1 deletion opentelemetry-api/src/opentelemetry/_metrics/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,12 @@ def __init__(


class Synchronous(Instrument):
pass
"""Base class for all synchronous instruments"""


class Asynchronous(Instrument):
"""Base class for all asynchronous instruments"""

@abstractmethod
def __init__(
self,
Expand Down
2 changes: 2 additions & 0 deletions opentelemetry-sdk/src/opentelemetry/sdk/_metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@


class Meter(APIMeter):
"""See `opentelemetry._metrics.Meter`."""

def __init__(
self,
instrumentation_scope: InstrumentationScope,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@


class MetricExportResult(Enum):
"""Result of exporting a metric
Can be any of the following values:"""

SUCCESS = 0
FAILURE = 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@

@dataclass(frozen=True)
class Measurement:
"""
Represents a data point reported via the metrics API to the SDK.
"""

value: Union[int, float]
instrument: "_Instrument"
attributes: Attributes = None
16 changes: 16 additions & 0 deletions opentelemetry-sdk/src/opentelemetry/sdk/_metrics/point.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,22 @@


class AggregationTemporality(IntEnum):
"""
The temporality to use when aggregating data.
Can be one of the following values:
"""

UNSPECIFIED = 0
DELTA = 1
CUMULATIVE = 2


@dataclass(frozen=True)
class Sum:
"""Represents the type of a scalar metric that is calculated as a sum of
all reported measurements over a time interval."""

aggregation_temporality: AggregationTemporality
is_monotonic: bool
start_time_unix_nano: int
Expand All @@ -39,12 +48,19 @@ class Sum:

@dataclass(frozen=True)
class Gauge:
"""Represents the type of a scalar metric that always exports the current
value for every data point. It should be used for an unknown
aggregation."""

time_unix_nano: int
value: Union[int, float]


@dataclass(frozen=True)
class Histogram:
"""Represents the type of a metric that is calculated by aggregating as a
histogram of all reported measurements over a time interval."""

aggregation_temporality: AggregationTemporality
bucket_counts: Sequence[int]
explicit_bounds: Sequence[float]
Expand Down

0 comments on commit ebdc101

Please sign in to comment.