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:

Examples:

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.



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

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.



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

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.



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

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