lib/opentelemetry/exporter/otlp/exporter.rb in opentelemetry-exporter-otlp-0.17.0 vs lib/opentelemetry/exporter/otlp/exporter.rb in opentelemetry-exporter-otlp-0.18.0

- old
+ new

@@ -137,11 +137,11 @@ end def send_bytes(bytes, timeout:) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity retry_count = 0 timeout ||= @timeout - start_time = Time.now + start_time = OpenTelemetry::Common::Utilities.timeout_timestamp around_request do # rubocop:disable Metrics/BlockLength request = Net::HTTP::Post.new(@path) request.body = if @compression == 'gzip' request.add_field('Content-Encoding', 'gzip') Zlib.gzip(bytes) @@ -188,10 +188,16 @@ retry if backoff?(retry_count: retry_count += 1, reason: 'timeout') return FAILURE rescue SocketError retry if backoff?(retry_count: retry_count += 1, reason: 'socket_error') return FAILURE + rescue SystemCallError => e + retry if backoff?(retry_count: retry_count += 1, reason: e.class.name) + return FAILURE + rescue EOFError + retry if backoff?(retry_count: retry_count += 1, reason: 'eof_error') + return FAILURE end ensure # Reset timeouts to defaults for the next call. @http.open_timeout = @timeout @http.read_timeout = @timeout @@ -275,17 +281,17 @@ span_id: span_data.span_id, trace_state: span_data.tracestate.to_s, parent_span_id: span_data.parent_span_id == OpenTelemetry::Trace::INVALID_SPAN_ID ? nil : span_data.parent_span_id, name: span_data.name, kind: as_otlp_span_kind(span_data.kind), - start_time_unix_nano: as_otlp_timestamp(span_data.start_timestamp), - end_time_unix_nano: as_otlp_timestamp(span_data.end_timestamp), + start_time_unix_nano: span_data.start_timestamp, + end_time_unix_nano: span_data.end_timestamp, attributes: span_data.attributes&.map { |k, v| as_otlp_key_value(k, v) }, dropped_attributes_count: span_data.total_recorded_attributes - span_data.attributes&.size.to_i, events: span_data.events&.map do |event| Opentelemetry::Proto::Trace::V1::Span::Event.new( - time_unix_nano: as_otlp_timestamp(event.timestamp), + time_unix_nano: event.timestamp, name: event.name, attributes: event.attributes&.map { |k, v| as_otlp_key_value(k, v) } # TODO: track dropped_attributes_count in Span#append_event ) end, @@ -306,13 +312,9 @@ code: status.code == OpenTelemetry::Trace::Status::ERROR ? Opentelemetry::Proto::Trace::V1::Status::StatusCode::UnknownError : Opentelemetry::Proto::Trace::V1::Status::StatusCode::Ok, message: status.description ) end ) - end - - def as_otlp_timestamp(timestamp) - (timestamp.to_r * 1_000_000_000).to_i end def as_otlp_span_kind(kind) case kind when :internal then Opentelemetry::Proto::Trace::V1::Span::SpanKind::INTERNAL