apm_bro 0.1.14 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@ module ApmBro
6
6
 
7
7
  def self.subscribe!
8
8
  install_redis_instrumentation!
9
- rescue StandardError
9
+ rescue
10
10
  # Never raise from instrumentation install
11
11
  end
12
12
 
@@ -25,7 +25,7 @@ module ApmBro
25
25
  # Only instrument if Redis::Client actually has the call method
26
26
  # Check both public and private methods
27
27
  has_call = ::Redis::Client.instance_methods(false).include?(:call) ||
28
- ::Redis::Client.private_instance_methods(false).include?(:call)
28
+ ::Redis::Client.private_instance_methods(false).include?(:call)
29
29
  return unless has_call
30
30
 
31
31
  mod = Module.new do
@@ -41,7 +41,7 @@ module ApmBro
41
41
  end
42
42
  else
43
43
  # If not tracking, just pass through unchanged
44
- super(*args, &block)
44
+ super
45
45
  end
46
46
  end
47
47
 
@@ -63,7 +63,6 @@ module ApmBro
63
63
  return yield unless Thread.current[RedisSubscriber::THREAD_LOCAL_KEY]
64
64
 
65
65
  start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
66
- result = nil
67
66
  error = nil
68
67
  begin
69
68
  result = yield
@@ -90,7 +89,7 @@ module ApmBro
90
89
  if Thread.current[RedisSubscriber::THREAD_LOCAL_KEY]
91
90
  Thread.current[RedisSubscriber::THREAD_LOCAL_KEY] << event
92
91
  end
93
- rescue StandardError
92
+ rescue
94
93
  end
95
94
  end
96
95
  end
@@ -99,7 +98,6 @@ module ApmBro
99
98
  return yield unless Thread.current[RedisSubscriber::THREAD_LOCAL_KEY]
100
99
 
101
100
  start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
102
- result = nil
103
101
  begin
104
102
  result = yield
105
103
  result
@@ -119,7 +117,7 @@ module ApmBro
119
117
  if Thread.current[RedisSubscriber::THREAD_LOCAL_KEY]
120
118
  Thread.current[RedisSubscriber::THREAD_LOCAL_KEY] << event
121
119
  end
122
- rescue StandardError
120
+ rescue
123
121
  end
124
122
  end
125
123
  end
@@ -128,7 +126,6 @@ module ApmBro
128
126
  return yield unless Thread.current[RedisSubscriber::THREAD_LOCAL_KEY]
129
127
 
130
128
  start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
131
- result = nil
132
129
  begin
133
130
  result = yield
134
131
  result
@@ -148,7 +145,7 @@ module ApmBro
148
145
  if Thread.current[RedisSubscriber::THREAD_LOCAL_KEY]
149
146
  Thread.current[RedisSubscriber::THREAD_LOCAL_KEY] << event
150
147
  end
151
- rescue StandardError
148
+ rescue
152
149
  end
153
150
  end
154
151
  end
@@ -157,39 +154,41 @@ module ApmBro
157
154
  parts = Array(command).map(&:to_s)
158
155
  command_name = parts.first&.upcase
159
156
  key = parts[1]
160
- args_count = parts.length > 1 ? parts.length - 1 : 0
157
+ args_count = (parts.length > 1) ? parts.length - 1 : 0
161
158
 
162
159
  {
163
160
  command: safe_command(command_name),
164
161
  key: safe_key(key),
165
162
  args_count: args_count
166
163
  }
167
- rescue StandardError
168
- { command: nil, key: nil, args_count: nil }
164
+ rescue
165
+ {command: nil, key: nil, args_count: nil}
169
166
  end
170
167
 
171
168
  def safe_command(cmd)
172
169
  return nil if cmd.nil?
173
170
  cmd.to_s[0, 20]
174
- rescue StandardError
171
+ rescue
175
172
  nil
176
173
  end
177
174
 
178
175
  def safe_key(key)
179
176
  return nil if key.nil?
180
177
  s = key.to_s
181
- s.length > 200 ? s[0, 200] + "…" : s
182
- rescue StandardError
178
+ (s.length > 200) ? s[0, 200] + "…" : s
179
+ rescue
183
180
  nil
184
181
  end
185
182
 
186
183
  def safe_db(db)
187
- Integer(db) rescue nil
184
+ Integer(db)
185
+ rescue
186
+ nil
188
187
  end
189
188
  end
190
189
 
191
190
  ::Redis::Client.prepend(mod) unless ::Redis::Client.ancestors.include?(mod)
192
- rescue StandardError
191
+ rescue
193
192
  # Redis::Client may not be available or may have different structure
194
193
  end
195
194
 
@@ -204,7 +203,7 @@ module ApmBro
204
203
  event = build_event(name, data, duration_ms)
205
204
  Thread.current[THREAD_LOCAL_KEY] << event if event
206
205
  end
207
- rescue StandardError
206
+ rescue
208
207
  end
209
208
  end
210
209
  end
@@ -221,7 +220,7 @@ module ApmBro
221
220
 
222
221
  def self.build_event(name, data, duration_ms)
223
222
  cmd = extract_command(data)
224
- base = {
223
+ {
225
224
  event: name.to_s,
226
225
  command: cmd[:command],
227
226
  key: cmd[:key],
@@ -229,22 +228,21 @@ module ApmBro
229
228
  duration_ms: duration_ms,
230
229
  db: safe_db(data[:db])
231
230
  }
232
- base
233
- rescue StandardError
231
+ rescue
234
232
  nil
235
233
  end
236
234
 
237
235
  def self.extract_command(data)
238
- return { command: nil, key: nil, args_count: nil } unless data.is_a?(Hash)
236
+ return {command: nil, key: nil, args_count: nil} unless data.is_a?(Hash)
239
237
 
240
- if data[:command]
241
- parts = Array(data[:command]).map(&:to_s)
238
+ parts = if data[:command]
239
+ Array(data[:command]).map(&:to_s)
242
240
  elsif data[:commands]
243
- parts = Array(data[:commands]).flatten.map(&:to_s)
241
+ Array(data[:commands]).flatten.map(&:to_s)
244
242
  elsif data[:cmd]
245
- parts = Array(data[:cmd]).map(&:to_s)
243
+ Array(data[:cmd]).map(&:to_s)
246
244
  else
247
- parts = []
245
+ []
248
246
  end
249
247
 
250
248
  command_name = parts.first&.upcase
@@ -256,30 +254,29 @@ module ApmBro
256
254
  key: safe_key(key),
257
255
  args_count: args_count
258
256
  }
259
- rescue StandardError
260
- { command: nil, key: nil, args_count: nil }
257
+ rescue
258
+ {command: nil, key: nil, args_count: nil}
261
259
  end
262
260
 
263
261
  def self.safe_command(cmd)
264
262
  return nil if cmd.nil?
265
- s = cmd.to_s[0, 20]
266
- s
267
- rescue StandardError
263
+ cmd.to_s[0, 20]
264
+ rescue
268
265
  nil
269
266
  end
270
267
 
271
268
  def self.safe_key(key)
272
269
  return nil if key.nil?
273
270
  s = key.to_s
274
- s.length > 200 ? s[0, 200] + "…" : s
275
- rescue StandardError
271
+ (s.length > 200) ? s[0, 200] + "…" : s
272
+ rescue
276
273
  nil
277
274
  end
278
275
 
279
276
  def self.safe_db(db)
280
- Integer(db) rescue nil
277
+ Integer(db)
278
+ rescue
279
+ nil
281
280
  end
282
281
  end
283
282
  end
284
-
285
-