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
- #on_finish(span, _event, _id, payload) ⇒ Object
- #on_start(_span, _event, _id, _payload) ⇒ Object
- #payload_exception(payload) ⇒ Object
- #record_exception(span, payload) ⇒ Object
- #report_if_exception(span, payload) ⇒ Object
- #span_options ⇒ Object
- #subscribe(pattern = nil, span_name = nil, span_options = nil) ⇒ Object
-
#subscribe! ⇒ Object
Publicly exposes protected method ‘subscribe!`.
- #subscription(span_name = nil, span_options = nil, on_start: nil, on_finish: nil, trace: nil) ⇒ Object
- #supported? ⇒ Boolean
- #trace?(_event, _payload) ⇒ Boolean
Instance Method Details
#on_finish(span, _event, _id, payload) ⇒ Object
72 73 74 |
# File 'lib/datadog/tracing/contrib/active_support/notifications/event.rb', line 72 def on_finish(span, _event, _id, payload) record_exception(span, payload) end |
#on_start(_span, _event, _id, _payload) ⇒ Object
70 |
# File 'lib/datadog/tracing/contrib/active_support/notifications/event.rb', line 70 def on_start(_span, _event, _id, _payload); end |
#payload_exception(payload) ⇒ Object
65 66 67 68 |
# File 'lib/datadog/tracing/contrib/active_support/notifications/event.rb', line 65 def payload_exception(payload) payload[:exception_object] || payload[:exception] # Fallback for ActiveSupport < 5.0 end |
#record_exception(span, payload) ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/datadog/tracing/contrib/active_support/notifications/event.rb', line 80 def record_exception(span, payload) if payload[:exception_object] span.set_error(payload[:exception_object]) elsif payload[:exception] # Fallback for ActiveSupport < 5.0 span.set_error(payload[:exception]) end end |
#report_if_exception(span, payload) ⇒ Object
60 61 62 63 |
# File 'lib/datadog/tracing/contrib/active_support/notifications/event.rb', line 60 def report_if_exception(span, payload) exception = payload_exception(payload) span.set_error(payload[:exception]) if exception end |
#span_options ⇒ Object
56 57 58 |
# File 'lib/datadog/tracing/contrib/active_support/notifications/event.rb', line 56 def {} end |
#subscribe(pattern = nil, span_name = nil, span_options = nil) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/datadog/tracing/contrib/active_support/notifications/event.rb', line 39 def subscribe(pattern = nil, span_name = nil, = nil) if supported? super( pattern || event_name, span_name || self.span_name, || self., on_start: method(:on_start), on_finish: method(:on_finish), trace: method(:trace?) ) 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, span_options = nil, on_start: nil, on_finish: nil, trace: nil) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/datadog/tracing/contrib/active_support/notifications/event.rb', line 29 def subscription(span_name = nil, = nil, on_start: nil, on_finish: nil, trace: nil) super( span_name || self.span_name, || self., on_start: on_start, on_finish: on_finish, trace: trace ) end |
#supported? ⇒ Boolean
52 53 54 |
# File 'lib/datadog/tracing/contrib/active_support/notifications/event.rb', line 52 def supported? true end |
#trace?(_event, _payload) ⇒ Boolean
76 77 78 |
# File 'lib/datadog/tracing/contrib/active_support/notifications/event.rb', line 76 def trace?(_event, _payload) true end |