Module: OpenTelemetry::SDK::Trace::Export::MetricsReporter

Extended by:
MetricsReporter
Included in:
MetricsReporter
Defined in:
lib/opentelemetry/sdk/trace/export/metrics_reporter.rb

Overview

MetricsReporter defines an interface used for reporting metrics from span processors (like the BatchSpanProcessor) and exporters. It can be used to report metrics such as dropped spans, and successful and failed export attempts. This exists to decouple the Trace SDK from the unstable OpenTelemetry Metrics API. An example implementation in terms of StatsD is:

module MetricsReporter def add_to_counter(metric, increment: 1, labels: {}) StatsD.increment(metric, increment, labels, no_prefix: true) end def record_value(metric, value:, labels: {}) StatsD.distribution(metric, value, labels, no_prefix: true) end def observe_value(metric, value:, labels: {}) StatsD.gauge(metric, value, labels, no_prefix: true) end end

Instance Method Summary collapse

Instance Method Details

#add_to_counter(metric, increment: 1, labels: {}) ⇒ Object

Adds an increment to a metric with the provided labels.

Parameters:

  • metric (String)

    The metric name.

  • increment (optional Numeric) (defaults to: 1)

    An optional increment to report.

  • labels (optional Hash<String, String>) (defaults to: {})

    Optional labels to associate with the metric.



38
# File 'lib/opentelemetry/sdk/trace/export/metrics_reporter.rb', line 38

def add_to_counter(metric, increment: 1, labels: {}); end

#observe_value(metric, value:, labels: {}) ⇒ Object

Observes a value for a metric with the provided labels.

Parameters:

  • metric (String)

    The metric name.

  • value (Numeric)

    The value to observe.

  • labels (optional Hash<String, String>) (defaults to: {})

    Optional labels to associate with the metric.



54
# File 'lib/opentelemetry/sdk/trace/export/metrics_reporter.rb', line 54

def observe_value(metric, value:, labels: {}); end

#record_value(metric, value:, labels: {}) ⇒ Object

Records a value for a metric with the provided labels.

Parameters:

  • metric (String)

    The metric name.

  • value (Numeric)

    The value to report.

  • labels (optional Hash<String, String>) (defaults to: {})

    Optional labels to associate with the metric.



46
# File 'lib/opentelemetry/sdk/trace/export/metrics_reporter.rb', line 46

def record_value(metric, value:, labels: {}); end