Module: Datadog::Tracing::Contrib::ActiveSupport::Notifications::Event::ClassMethods

Defined in:
lib/datadog/tracing/contrib/active_support/notifications/event.rb

Overview

Redefines some class behaviors for a Subscriber to make it a bit simpler for an Event.

Instance Method Summary collapse

Instance Method Details

#payload_exception(payload) ⇒ Object



61
62
63
64
# File 'lib/datadog/tracing/contrib/active_support/notifications/event.rb', line 61

def payload_exception(payload)
  payload[:exception_object] ||
    payload[:exception] # Fallback for ActiveSupport < 5.0
end

#report_if_exception(span, payload) ⇒ Object



56
57
58
59
# File 'lib/datadog/tracing/contrib/active_support/notifications/event.rb', line 56

def report_if_exception(span, payload)
  exception = payload_exception(payload)
  span.set_error(payload[:exception]) if exception
end

#span_optionsObject



52
53
54
# File 'lib/datadog/tracing/contrib/active_support/notifications/event.rb', line 52

def span_options
  {}
end

#subscribe(pattern = nil, span_name = nil, options = nil) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/datadog/tracing/contrib/active_support/notifications/event.rb', line 37

def subscribe(pattern = nil, span_name = nil, options = nil)
  if supported?
    super(
      pattern || event_name,
      span_name || self.span_name,
      options || span_options,
      &method(:process)
    )
  end
end

#subscribe!Object

Publicly exposes protected method ‘subscribe!`



25
26
27
# File 'lib/datadog/tracing/contrib/active_support/notifications/event.rb', line 25

def subscribe! # rubocop:disable Lint/UselessMethodDefinition
  super
end

#subscription(span_name = nil, options = nil) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/datadog/tracing/contrib/active_support/notifications/event.rb', line 29

def subscription(span_name = nil, options = nil)
  super(
    span_name || self.span_name,
    options || span_options,
    &method(:process)
  )
end

#supported?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/datadog/tracing/contrib/active_support/notifications/event.rb', line 48

def supported?
  true
end