Module: OpenLoam::Telemetry
- Defined in:
- lib/open_loam/telemetry.rb
Overview
A dependency-free observability seam (L-712). Wrap a unit of work in a span;
by default it emits an ActiveSupport::Notifications event
("open_loam.span.
OpenLoam::Telemetry.backend = ->(name, attributes, work) do
Tracer.in_span(name, attributes: attributes) { work.call }
end
OpenLoam instruments its async/background hot paths (scheduler tick, durable event delivery, inbound webhook ingest) so an operator sees them without wiring anything per-call.
Class Method Summary collapse
- .backend ⇒ Object
- .backend=(callable) ⇒ Object
- .reset! ⇒ Object
-
.span(name, **attributes, &block) ⇒ Object
Run
blockas a span namednamewithattributes.
Class Method Details
.backend ⇒ Object
31 32 33 |
# File 'lib/open_loam/telemetry.rb', line 31 def backend @backend end |
.backend=(callable) ⇒ Object
35 36 37 |
# File 'lib/open_loam/telemetry.rb', line 35 def backend=(callable) @backend = callable end |
.reset! ⇒ Object
39 40 41 |
# File 'lib/open_loam/telemetry.rb', line 39 def reset! @backend = nil end |
.span(name, **attributes, &block) ⇒ Object
Run block as a span named name with attributes. Returns the block's
value. A nil/absent block is a no-op that returns nil.
21 22 23 24 25 26 27 28 29 |
# File 'lib/open_loam/telemetry.rb', line 21 def span(name, **attributes, &block) return block&.call unless block_given? if backend backend.call(name.to_s, attributes, block) else ActiveSupport::Notifications.instrument("open_loam.span.#{name}", **attributes, &block) end end |