Class: WideEvent::SpanCounterProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/wide_event/span_counter_processor.rb

Overview

Rolls finished dependency child spans up into the active wide event's stats.* attributes: what makes "this request ran 742 queries" visible without opening a trace. Instrumentation scopes map to dependency names via config.span_scopes. Registered by the railtie when OTel is active.

Instance Method Summary collapse

Instance Method Details

#force_flush(timeout: nil) ⇒ Object



21
22
23
# File 'lib/wide_event/span_counter_processor.rb', line 21

def force_flush(timeout: nil)
  OpenTelemetry::SDK::Trace::Export::SUCCESS
end

#on_finish(span) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/wide_event/span_counter_processor.rb', line 9

def on_finish(span)
  return unless WideEvent.active?

  dep = WideEvent.config.span_scopes[span.instrumentation_scope&.name]
  return unless dep

  duration_ms = (span.end_timestamp - span.start_timestamp) / 1_000_000.0
  WideEvent.count(dep, duration_ms.round(2))
rescue StandardError => e
  WideEvent.handle_error(e, "span counter")
end

#on_start(span, parent_context) ⇒ Object



7
# File 'lib/wide_event/span_counter_processor.rb', line 7

def on_start(span, parent_context); end

#shutdown(timeout: nil) ⇒ Object



25
26
27
# File 'lib/wide_event/span_counter_processor.rb', line 25

def shutdown(timeout: nil)
  OpenTelemetry::SDK::Trace::Export::SUCCESS
end