Class: Bitfab::Otel::DeliveryTrackingExporter

Inherits:
Object
  • Object
show all
Defined in:
lib/bitfab/otel.rb

Overview

Records failed exports so a flush can report delivery, not just drain.

Instance Method Summary collapse

Constructor Details

#initialize(exporter) ⇒ DeliveryTrackingExporter

Returns a new instance of DeliveryTrackingExporter.



485
486
487
488
489
# File 'lib/bitfab/otel.rb', line 485

def initialize(exporter)
  @exporter = exporter
  @mutex = Mutex.new
  @failed_exports = 0
end

Instance Method Details

#export(spans, timeout: nil) ⇒ Object



491
492
493
494
495
496
497
498
499
500
# File 'lib/bitfab/otel.rb', line 491

def export(spans, timeout: nil)
  result = begin
    @exporter.export(spans, timeout:)
  rescue
    @mutex.synchronize { @failed_exports += 1 }
    raise
  end
  @mutex.synchronize { @failed_exports += 1 } unless result == SUCCESS
  result
end

#force_flush(timeout: nil) ⇒ Object



510
511
512
# File 'lib/bitfab/otel.rb', line 510

def force_flush(timeout: nil)
  @exporter.force_flush(timeout:)
end

#shutdown(timeout: nil) ⇒ Object



514
515
516
# File 'lib/bitfab/otel.rb', line 514

def shutdown(timeout: nil)
  @exporter.shutdown(timeout:)
end

#take_failed_exportsObject



502
503
504
505
506
507
508
# File 'lib/bitfab/otel.rb', line 502

def take_failed_exports
  @mutex.synchronize do
    failed = @failed_exports
    @failed_exports = 0
    failed
  end
end