Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
description,
unit,
value_type,
label_keys=label_keys,
enabled=enabled,
monotonic=monotonic,
)
def set(self, label_set: LabelSet, value: metrics_api.ValueT) -> None:
"""See `opentelemetry.metrics.Gauge.set`."""
self.get_handle(label_set).set(value)
UPDATE_FUNCTION = set
class Measure(Metric, metrics_api.Measure):
"""See `opentelemetry.metrics.Measure`.
By default, measure metrics can accept both positive and negatives.
Negative inputs will be discarded when monotonic is True.
"""
HANDLE_TYPE = MeasureHandle
def __init__(
self,
name: str,
description: str,
unit: str,
value_type: Type[metrics_api.ValueT],
label_keys: Sequence[str] = (),
enabled: bool = False,
description,
unit,
value_type,
label_keys=label_keys,
enabled=enabled,
monotonic=monotonic,
)
def add(self, label_set: LabelSet, value: metrics_api.ValueT) -> None:
"""See `opentelemetry.metrics.Counter.add`."""
self.get_handle(label_set).add(value)
UPDATE_FUNCTION = add
class Gauge(Metric, metrics_api.Gauge):
"""See `opentelemetry.metrics.Gauge`.
By default, gauge values can go both up and down (non-monotonic).
Negative inputs will be discarded for monotonic gauge metrics.
"""
HANDLE_TYPE = GaugeHandle
def __init__(
self,
name: str,
description: str,
unit: str,
value_type: Type[metrics_api.ValueT],
label_keys: Sequence[str] = (),
enabled: bool = True,
if not handle:
handle = self.HANDLE_TYPE(
self.value_type, self.enabled, self.monotonic
)
self.handles[label_set] = handle
return handle
def __repr__(self):
return '{}(name="{}", description={})'.format(
type(self).__name__, self.name, self.description
)
UPDATE_FUNCTION = lambda x, y: None # noqa: E731
class Counter(Metric, metrics_api.Counter):
"""See `opentelemetry.metrics.Counter`.
By default, counter values can only go up (monotonic). Negative inputs
will be discarded for monotonic counter metrics. Counter metrics that
have a monotonic option set to False allows negative inputs.
"""
HANDLE_TYPE = CounterHandle
def __init__(
self,
name: str,
description: str,
unit: str,
value_type: Type[metrics_api.ValueT],
label_keys: Sequence[str] = (),