Sha256: ec30849908f92e9ffb6320db72c3c9d06a264bb398cea718a4a178ce4e54980d

Contents?: true

Size: 1.17 KB

Versions: 35

Compression:

Stored size: 1.17 KB

Contents

module Appsignal
  class Hooks
    # @api private
    class ShoryukenMiddleware
      def call(worker_instance, queue, sqs_msg, body)
        metadata = { :queue => queue }.merge(sqs_msg.attributes)
        options = {
          :class => worker_instance.class.name,
          :method => "perform",
          :metadata => metadata
        }

        args = body.is_a?(Hash) ? body : { :params => body }
        options[:params] = Appsignal::Utils::ParamsSanitizer.sanitize args,
          :filter_parameters => Appsignal.config[:filter_parameters]

        if sqs_msg.attributes.key?("SentTimestamp")
          options[:queue_start] = Time.at(sqs_msg.attributes["SentTimestamp"].to_i / 1000)
        end

        Appsignal.monitor_transaction("perform_job.shoryuken", options) do
          yield
        end
      end
    end

    class ShoryukenHook < Appsignal::Hooks::Hook
      register :shoryuken

      def dependencies_present?
        defined?(::Shoryuken)
      end

      def install
        ::Shoryuken.configure_server do |config|
          config.server_middleware do |chain|
            chain.add Appsignal::Hooks::ShoryukenMiddleware
          end
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
appsignal-2.5.3-java lib/appsignal/hooks/shoryuken.rb
appsignal-2.5.3 lib/appsignal/hooks/shoryuken.rb
appsignal-2.5.3.alpha.2 lib/appsignal/hooks/shoryuken.rb
appsignal-2.5.3.alpha.2-java lib/appsignal/hooks/shoryuken.rb
appsignal-2.5.3.alpha.1 lib/appsignal/hooks/shoryuken.rb
appsignal-2.5.3.alpha.1-java lib/appsignal/hooks/shoryuken.rb
appsignal-2.5.2-java lib/appsignal/hooks/shoryuken.rb
appsignal-2.5.2 lib/appsignal/hooks/shoryuken.rb
appsignal-2.5.1-java lib/appsignal/hooks/shoryuken.rb
appsignal-2.5.1 lib/appsignal/hooks/shoryuken.rb
appsignal-2.5.1.beta.1-java lib/appsignal/hooks/shoryuken.rb
appsignal-2.5.1.beta.1 lib/appsignal/hooks/shoryuken.rb
appsignal-2.5.0-java lib/appsignal/hooks/shoryuken.rb
appsignal-2.5.0 lib/appsignal/hooks/shoryuken.rb
appsignal-2.5.0.beta.1-java lib/appsignal/hooks/shoryuken.rb
appsignal-2.5.0.beta.1 lib/appsignal/hooks/shoryuken.rb
appsignal-2.5.0.alpha.1-java lib/appsignal/hooks/shoryuken.rb
appsignal-2.5.0.alpha.1 lib/appsignal/hooks/shoryuken.rb
appsignal-2.4.3 lib/appsignal/hooks/shoryuken.rb
appsignal-2.4.2 lib/appsignal/hooks/shoryuken.rb