Sha256: 4d02d5725870d08159f46b81cfdc6e0c9574f4f76ea5fe966c943a37a2815fe1

Contents?: true

Size: 1.29 KB

Versions: 44

Compression:

Stored size: 1.29 KB

Contents

# (c) Copyright IBM Corp. 2021
# (c) Copyright Instana Inc. 2021

module Instana
  module Instrumentation
    class S3 < Seahorse::Client::Plugin
      class Handler < Seahorse::Client::Handler
        def call(context)
          s3_tags = {
            op: format_operation(context.operation_name),
            bucket: bucket_name_from(context),
            key: key_from_context(context)
          }.reject { |_, v| v.nil? }

          ::Instana.tracer.trace(:s3, {s3: s3_tags}) { @handler.call(context) }
        end

        private

        def bucket_name_from(context)
          context.params[:bucket] || 'Unknown'
        end

        def key_from_context(context)
          context.params[:key]
        end

        def format_operation(name)
          case name
          when :create_bucket
            'createBucket'
          when :delete_bucket
            'deleteBucket'
          when :delete_object
            'delete'
          when :get_object
            'get'
          when :head_object
            'metadata'
          when :list_objects
            'list'
          when :put_object
            'list'
          else
            name.to_s
          end
        end
      end

      def add_handlers(handlers, _config)
        handlers.add(Handler, step: :initialize)
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
instana-1.217.1 lib/instana/instrumentation/aws_sdk_s3.rb
instana-1.217.0 lib/instana/instrumentation/aws_sdk_s3.rb
instana-1.216.0 lib/instana/instrumentation/aws_sdk_s3.rb
instana-1.215.1 lib/instana/instrumentation/aws_sdk_s3.rb
instana-1.215.0 lib/instana/instrumentation/aws_sdk_s3.rb
instana-1.214.4 lib/instana/instrumentation/aws_sdk_s3.rb
instana-1.214.3 lib/instana/instrumentation/aws_sdk_s3.rb
instana-1.214.2 lib/instana/instrumentation/aws_sdk_s3.rb
instana-1.214.1 lib/instana/instrumentation/aws_sdk_s3.rb
instana-1.214.0 lib/instana/instrumentation/aws_sdk_s3.rb
instana-1.213.3 lib/instana/instrumentation/aws_sdk_s3.rb
instana-1.213.2 lib/instana/instrumentation/aws_sdk_s3.rb
instana-1.213.1 lib/instana/instrumentation/aws_sdk_s3.rb
instana-1.213.0 lib/instana/instrumentation/aws_sdk_s3.rb
instana-1.212.0 lib/instana/instrumentation/aws_sdk_s3.rb
instana-1.211.0 lib/instana/instrumentation/aws_sdk_s3.rb
instana-1.210.1 lib/instana/instrumentation/aws_sdk_s3.rb
instana-1.210.0 lib/instana/instrumentation/aws_sdk_s3.rb
instana-1.209.8 lib/instana/instrumentation/aws_sdk_s3.rb
instana-1.209.7 lib/instana/instrumentation/aws_sdk_s3.rb