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

To help you get started, we’ve selected a few opentelemetry-sdk 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-sdk / src / opentelemetry / sdk / metrics / __init__.py View on Github external
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,
github open-telemetry / opentelemetry-python / opentelemetry-sdk / src / opentelemetry / sdk / metrics / __init__.py View on Github external
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,
github open-telemetry / opentelemetry-python / opentelemetry-sdk / src / opentelemetry / sdk / metrics / __init__.py View on Github external
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] = (),

opentelemetry-sdk

OpenTelemetry Python SDK

Apache-2.0
Latest version published 3 days ago

Package Health Score

97 / 100
Full package analysis