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.



458
459
460
461
462
# File 'lib/bitfab/otel.rb', line 458

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

Instance Method Details

#export(spans, timeout: nil) ⇒ Object



464
465
466
467
468
469
470
471
472
473
# File 'lib/bitfab/otel.rb', line 464

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



483
484
485
# File 'lib/bitfab/otel.rb', line 483

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

#shutdown(timeout: nil) ⇒ Object



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

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

#take_failed_exportsObject



475
476
477
478
479
480
481
# File 'lib/bitfab/otel.rb', line 475

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