Class: TIMEx::Telemetry::Adapters::ActiveSupportNotifications

Inherits:
Base
  • Object
show all
Defined in:
lib/timex/telemetry/adapters.rb

Overview

Bridges TIMEx events to ActiveSupport::Notifications.

Constant Summary collapse

EVENT_PREFIX =
"timex."

Instance Method Summary collapse

Methods inherited from Base

#emit

Constructor Details

#initializeActiveSupportNotifications

Returns a new instance of ActiveSupportNotifications.



86
87
88
89
# File 'lib/timex/telemetry/adapters.rb', line 86

def initialize
  super
  require "active_support/notifications"
end

Instance Method Details

#finish(event:, payload:) ⇒ void

This method returns an undefined value.

Parameters:

  • event (Symbol, String)
  • payload (Hash{Symbol => Object})


102
103
104
105
106
107
# File 'lib/timex/telemetry/adapters.rb', line 102

def finish(event:, payload:)
  token = payload.delete(:__asn_token)
  return unless token

  ::ActiveSupport::Notifications.instrumenter.finish_with_state(token, "#{EVENT_PREFIX}#{event}", payload)
end

#start(event:, payload:) ⇒ void

This method returns an undefined value.

Parameters:

  • event (Symbol, String)
  • payload (Hash{Symbol => Object})


94
95
96
97
# File 'lib/timex/telemetry/adapters.rb', line 94

def start(event:, payload:)
  instrumenter = ::ActiveSupport::Notifications.instrumenter
  payload[:__asn_token] = instrumenter.start("#{EVENT_PREFIX}#{event}", payload)
end