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.



395
396
397
398
399
# File 'lib/bitfab/otel.rb', line 395

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

Instance Method Details

#export(spans, timeout: nil) ⇒ Object



401
402
403
404
405
406
407
408
409
410
# File 'lib/bitfab/otel.rb', line 401

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



420
421
422
# File 'lib/bitfab/otel.rb', line 420

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

#shutdown(timeout: nil) ⇒ Object



424
425
426
# File 'lib/bitfab/otel.rb', line 424

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

#take_failed_exportsObject



412
413
414
415
416
417
418
# File 'lib/bitfab/otel.rb', line 412

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