Sha256: 65f734c0804680ffe906b1c91069de910d438e0a7037e446bad087ff131d6fd7

Contents?: true

Size: 967 Bytes

Versions: 12

Compression:

Stored size: 967 Bytes

Contents

# frozen_string_literal: true

require 'aws-sdk-core'
require 'active_support/notifications'

module Aws
  module Rails

    # Instruments client operation calls for ActiveSupport::Notifications
    # Each client operation will produce an event with name:
    # <operation>.<service>.aws
    # @api private
    class Notifications < Seahorse::Client::Plugin

      def add_handlers(handlers, config)
        # This plugin needs to be first
        # which means it is called first in the stack, to start recording time,
        # and returns last
        handlers.add(Handler, step: :initialize, priority: 99)
      end

      class Handler < Seahorse::Client::Handler

        def call(context)
          event_name = "#{context.operation_name}.#{context.config.api.metadata['serviceId']}.aws"
          ActiveSupport::Notifications.instrument(event_name, context: context) do
            @handler.call(context)
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
aws-sdk-rails-3.8.0 lib/aws/rails/notifications.rb
aws-sdk-rails-3.7.1 lib/aws/rails/notifications.rb
aws-sdk-rails-3.7.0 lib/aws/rails/notifications.rb
aws-sdk-rails-3.6.4 lib/aws/rails/notifications.rb
aws-sdk-rails-3.6.3 lib/aws/rails/notifications.rb
aws-sdk-rails-3.6.2 lib/aws/rails/notifications.rb
aws-sdk-rails-3.6.1 lib/aws/rails/notifications.rb
aws-sdk-rails-3.6.0 lib/aws/rails/notifications.rb
aws-sdk-rails-3.5.0 lib/aws/rails/notifications.rb
aws-sdk-rails-3.4.0 lib/aws/rails/notifications.rb
aws-sdk-rails-3.3.0 lib/aws/rails/notifications.rb
aws-sdk-rails-3.2.1 lib/aws/rails/notifications.rb