Class: Foam::Otel::GuardedSpanProcessor

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

Overview

A tenant span/log processor supplied via additional_* — wrapped so a throwing tenant instance is skipped with a loud warning and breaks neither the app nor foam's export (rule 18 C / rule 9). Never-throw is foam's guarantee for foam-invoked calls; the wrapper enforces it. The wrapper is ALSO the tenant seam's masking point: on_finish/on_emit hand the tenant the masked view above, never the raw item (credential floor, capture-time clause — tenants only ever see the masked view).

Instance Method Summary collapse

Constructor Details

#initialize(inner, config = nil) ⇒ GuardedSpanProcessor

Returns a new instance of GuardedSpanProcessor.



243
244
245
246
# File 'lib/foam/otel/pipelines.rb', line 243

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

Instance Method Details

#force_flush(timeout: nil) ⇒ Object



263
# File 'lib/foam/otel/pipelines.rb', line 263

def force_flush(timeout: nil) = guarded { @inner.force_flush(timeout: timeout) } || OpenTelemetry::SDK::Trace::Export::SUCCESS

#on_finish(span) ⇒ Object



250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/foam/otel/pipelines.rb', line 250

def on_finish(span)
  guarded do
    masked = Foam::Otel::Redaction.mask_span_data(span.to_span_data, @config)
    if masked.nil?
      # Fail closed, loudly (rule 15): a span whose masked view cannot be
      # built is WITHHELD from the tenant, never handed over raw.
      Foam::Otel::Diagnostics.warn("tenant span view masking failed — span withheld from " \
                                   "additional span processor (fail-closed, rule 14)")
    else
      @inner.on_finish(MaskedSpanView.new(span, masked))
    end
  end
end

#on_start(span, context) ⇒ Object



248
# File 'lib/foam/otel/pipelines.rb', line 248

def on_start(span, context) = guarded { @inner.on_start(span, context) }

#shutdown(timeout: nil) ⇒ Object



264
# File 'lib/foam/otel/pipelines.rb', line 264

def shutdown(timeout: nil) = guarded { @inner.shutdown(timeout: timeout) } || OpenTelemetry::SDK::Trace::Export::SUCCESS