lib/opentelemetry/exporter/otlp/exporter.rb in opentelemetry-exporter-otlp-0.26.3 vs lib/opentelemetry/exporter/otlp/exporter.rb in opentelemetry-exporter-otlp-0.27.0
- old
+ new
@@ -242,11 +242,11 @@
value: duration_ms,
labels: { 'status' => response&.code || 'unknown' })
end
end
- def backoff?(retry_count:, reason:, retry_after: nil) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
+ def backoff?(retry_count:, reason:, retry_after: nil) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
@metrics_reporter.add_to_counter('otel.otlp_exporter.failure', labels: { 'reason' => reason })
return false if retry_count > RETRY_COUNT
sleep_interval = nil
unless retry_after.nil?
@@ -269,10 +269,11 @@
sleep(sleep_interval)
true
end
def encode(span_data) # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
+ start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
Opentelemetry::Proto::Collector::Trace::V1::ExportTraceServiceRequest.encode(
Opentelemetry::Proto::Collector::Trace::V1::ExportTraceServiceRequest.new(
resource_spans: span_data
.group_by(&:resource)
.map do |resource, span_datas|
@@ -296,9 +297,14 @@
)
)
rescue StandardError => e
OpenTelemetry.handle_error(exception: e, message: 'unexpected error in OTLP::Exporter#encode')
nil
+ ensure
+ stop = Process.clock_gettime(Process::CLOCK_MONOTONIC)
+ duration_ms = 1000.0 * (stop - start)
+ @metrics_reporter.record_value('otel.otlp_exporter.encode_duration',
+ value: duration_ms)
end
def as_otlp_span(span_data) # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
Opentelemetry::Proto::Trace::V1::Span.new(
trace_id: span_data.trace_id,