How to use the opentelemetry-api.src.opentelemetry.metrics.__init__.Metric function in opentelemetry-api

To help you get started, we’ve selected a few opentelemetry-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github open-telemetry / opentelemetry-python / opentelemetry-api / src / opentelemetry / metrics / __init__.py View on Github external
"""


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):
github open-telemetry / opentelemetry-python / opentelemetry-api / src / opentelemetry / metrics / __init__.py View on Github external
"""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:
github open-telemetry / opentelemetry-python / opentelemetry-api / src / opentelemetry / metrics / __init__.py View on Github external
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`."""
github open-telemetry / opentelemetry-python / opentelemetry-api / src / opentelemetry / metrics / __init__.py View on Github external
"""

    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.

opentelemetry-api

OpenTelemetry Python API

Apache-2.0
Latest version published 4 days ago

Package Health Score

97 / 100
Full package analysis