sbmt-outbox 6.12.0 → 6.13.0

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: 0b78c4c7a59f68f29949ef958639b1dd6ae9e30026ff30dd9c431f8e17551c7f
4
- data.tar.gz: a2ead04d61fdb3f0ddeb2926f7019566e2c519d89496075c1b2c86b13890a006
3
+ metadata.gz: 47ab689de26112df54d99c701fad3c6f492096173de831fc134318afa91c6662
4
+ data.tar.gz: b11e20111becd1d58cfca72a98d62adeb1b7573c0c093081b086331d90cc7b04
5
5
  SHA512:
6
- metadata.gz: 4d57153ed214e2caceaaf46162fc045213884f7d40ada35880d47c7084bce3b67b0725422838baebc750be024a519ba14217dc28ed8db5944118d9c940bd9cfd
7
- data.tar.gz: ec87e24359bd4aed28bbef3185e0eedb1704dbd032ce4ab12a0c321742a3eecf50d534b6e6866d53c498785cbfc547b73780c2ec7baf5c253fa4e0070856dfd2
6
+ metadata.gz: 6df07282a29bf4468399747b2443965c35bcbc8590bcb5b6613fdad8c255cad9296dfdf9662399617f15ce39cd589e6f022a4da3c8611ee9d712714a10d36fcf
7
+ data.tar.gz: 0f14e1ed6c00ed9fd2c4fd4e9ff225330b507f0a9fbef4c39a32e86eeb0a7bebbf194a2b4040f5b4e2813b8438f27bb78a9a024b16784397ff0fe712143b505f
@@ -116,12 +116,17 @@ module Sbmt
116
116
  delete_statement = Arel::Nodes::DeleteStatement.new
117
117
  delete_statement.relation = table
118
118
  delete_statement.wheres = [table[:id].in(subquery)]
119
+ deleted_count = nil
119
120
 
120
121
  loop do
121
- deleted_count = item_class
122
- .connection
123
- .execute(delete_statement.to_sql)
124
- .cmd_tuples
122
+ track_deleted_latency do
123
+ deleted_count = item_class
124
+ .connection
125
+ .execute(delete_statement.to_sql)
126
+ .cmd_tuples
127
+ end
128
+
129
+ track_deleted_counter(deleted_count)
125
130
 
126
131
  logger.log_info("Deleted #{deleted_count} #{box_type} items for #{box_name} items")
127
132
  break if deleted_count == 0
@@ -158,8 +163,14 @@ module Sbmt
158
163
  end
159
164
 
160
165
  def delete_items_in_batches_mysql(query)
166
+ deleted_count = nil
167
+
161
168
  loop do
162
- deleted_count = query.limit(BATCH_SIZE).delete_all
169
+ track_deleted_latency do
170
+ deleted_count = query.limit(BATCH_SIZE).delete_all
171
+ end
172
+
173
+ track_deleted_counter(deleted_count)
163
174
 
164
175
  logger.log_info("Deleted #{deleted_count} #{box_type} items for #{box_name} items")
165
176
  break if deleted_count == 0
@@ -179,6 +190,22 @@ module Sbmt
179
190
  :unknown
180
191
  end
181
192
  end
193
+
194
+ def track_deleted_counter(deleted_count)
195
+ ::Yabeda
196
+ .outbox
197
+ .deleted_counter
198
+ .increment({box_type: box_type, box_name: box_name}, by: deleted_count)
199
+ end
200
+
201
+ def track_deleted_latency
202
+ ::Yabeda
203
+ .outbox
204
+ .delete_latency
205
+ .measure({box_type: box_type, box_name: box_name}) do
206
+ yield
207
+ end
208
+ end
182
209
  end
183
210
  end
184
211
  end
@@ -43,6 +43,16 @@ Yabeda.configure do
43
43
  unit: :seconds,
44
44
  buckets: [0.5, 1, 2.5, 5, 10, 15, 20, 30, 45, 60, 300].freeze,
45
45
  comment: "A histogram outbox process latency"
46
+
47
+ histogram :delete_latency,
48
+ tags: %i[box_type box_name],
49
+ unit: :seconds,
50
+ buckets: [0.005, 0.01, 0.05, 0.1, 0.25, 0.5, 1, 2, 5, 10, 20, 30].freeze,
51
+ comment: "A histogram for outbox/inbox deletion latency"
52
+
53
+ counter :deleted_counter,
54
+ tags: %i[box_type box_name],
55
+ comment: "A counter for the number of deleted outbox/inbox items"
46
56
  end
47
57
 
48
58
  group :box_worker do
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sbmt
4
4
  module Outbox
5
- VERSION = "6.12.0"
5
+ VERSION = "6.13.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sbmt-outbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.12.0
4
+ version: 6.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sbermarket Ruby-Platform Team