Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
class DefaultMetric(Metric):
"""The default Metric used when no Metric implementation is available."""
def get_handle(self, label_set: LabelSet) -> "DefaultMetricHandle":
"""Gets a `DefaultMetricHandle`.
Args:
label_set: `LabelSet` to associate with the returned handle.
"""
return DefaultMetricHandle()
class Counter(Metric):
"""A counter type metric that expresses the computation of a sum."""
def get_handle(self, label_set: LabelSet) -> "CounterHandle":
"""Gets a `CounterHandle`."""
return CounterHandle()
def add(self, label_set: LabelSet, value: ValueT) -> None:
"""Increases the value of the counter by ``value``.
Args:
label_set: `LabelSet` to associate with the returned handle.
value: The value to add to the counter metric.
"""
class Gauge(Metric):
"""A counter type metric that expresses the computation of a sum."""
def get_handle(self, label_set: LabelSet) -> "CounterHandle":
"""Gets a `CounterHandle`."""
return CounterHandle()
def add(self, label_set: LabelSet, value: ValueT) -> None:
"""Increases the value of the counter by ``value``.
Args:
label_set: `LabelSet` to associate with the returned handle.
value: The value to add to the counter metric.
"""
class Gauge(Metric):
"""A gauge type metric that expresses a pre-calculated value.
Gauge metrics have a value that is either ``Set`` by explicit
instrumentation or observed through a callback. This kind of metric
should be used when the metric cannot be expressed as a sum or because
the measurement interval is arbitrary.
"""
def get_handle(self, label_set: LabelSet) -> "GaugeHandle":
"""Gets a `GaugeHandle`."""
return GaugeHandle()
def set(self, label_set: LabelSet, value: ValueT) -> None:
"""Sets the value of the gauge to ``value``.
Args:
def get_handle(self, label_set: LabelSet) -> "object":
"""Gets a handle, used for repeated-use of metrics instruments.
Handles are useful to reduce the cost of repeatedly recording a metric
with a pre-defined set of label values. All metric kinds (counter,
gauge, measure) support declaring a set of required label keys. The
values corresponding to these keys should be specified in every handle.
"Unspecified" label values, in cases where a handle is requested but
a value was not provided are permitted.
Args:
label_set: `LabelSet` to associate with the returned handle.
"""
class DefaultMetric(Metric):
"""The default Metric used when no Metric implementation is available."""
def get_handle(self, label_set: LabelSet) -> "DefaultMetricHandle":
"""Gets a `DefaultMetricHandle`.
Args:
label_set: `LabelSet` to associate with the returned handle.
"""
return DefaultMetricHandle()
class Counter(Metric):
"""A counter type metric that expresses the computation of a sum."""
def get_handle(self, label_set: LabelSet) -> "CounterHandle":
"""Gets a `CounterHandle`."""
"""
def get_handle(self, label_set: LabelSet) -> "GaugeHandle":
"""Gets a `GaugeHandle`."""
return GaugeHandle()
def set(self, label_set: LabelSet, value: ValueT) -> None:
"""Sets the value of the gauge to ``value``.
Args:
label_set: `LabelSet` to associate with the returned handle.
value: The value to set the gauge metric to.
"""
class Measure(Metric):
"""A measure type metric that represent raw stats that are recorded.
Measure metrics represent raw statistics that are recorded. By
default, measure metrics can accept both positive and negatives.
Negative inputs will be discarded when monotonic is True.
"""
def get_handle(self, label_set: LabelSet) -> "MeasureHandle":
"""Gets a `MeasureHandle` with a float value."""
return MeasureHandle()
def record(self, label_set: LabelSet, value: ValueT) -> None:
"""Records the ``value`` to the measure.
Args:
label_set: `LabelSet` to associate with the returned handle.