Class: Labkit::Tracing::Rails::ActionView::Subscriber

Inherits:
Object
  • Object
show all
Includes:
TracingCommon
Defined in:
lib/labkit/tracing/rails/action_view/subscriber.rb

Overview

ActionView bridges action view notifications to the distributed tracing subsystem

Constant Summary collapse

RENDER_TEMPLATE_NOTIFICATION_TOPIC =
"render_template.action_view"
RENDER_COLLECTION_NOTIFICATION_TOPIC =
"render_collection.action_view"
RENDER_PARTIAL_NOTIFICATION_TOPIC =
"render_partial.action_view"

Class Method Summary collapse

Class Method Details

.instrumentObject

Instruments Rails ActionView events for opentracing. Returns a lambda, which, when called will unsubscribe from the notifications



18
19
20
21
22
23
24
25
26
# File 'lib/labkit/tracing/rails/action_view/subscriber.rb', line 18

def self.instrument
  subscriptions = [
    ::ActiveSupport::Notifications.subscribe(RENDER_TEMPLATE_NOTIFICATION_TOPIC, RenderTemplateInstrumenter.new),
    ::ActiveSupport::Notifications.subscribe(RENDER_COLLECTION_NOTIFICATION_TOPIC, RenderCollectionInstrumenter.new),
    ::ActiveSupport::Notifications.subscribe(RENDER_PARTIAL_NOTIFICATION_TOPIC, RenderPartialInstrumenter.new),
  ]

  create_unsubscriber subscriptions
end