Module: Yandex360::Rails
- Defined in:
- lib/yandex360/rails.rb
Overview
The work the Railtie does, kept here as plain methods so it can be tested without booting an application. The Railtie itself is only wiring.
Constant Summary collapse
- EVENT_NAME =
ActiveSupport's own convention is event.library, as in sql.active_record, so an APM recognises this without being told about it.
"request.yandex360"
Class Method Summary collapse
-
.apply_configuration(options, logger: nil) ⇒ Object
Copies config.yandex360 into the gem's own configuration.
-
.bridge_instrumentation(notifications) ⇒ Object
Republishes the gem's events through ActiveSupport::Notifications.
Class Method Details
.apply_configuration(options, logger: nil) ⇒ Object
Copies config.yandex360 into the gem's own configuration. Values left unset in the application are not touched, so the gem's defaults stand.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/yandex360/rails.rb', line 14 def apply_configuration(, logger: nil) Yandex360.configure do |config| Configuration::SETTINGS.each do |setting| value = [setting] config.public_send("#{setting}=", value) unless value.nil? end # Rails already has somewhere for this to go, so use it unless the # application said otherwise. config.logger ||= logger end end |
.bridge_instrumentation(notifications) ⇒ Object
Republishes the gem's events through ActiveSupport::Notifications. Returns the subscriber so a caller can undo it.
29 30 31 32 33 |
# File 'lib/yandex360/rails.rb', line 29 def bridge_instrumentation(notifications) Yandex360.on(:request) do |event| notifications.instrument(EVENT_NAME, event.to_h) end end |