Sha256: 8bd7bb213063b5edae3d31b562e8c0dcae57780f6b56119b445bfea1fb79926f

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Mnemosyne
  module Probes
    module ActionController
      module Renderers
        CATEGORY = 'render_to_body.renderers.action_controller'.freeze

        class Probe < ::Mnemosyne::Probe
          subscribe CATEGORY

          def setup
            ::ActionController::Base.prepend Instrumentation
          end

          # rubocop:disable Metrics/ParameterLists
          def call(trace, _name, start, finish, _id, _payload)
            start  = ::Mnemosyne::Clock.to_tick(start)
            finish = ::Mnemosyne::Clock.to_tick(finish)

            span = ::Mnemosyne::Span.new 'app.controller.renderers.rails',
              start: start, finish: finish

            trace << span
          end
        end

        module Instrumentation
          def render_to_body(*args, &block)
            ::ActiveSupport::Notifications.instrument CATEGORY do
              super
            end
          end
        end
      end
    end

    register 'ActionController::Base',
      'action_controller/metal/renderers',
      ActionController::Renderers::Probe.new
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mnemosyne-ruby-1.0.1 lib/mnemosyne/probes/action_controller/renderers.rb
mnemosyne-ruby-1.0.0 lib/mnemosyne/probes/action_controller/renderers.rb
mnemosyne-ruby-0.2.0 lib/mnemosyne/probes/action_controller/renderers.rb
mnemosyne-ruby-0.1.0 lib/mnemosyne/probes/action_controller/renderers.rb