sbmt-outbox 6.9.0 → 6.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d1f4fc3cdedb0f5965cd7f6300aa6ac3535053d94b62dd0b6fb440d542edc4c
4
- data.tar.gz: 0bc0039248269d121d003a8175469a316bf87c55b9331765c21b3a2fb7f954b9
3
+ metadata.gz: 563533826523f381bff35759aecedd3f1b5ed4e20067725e7f28d0a94808ab89
4
+ data.tar.gz: 3a974ff0df4cf3a771888b521d33e9d5b5df367973b9a43fc6dfd4f6418caed0
5
5
  SHA512:
6
- metadata.gz: 18d8a5e96cb13869f08fd91ee1f2581cc738d1fe5df7b4532503537d246fa37a15c074db87b7f9e8fe6895c0fc495467eabe9563c5923e0c2220459bde744566
7
- data.tar.gz: e15f6f2c0d1bc1b6c6b54e6702dc35a928e124d826d74f1f5fee274d43336db5866a9db6bab3c107354fff8dbdf26a8e89626dfeb66c3e9407de48b456350525
6
+ metadata.gz: 4af541b2e8db7fa1fec41071caf150a1df4e973a1f93bfc2491288d0d4fe69a49d20cc9ebd96dcb378d0b6cc381baef68b8dbd5cfde8fdb062730125fdcac120
7
+ data.tar.gz: 8274526f2a1c4fa433a20787ef14b07b83de4d11fa5d87f9ba30c7639bbb1396d4ae0fcec6d07493336d050ff757324e9bf88d14495e1ac803c1bf074a71734b
@@ -11,7 +11,7 @@ module Sbmt
11
11
 
12
12
  METRICS_COUNTERS = %i[error_counter retry_counter sent_counter fetch_error_counter discarded_counter].freeze
13
13
 
14
- delegate :log_success, :log_failure, to: "Sbmt::Outbox.logger"
14
+ delegate :log_success, :log_info, :log_failure, to: "Sbmt::Outbox.logger"
15
15
  delegate :item_process_middlewares, to: "Sbmt::Outbox"
16
16
  delegate :box_type, :box_name, :owner, to: :item_class
17
17
 
@@ -73,7 +73,7 @@ module Sbmt
73
73
  end
74
74
 
75
75
  unless item.for_processing?
76
- log_error("already processed")
76
+ log_info("already processed")
77
77
  counters[:fetch_error_counter] += 1
78
78
  return Failure(:already_processed)
79
79
  end
@@ -154,7 +154,7 @@ module Sbmt
154
154
  # rubocop:enable Metrics/MethodLength
155
155
 
156
156
  def track_failed(ex_or_msg, item = nil)
157
- log_error(ex_or_msg, item)
157
+ log_processing_error(ex_or_msg, item)
158
158
 
159
159
  item&.touch_processed_at
160
160
  item&.add_error(ex_or_msg)
@@ -170,6 +170,8 @@ module Sbmt
170
170
  counters[:retry_counter] += 1
171
171
  item.pending!
172
172
  end
173
+ rescue => e
174
+ log_error_handling_error(e, item)
173
175
  end
174
176
 
175
177
  def track_successed(item)
@@ -196,18 +198,28 @@ module Sbmt
196
198
  counters[:discarded_counter] += 1
197
199
  end
198
200
 
199
- def log_error(ex_or_msg, item = nil)
201
+ def log_processing_error(ex_or_msg, item = nil)
200
202
  text = format_exception_error(ex_or_msg)
201
203
 
202
204
  msg = "Failed processing #{box_type} item with error: #{text}.\n" \
203
205
  "Record: #{item_class.name}##{item_id}.\n" \
204
206
  "#{item&.log_details&.to_json}"
205
207
 
206
- log_failure(msg, backtrace: format_backtrace(ex_or_msg))
208
+ log_failure(msg, stacktrace: format_backtrace(ex_or_msg))
207
209
  end
208
210
 
209
- def format_exception_error(e)
210
- text = if e.respond_to?(:cause) && !e.cause.nil?
211
+ def log_error_handling_error(handling_error, item = nil)
212
+ text = format_exception_error(handling_error, extract_cause: false)
213
+
214
+ msg = "Could not persist status of failed #{box_type} item due to error: #{text}.\n" \
215
+ "Record: #{item_class.name}##{item_id}.\n" \
216
+ "#{item&.log_details&.to_json}"
217
+
218
+ log_failure(msg, stacktrace: format_backtrace(handling_error))
219
+ end
220
+
221
+ def format_exception_error(e, extract_cause: true)
222
+ text = if extract_cause && e.respond_to?(:cause) && !e.cause.nil?
211
223
  "#{format_exception_error(e.cause)}. "
212
224
  else
213
225
  ""
@@ -28,7 +28,9 @@ module Sbmt
28
28
  extracted_context = ::OpenTelemetry.propagation.extract(item_options_headers)
29
29
  ::OpenTelemetry::Context.with_current(extracted_context) do
30
30
  tracer.in_span(span_name(item_class), attributes: span_attributes.compact, kind: :consumer) do
31
- yield
31
+ Sbmt::Outbox.logger.with_tags(trace_id: trace_id) do
32
+ yield
33
+ end
32
34
  end
33
35
  end
34
36
  end
@@ -42,6 +44,12 @@ module Sbmt
42
44
  def span_name(item_class)
43
45
  "#{item_class.box_type}/#{item_class.box_name} process item"
44
46
  end
47
+
48
+ def trace_id
49
+ context = ::OpenTelemetry::Trace.current_span.context
50
+
51
+ context.valid? ? context.hex_trace_id : nil
52
+ end
45
53
  end
46
54
  end
47
55
  end
@@ -16,7 +16,6 @@ module Sbmt
16
16
 
17
17
  # transaction will be nil if sentry tracing is not enabled
18
18
  transaction = start_transaction(scope, job)
19
- job.log_tags[:trace_id] = scope&.tags&.[](:trace_id)
20
19
 
21
20
  begin
22
21
  yield
@@ -218,7 +218,7 @@ module Sbmt
218
218
 
219
219
  logger.log_error(
220
220
  "Failed processing #{job.resource_key} with error: #{e.class} #{e.message}",
221
- backtrace: backtrace
221
+ stacktrace: backtrace
222
222
  )
223
223
  end
224
224
 
@@ -134,7 +134,7 @@ module Sbmt
134
134
 
135
135
  logger.log_error(
136
136
  "Failed processing #{task} with error: #{e.class} #{e.message}",
137
- backtrace: backtrace
137
+ stacktrace: backtrace
138
138
  )
139
139
  end
140
140
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sbmt
4
4
  module Outbox
5
- VERSION = "6.9.0"
5
+ VERSION = "6.10.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sbmt-outbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.9.0
4
+ version: 6.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sbermarket Ruby-Platform Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-13 00:00:00.000000000 Z
11
+ date: 2024-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool