Class: Foam::Otel::RedactingLogRecordExporter

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

Instance Method Summary collapse

Constructor Details

#initialize(inner, config) ⇒ RedactingLogRecordExporter

Returns a new instance of RedactingLogRecordExporter.



66
67
68
69
# File 'lib/foam/otel/redacting_exporter.rb', line 66

def initialize(inner, config)
  @inner = inner
  @config = config
end

Instance Method Details

#export(log_record_data, timeout: nil) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/foam/otel/redacting_exporter.rb', line 71

def export(log_record_data, timeout: nil)
  batch = log_record_data.to_a
  masked = batch.filter_map { |lrd| Redaction.mask_log_record_data(lrd, @config) }
  dropped = batch.length - masked.length
  if dropped.positive?
    Diagnostics.warn("redaction failed for #{dropped} log record(s) — dropped rather than " \
                     "exported unmasked (rule 14 fail-closed)")
    @inner.export(masked, timeout: timeout) unless masked.empty?
    return OpenTelemetry::SDK::Logs::Export::FAILURE
  end
  @inner.export(masked, timeout: timeout)
rescue StandardError, SystemStackError
  Diagnostics.warn("log redaction raised past its guards — batch dropped (fail-closed, rule 14/15)")
  OpenTelemetry::SDK::Logs::Export::FAILURE
end

#force_flush(timeout: nil) ⇒ Object



87
# File 'lib/foam/otel/redacting_exporter.rb', line 87

def force_flush(timeout: nil) = @inner.force_flush(timeout: timeout)

#shutdown(timeout: nil) ⇒ Object



88
# File 'lib/foam/otel/redacting_exporter.rb', line 88

def shutdown(timeout: nil) = @inner.shutdown(timeout: timeout)