Class: Foam::Otel::BeforeSend::SpanExporter
- Inherits:
-
Object
- Object
- Foam::Otel::BeforeSend::SpanExporter
- Defined in:
- lib/foam/otel/before_send.rb
Overview
The span-side wrapper (composition over the redacting exporter, same wrap-never-subclass posture as redacting_exporter.rb: only the public export/force_flush/shutdown contract the batch processors call).
Instance Method Summary collapse
- #export(span_data, timeout: nil) ⇒ Object
- #force_flush(timeout: nil) ⇒ Object
-
#initialize(inner, config) ⇒ SpanExporter
constructor
A new instance of SpanExporter.
- #shutdown(timeout: nil) ⇒ Object
Constructor Details
#initialize(inner, config) ⇒ SpanExporter
Returns a new instance of SpanExporter.
227 228 229 230 |
# File 'lib/foam/otel/before_send.rb', line 227 def initialize(inner, config) @inner = inner @hooks = config.before_send end |
Instance Method Details
#export(span_data, timeout: nil) ⇒ Object
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/foam/otel/before_send.rb', line 232 def export(span_data, timeout: nil) batch = span_data.to_a faults = [] kept = batch.filter_map do |sd| result = BeforeSend.run(@hooks, sd, :span, faults) result.equal?(ERROR) ? nil : result end # ONE aggregated warn per batch (the redacting exporters' # convention) — class names only, never messages/values. unless faults.empty? Diagnostics.warn("before_send faulted for #{faults.length} span record(s) — dropped, never " \ "exported half-transformed (fail-closed, rule 14): #{faults.uniq.take(3).join(', ')}") end status = kept.empty? ? OpenTelemetry::SDK::Trace::Export::SUCCESS : @inner.export(kept, timeout: timeout) faults.empty? ? status : OpenTelemetry::SDK::Trace::Export::FAILURE rescue StandardError, SystemStackError # Fail closed past the per-record guards, loudly (rule 15) — # never raise into the batch thread. Diagnostics.warn("before_send pass raised past its guards — span batch dropped (fail-closed, rule 14/15)") OpenTelemetry::SDK::Trace::Export::FAILURE end |
#force_flush(timeout: nil) ⇒ Object
254 |
# File 'lib/foam/otel/before_send.rb', line 254 def force_flush(timeout: nil) = @inner.force_flush(timeout: timeout) |
#shutdown(timeout: nil) ⇒ Object
255 |
# File 'lib/foam/otel/before_send.rb', line 255 def shutdown(timeout: nil) = @inner.shutdown(timeout: timeout) |