Module: Atatus::Spies::SQSSpy::Ext Private

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

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(mod) ⇒ 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.



65
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/atatus/spies/sqs.rb', line 65

def self.prepended(mod)
  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

  def send_message_batch(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_BATCH to #{queue_name}" : 'SQS SEND_BATCH'
    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_batch',
      context: context
    ) do |span|
      trace_context = span&.trace_context || transaction.trace_context

      trace_context.apply_headers do |key, value|
        params[:entries].each do |message|
          message[:message_attributes] ||= {}
          message[:message_attributes][key] ||= {}
          message[:message_attributes][key][:string_value] = value
          message[:message_attributes][key][:data_type] = 'String'
        end
      end

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

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

    queue_name = Atatus::Spies::SQSSpy.queue_name(params)
    span_name =
      queue_name ? "SQS RECEIVE from #{queue_name}" : 'SQS RECEIVE'
    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: 'receive',
      context: context
    ) do
      Atatus::Spies::SQSSpy.without_net_http do
        super(params, options)
      end
    end
  end

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

    queue_name = Atatus::Spies::SQSSpy.queue_name(params)
    span_name = queue_name ? "SQS DELETE from #{queue_name}" : 'SQS DELETE'
    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: 'delete',
      context: context
    ) do
      Atatus::Spies::SQSSpy.without_net_http do
        super(params, options)
      end
    end
  end

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

    queue_name = Atatus::Spies::SQSSpy.queue_name(params)
    span_name =
      queue_name ? "SQS DELETE_BATCH from #{queue_name}" : 'SQS DELETE_BATCH'
    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: 'delete_batch',
      context: context
    ) do
      Atatus::Spies::SQSSpy.without_net_http do
        super(params, options)
      end
    end
  end
end

Instance Method Details

#delete_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.



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/atatus/spies/sqs.rb', line 165

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

  queue_name = Atatus::Spies::SQSSpy.queue_name(params)
  span_name = queue_name ? "SQS DELETE from #{queue_name}" : 'SQS DELETE'
  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: 'delete',
    context: context
  ) do
    Atatus::Spies::SQSSpy.without_net_http do
      super(params, options)
    end
  end
end

#delete_message_batch(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.



191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/atatus/spies/sqs.rb', line 191

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

  queue_name = Atatus::Spies::SQSSpy.queue_name(params)
  span_name =
    queue_name ? "SQS DELETE_BATCH from #{queue_name}" : 'SQS DELETE_BATCH'
  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: 'delete_batch',
    context: context
  ) do
    Atatus::Spies::SQSSpy.without_net_http do
      super(params, options)
    end
  end
end

#receive_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.



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/atatus/spies/sqs.rb', line 138

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

  queue_name = Atatus::Spies::SQSSpy.queue_name(params)
  span_name =
    queue_name ? "SQS RECEIVE from #{queue_name}" : 'SQS RECEIVE'
  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: 'receive',
    context: context
  ) do
    Atatus::Spies::SQSSpy.without_net_http do
      super(params, options)
    end
  end
end

#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

#send_message_batch(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.



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/atatus/spies/sqs.rb', line 100

def send_message_batch(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_BATCH to #{queue_name}" : 'SQS SEND_BATCH'
  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_batch',
    context: context
  ) do |span|
    trace_context = span&.trace_context || transaction.trace_context

    trace_context.apply_headers do |key, value|
      params[:entries].each do |message|
        message[:message_attributes] ||= {}
        message[:message_attributes][key] ||= {}
        message[:message_attributes][key][:string_value] = value
        message[:message_attributes][key][:data_type] = 'String'
      end
    end

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