Method: Atatus::Spies::SQSSpy::Ext#send_message

Defined in:
lib/atatus/spies/sqs.rb

#send_message(params = {}, options = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/atatus/spies/sqs.rb', line 66

def send_message(params = {}, options = {})
  unless (transaction = Atatus.current_transaction)
    return super(params, options)
  end

  queue_name = Atatus::Spies::SQSSpy.queue_name(params)
  span_name = queue_name ? "SQS SEND to #{queue_name}" : 'SQS SEND'
  region = Atatus::Spies::SQSSpy.region_from_url(params[:queue_url])
  context = Atatus::Spies::SQSSpy.span_context(
    queue_name,
    region || config.region
  )

  Atatus.with_span(
    span_name,
    TYPE,
    subtype: SUBTYPE,
    action: 'send',
    context: context
  ) do |span|
    trace_context = span&.trace_context || transaction.trace_context
    trace_context.apply_headers do |key, value|
      params[:message_attributes] ||= {}
      params[:message_attributes][key] ||= {}
      params[:message_attributes][key][:string_value] = value
      params[:message_attributes][key][:data_type] = 'String'
    end

    Atatus::Spies::SQSSpy.without_net_http do
      super(params, options)
    end
  end
end