Sha256: fd1f1d660f83cd3232e0e1e873c5b6083e2c4e9b14fe14b09667e3ba0f19c405

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

module Mnemosyne
  module Probes
    module Responder
      module Respond
        class Probe < ::Mnemosyne::Probe
          subscribe 'respond.responders.mnemosyne'

          def setup
            ::ActionController::Responder.prepend \
              ::Mnemosyne::Probes::Responder::Respond::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.responder.respond',
              start: start, finish: finish

            trace << span
          end
        end

        module Instrumentation
          def respond
            ::ActiveSupport::Notifications.instrument \
              'respond.responders.mnemosyne' do

              super
            end
          end
        end
      end
    end

    register 'ActionController::Responder',
      'action_controller/responder',
      Responder::Respond::Probe.new
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mnemosyne-ruby-1.0.1 lib/mnemosyne/probes/responder/respond.rb
mnemosyne-ruby-1.0.0 lib/mnemosyne/probes/responder/respond.rb
mnemosyne-ruby-0.2.0 lib/mnemosyne/probes/responder/respond.rb
mnemosyne-ruby-0.1.0 lib/mnemosyne/probes/responder/respond.rb