Skip to content

Commit

Permalink
Update exception handling for report_result
Browse files Browse the repository at this point in the history
  • Loading branch information
kaylareopelle committed Nov 22, 2023
1 parent 8ef50c1 commit 18c68f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,19 +188,15 @@ def export_batch(batch, timeout: @exporter_timeout_seconds)
report_result(result_code, batch)
result_code
rescue StandardError => e
report_result(FAILURE, batch)
puts e.class
puts e.message
puts e.backtrace
report_result(FAILURE, batch, e)
OpenTelemetry.handle_error(exception: e, message: 'unexpected error in BatchLogRecordProcessor#export_batch')
end

def report_result(result_code, batch)
def report_result(result_code, batch, e = nil)
if result_code == SUCCESS
OpenTelemetry.logger.debug("Successfully exported #{batch.size} log records")
else
OpenTelemetry.handle_error(exception: ExportError.new("Unable to export #{batch.size} log records"))
puts result_code
OpenTelemetry.handle_error(exception: e, message: "Unable to export #{batch.size} log records")
end
end

Expand Down
10 changes: 3 additions & 7 deletions sdk/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,21 +188,17 @@ def export_batch(batch, timeout: @exporter_timeout_seconds)
report_result(result_code, batch)
result_code
rescue StandardError => e
puts e.class
puts e.message
puts e.backtrace
report_result(FAILURE, batch)
report_result(FAILURE, batch, e)
@metrics_reporter.add_to_counter('otel.bsp.error', labels: { 'reason' => e.class.to_s })
FAILURE
end

def report_result(result_code, batch)
def report_result(result_code, batch, e = nil)
if result_code == SUCCESS
@metrics_reporter.add_to_counter('otel.bsp.export.success')
@metrics_reporter.add_to_counter('otel.bsp.exported_spans', increment: batch.size)
else
OpenTelemetry.handle_error(exception: ExportError.new("Unable to export #{batch.size} spans"))
puts result_code
OpenTelemetry.handle_error(exception: e, message: "Unable to export #{batch.size} spans")
@metrics_reporter.add_to_counter('otel.bsp.export.failure')
report_dropped_spans(batch.size, reason: 'export-failure')
end
Expand Down

0 comments on commit 18c68f7

Please sign in to comment.