Class: Datadog::OpenTelemetry::SDK::MetricsExporter

Inherits:
OpenTelemetry::Exporter::OTLP::Metrics::MetricsExporter
  • Object
show all
Defined in:
lib/datadog/opentelemetry/sdk/metrics_exporter.rb

Constant Summary collapse

METRIC_EXPORT_ATTEMPTS =
'otel.metrics_export_attempts'
METRIC_EXPORT_SUCCESSES =
'otel.metrics_export_successes'
METRIC_EXPORT_FAILURES =
'otel.metrics_export_failures'
TELEMETRY_NAMESPACE =
'tracers'
TELEMETRY_TAGS =
{'protocol' => "http", 'encoding' => 'protobuf'}

Instance Method Summary collapse

Instance Method Details

#export(metrics, timeout: nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/datadog/opentelemetry/sdk/metrics_exporter.rb', line 15

def export(metrics, timeout: nil)
  telemetry&.inc(TELEMETRY_NAMESPACE, METRIC_EXPORT_ATTEMPTS, 1, tags: TELEMETRY_TAGS)
  result = super
  metric_name = (result == 0) ? METRIC_EXPORT_SUCCESSES : METRIC_EXPORT_FAILURES
  telemetry&.inc(TELEMETRY_NAMESPACE, metric_name, 1, tags: TELEMETRY_TAGS)
  result
rescue => e
  Datadog.logger.error("Failed to export OpenTelemetry Metrics:  #{e.class}: #{e}")
  telemetry&.inc(TELEMETRY_NAMESPACE, METRIC_EXPORT_FAILURES, 1, tags: TELEMETRY_TAGS)
  raise
end