Class: Instana::Instrumentation::SQS::Handler

Inherits:
Seahorse::Client::Handler
  • Object
show all
Defined in:
lib/instana/instrumentation/aws_sdk_sqs.rb

Constant Summary collapse

SPAN_FORMING_OPERATIONS =
[:send_message, :send_message_batch, :get_queue_url, :create_queue, :delete_message, :delete_message_batch].freeze

Instance Method Summary collapse

Instance Method Details

#call(context) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/instana/instrumentation/aws_sdk_sqs.rb', line 10

def call(context)
  is_tracing = ::Instana.tracer.tracing?
  unless is_tracing && SPAN_FORMING_OPERATIONS.include?(context.operation_name)
    return @handler.call(context)
  end

  span_tags = tags_for(context.operation_name, context.params).reject { |_, v| v.nil? }

  ::Instana.tracer.in_span(:sqs, attributes: {sqs: span_tags}) do |span|
    case context.operation_name
    when :send_message
      inject_instana_headers(span, context.params)
    when :send_message_batch
      context.params[:entries].each { |e| inject_instana_headers(span, e) }
    end

    response = @handler.call(context)

    span_tags[:queue] = response.queue_url if response.respond_to?(:queue_url)
    span.add_attributes(sqs: span_tags)

    response
  end
end