Class: Foam::Otel::SessionStitching::SpanProcessor
- Inherits:
-
Object
- Object
- Foam::Otel::SessionStitching::SpanProcessor
- Defined in:
- lib/foam/otel/session_stitching.rb
Overview
Stamps session baggage onto every span at START (attributes freeze at finish — GOTCHAS F1 — so on_start is the only safe write point).
Instance Method Summary collapse
- #force_flush(timeout: nil) ⇒ Object
- #on_finish(span) ⇒ Object
- #on_start(span, parent_context) ⇒ Object
- #shutdown(timeout: nil) ⇒ Object
Instance Method Details
#force_flush(timeout: nil) ⇒ Object
72 |
# File 'lib/foam/otel/session_stitching.rb', line 72 def force_flush(timeout: nil) = OpenTelemetry::SDK::Trace::Export::SUCCESS |
#on_finish(span) ⇒ Object
70 |
# File 'lib/foam/otel/session_stitching.rb', line 70 def on_finish(span); end |
#on_start(span, parent_context) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/foam/otel/session_stitching.rb', line 54 def on_start(span, parent_context) stamp = SessionStitching.session_attributes(parent_context) return if stamp.empty? # Fill-only (fleet uniformity with js/python): an app-set session.id # is never overwritten by the baggage value. existing = (span.instance_variable_defined?(:@attributes) && span.instance_variable_get(:@attributes)) || {} stamp.each do |key, value| span.set_attribute(key, value) unless existing.key?(key) end rescue StandardError, SystemStackError nil end |
#shutdown(timeout: nil) ⇒ Object
73 |
# File 'lib/foam/otel/session_stitching.rb', line 73 def shutdown(timeout: nil) = OpenTelemetry::SDK::Trace::Export::SUCCESS |