Sha256: 1e42be55361b6d544c1abc78236ea304bca5943664c4bbc6f2c932994e196b67

Contents?: true

Size: 1.2 KB

Versions: 144

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

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::HashSanitizer.sanitize(
          args,
          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

144 entries across 144 versions & 1 rubygems

Version Path
appsignal-2.8.4.beta.1 lib/appsignal/hooks/shoryuken.rb
appsignal-2.8.4.beta.1-java lib/appsignal/hooks/shoryuken.rb
appsignal-2.8.3 lib/appsignal/hooks/shoryuken.rb
appsignal-2.8.3-java lib/appsignal/hooks/shoryuken.rb
appsignal-2.8.3.beta.1 lib/appsignal/hooks/shoryuken.rb
appsignal-2.8.3.beta.1-java lib/appsignal/hooks/shoryuken.rb
appsignal-2.8.2 lib/appsignal/hooks/shoryuken.rb
appsignal-2.8.2-java lib/appsignal/hooks/shoryuken.rb
appsignal-2.8.1 lib/appsignal/hooks/shoryuken.rb
appsignal-2.8.1-java lib/appsignal/hooks/shoryuken.rb
appsignal-2.8.1.alpha.1-java lib/appsignal/hooks/shoryuken.rb
appsignal-2.8.1.alpha.1 lib/appsignal/hooks/shoryuken.rb
appsignal-2.8.0 lib/appsignal/hooks/shoryuken.rb
appsignal-2.8.0-java lib/appsignal/hooks/shoryuken.rb
appsignal-2.7.3.beta.2-java lib/appsignal/hooks/shoryuken.rb
appsignal-2.7.3.beta.2 lib/appsignal/hooks/shoryuken.rb
appsignal-2.7.3.beta.1 lib/appsignal/hooks/shoryuken.rb
appsignal-2.7.3.beta.1-java lib/appsignal/hooks/shoryuken.rb
appsignal-2.7.2-java lib/appsignal/hooks/shoryuken.rb
appsignal-2.7.2 lib/appsignal/hooks/shoryuken.rb