logbrew-sdk 0.1.13 → 0.1.15

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f4065e8e726690a78d3b682ba49d4c35d931e4e81619ea2ff11a4170f4572cc
4
- data.tar.gz: 29252ab423d8a184ed96724a76d57aafca1fd4008c383df86f44721eb6b511cf
3
+ metadata.gz: 0f1a43a336fe87e460238a865dd71006b99975d8dda5eea4556d3b7857ce7b8e
4
+ data.tar.gz: 6900c3207bebf800d0c41f9fb6784af6a5051f6afa2a6bf586f8ff5c9eef49f4
5
5
  SHA512:
6
- metadata.gz: 972aaa22ee930144da4508ce6a80e3e149a6b1cdad744178e3c5056349c43974b7681769d1b2338ce318547de5fefc6122d6c9066481858698e3d54a954603a4
7
- data.tar.gz: 0c7acd8d564f9bda21ce4b44d541e6b4d3417eb3afd46adb57487ed6802a72953ecd19449a0c8f8546f01bc7315c63731e949e87376091737e89beb58d2b082a
6
+ metadata.gz: b8249769684d6d9ed2177867a5cde11f1f7ca977218c9d4b2d2d43704d54e0c38e0d0d1307f271f72003db5d2e8cb3c55094c34fcb4f940f10794ab92346a069
7
+ data.tar.gz: 972b7ed436cdedf8c29fec9bf75d2a2c0c73cddc5e1d3dbacbf88b7e7c9a9ffc8e6b253b93a975a60d9bca8052c0833bc3adac007ca4a09c0a5aa8a321256198
data/README.md CHANGED
@@ -23,7 +23,7 @@ needed:
23
23
 
24
24
  ```ruby
25
25
  # Gemfile
26
- gem "logbrew-sdk", "~> 0.1.13"
26
+ gem "logbrew-sdk", "~> 0.1.15"
27
27
  ```
28
28
 
29
29
  ```bash
@@ -47,7 +47,7 @@ module LogBrew
47
47
  end
48
48
 
49
49
  @instrumentation.send(:capture_span, self, error)
50
- @instrumentation.send(:capture_terminal_issue, self) if error && terminal_failure && !cancellation?(error)
50
+ @instrumentation.send(:capture_terminal_issue, self, error) if error && terminal_failure && !cancellation?(error)
51
51
  rescue StandardError => capture_error
52
52
  @instrumentation.send(:report_capture_error, capture_error)
53
53
  end
@@ -79,20 +79,22 @@ module LogBrew
79
79
  }
80
80
  end
81
81
 
82
- def issue_attributes
83
- {
84
- "title" => "Sidekiq job failed",
85
- "level" => "error",
86
- "metadata" => {
87
- "source" => @source,
88
- "sampled" => @context.sampled,
89
- "retryCount" => @retry_count + 1
90
- }
82
+ def issue_attributes(error)
83
+ exception_type = IssueDiagnostics.safe_exception_type(error)
84
+ frame = IssueDiagnostics.stack_frames_from_exception(error).first
85
+ metadata = {
86
+ "source" => @source,
87
+ "sampled" => @context.sampled,
88
+ "retryCount" => @retry_count + 1,
89
+ "errorName" => exception_type
91
90
  }
92
- end
93
-
94
- def retry_count
95
- @retry_count
91
+ unless frame.nil?
92
+ metadata["errorFrameFile"] = frame.fetch("filename")
93
+ metadata["errorFrameLine"] = frame.fetch("line")
94
+ end
95
+ IssueDiagnostics.from_exception(
96
+ error, title: exception_type, mechanism_type: "sidekiq.job", handled: false, metadata: metadata
97
+ )
96
98
  end
97
99
 
98
100
  def failure_key
@@ -228,7 +230,9 @@ module LogBrew
228
230
  end
229
231
  return yield if operation.nil?
230
232
 
231
- terminal = terminal_failure?(job["retry"], retry_count)
233
+ terminal = terminal_failure?(
234
+ job["retry"], retry_count, initial_attempt: !job.key?("retry_count")
235
+ )
232
236
  operation.around(terminal_failure: terminal) { yield }
233
237
  end
234
238
 
@@ -362,13 +366,14 @@ module LogBrew
362
366
  value
363
367
  end
364
368
 
365
- def terminal_failure?(retry_setting, retry_count)
369
+ def terminal_failure?(retry_setting, retry_count, initial_attempt:)
366
370
  return false if retry_count.nil?
367
371
  return true if retry_setting == false || retry_setting == 0
368
372
  return false unless retry_setting.nil? || retry_setting == true || retry_setting.is_a?(Integer)
369
373
 
370
374
  limit = retry_setting.is_a?(Integer) ? retry_setting : @max_retries
371
375
  return false if limit.negative?
376
+ return false if initial_attempt && limit.positive?
372
377
 
373
378
  retry_count >= [limit - 1, 0].max
374
379
  end
@@ -381,7 +386,7 @@ module LogBrew
381
386
  )
382
387
  end
383
388
 
384
- def capture_terminal_issue(operation)
389
+ def capture_terminal_issue(operation, error)
385
390
  key = operation.failure_key
386
391
  reserved = @failure_mutex.synchronize do
387
392
  next false if @reported_failures.key?(key)
@@ -396,7 +401,7 @@ module LogBrew
396
401
  @client.issue(
397
402
  "ruby_sidekiq_issue_#{operation.context.span_id}",
398
403
  Time.now.utc.iso8601,
399
- operation.issue_attributes
404
+ operation.issue_attributes(error)
400
405
  )
401
406
  rescue StandardError
402
407
  @failure_mutex.synchronize { @reported_failures.delete(key) }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LogBrew
4
- VERSION = "0.1.13"
4
+ VERSION = "0.1.15"
5
5
  end
data/lib/logbrew.rb CHANGED
@@ -53,7 +53,15 @@ module LogBrew
53
53
  def capture_safely
54
54
  yield
55
55
  rescue StandardError => error
56
- @on_error.call(error) if @on_error.respond_to?(:call)
56
+ handle_logbrew_error(error)
57
+ end
58
+
59
+ def handle_logbrew_error(error)
60
+ begin
61
+ @on_error.call(error) if @on_error.respond_to?(:call)
62
+ rescue StandardError
63
+ nil
64
+ end
57
65
  raise error if @raise_errors
58
66
  end
59
67
  end
@@ -328,11 +336,6 @@ module LogBrew
328
336
  flush_logbrew if @flush_on_log
329
337
  end
330
338
 
331
- def handle_logbrew_error(error)
332
- @on_error.call(error) if @on_error.respond_to?(:call)
333
- raise error if @raise_errors
334
- end
335
-
336
339
  def logbrew_message(message)
337
340
  return message.message if message.is_a?(Exception)
338
341
  return message if message.is_a?(String)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logbrew-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - LogBrew
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-09-02 00:00:00.000000000 Z
11
+ date: 2026-10-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Public LogBrew Ruby SDK with typed issue diagnostics, automatic Rails
14
14
  request/error capture, and standard-library delivery.