sidekiq-logstash 3.2.0 → 3.2.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: 7da540744ff32bbe1218075f40fa979c9b5a9bdb7211c45df40ec8191b2b51cc
4
- data.tar.gz: '09e58a7cd2504538079fc8493e7fef3a59a9217736a0b1bf1425f6ba208f20c8'
3
+ metadata.gz: 5a83b2031669c8519371e3b02819cc9646488ffa1bfd3cbcb7fe679f61c8b05e
4
+ data.tar.gz: c638f2ad14e73977de141ae082b1b68bd87b0186c6e81507b5e6c564171c5c26
5
5
  SHA512:
6
- metadata.gz: 746c123b2341c14f1d565d830f489a5eddb6591ba56f6c72ffaafd737524126cd24df17fdc808af5b8271fa88f94c5e5356d37e923ba5327cf849a56080d7d7e
7
- data.tar.gz: f79226102532246d67bffcbe478d6e30781838d995d7c50f627e6a309f49f1a1b347aa7dbc1720733985a217a98d9c97d77db71ff53097d4b29c8fcd217012bc
6
+ metadata.gz: 2bce930465248b9328c29eb593802ec0b90be6265a9efa9e079245c5b84c06eed11166b4e0e9afc283292c6fef1e75cd1e95825dd869726995925b6d96f8dbfa
7
+ data.tar.gz: 5eb1304578dceac2d372e4dc794cc118f88e73e13784646d5582185329f0ffddfd57759464c9a8606640e2027beca72d9e91cd18f00dd61de7e3d7630b30301f
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sidekiq
4
+ module Logging
5
+ # Utility that allows us to get a hash representation of an exception
6
+ module ExceptionUtils
7
+ module_function
8
+
9
+ def get_exception_with_cause_hash(exc, parent_backtrace = nil, max_depth_left: 1)
10
+ error_hash = {
11
+ 'class' => exc.class.to_s,
12
+ 'message' => exc.message,
13
+ 'backtrace' => backtrace_for(exc, parent_backtrace)
14
+ }
15
+
16
+ if (cause = exc.cause) && max_depth_left.positive?
17
+ # Pass the current backtrace as the parent_backtrace to the cause to shorten cause's backtrace list
18
+ error_hash['cause'] = get_exception_with_cause_hash(cause, exc.backtrace, max_depth_left: max_depth_left - 1)
19
+ end
20
+
21
+ error_hash
22
+ end
23
+
24
+ def backtrace_for(exception, parent_backtrace = nil)
25
+ backtrace = exception.backtrace || []
26
+ if parent_backtrace
27
+ common_lines = backtrace.reverse.zip(parent_backtrace.reverse).take_while { |a, b| a == b }
28
+
29
+ backtrace = backtrace[0...-common_lines.length] if common_lines.any?
30
+ end
31
+
32
+ backtrace
33
+ end
34
+ end
35
+ end
36
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'sidekiq/exception_utils'
3
+ require 'sidekiq/logging/exception_utils'
4
4
 
5
5
  module Sidekiq
6
6
  module Logging
@@ -54,7 +54,7 @@ module Sidekiq
54
54
 
55
55
  config = Sidekiq::Logstash.configuration
56
56
  if config.log_job_exception_with_causes
57
- payload['error'] = ExceptionUtils.get_exception_with_cause_hash(
57
+ payload['error'] = Sidekiq::Logging::ExceptionUtils.get_exception_with_cause_hash(
58
58
  exc, max_depth_left: config.causes_logging_max_depth
59
59
  )
60
60
  else
@@ -66,7 +66,7 @@ module Sidekiq
66
66
  payload['error_cause'] = {
67
67
  'class' => cause.class.to_s,
68
68
  'message' => cause.message,
69
- 'backtrace' => ExceptionUtils.backtrace_for(cause, exc.backtrace)
69
+ 'backtrace' => Sidekiq::Logging::ExceptionUtils.backtrace_for(cause, exc.backtrace)
70
70
  }
71
71
  end
72
72
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sidekiq
4
4
  module Logstash
5
- VERSION = '3.2.0'
5
+ VERSION = '3.2.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-logstash
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mattia Giuffrida
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-29 00:00:00.000000000 Z
11
+ date: 2024-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-event
@@ -60,8 +60,8 @@ files:
60
60
  - bin/console
61
61
  - bin/setup
62
62
  - bin/test_console
63
- - lib/sidekiq/exception_utils.rb
64
63
  - lib/sidekiq/logging/argument_filter.rb
64
+ - lib/sidekiq/logging/exception_utils.rb
65
65
  - lib/sidekiq/logging/logstash_formatter.rb
66
66
  - lib/sidekiq/logging/shared.rb
67
67
  - lib/sidekiq/logstash.rb
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Utility that allows us to get a hash representation of an exception
4
- module ExceptionUtils
5
- module_function
6
-
7
- def get_exception_with_cause_hash(exc, parent_backtrace = nil, max_depth_left: 1)
8
- error_hash = {
9
- 'class' => exc.class.to_s,
10
- 'message' => exc.message,
11
- 'backtrace' => backtrace_for(exc, parent_backtrace)
12
- }
13
-
14
- if (cause = exc.cause) && max_depth_left.positive?
15
- # Pass the current backtrace as the parent_backtrace to the cause to shorten cause's backtrace list
16
- error_hash['cause'] = get_exception_with_cause_hash(cause, exc.backtrace, max_depth_left: max_depth_left - 1)
17
- end
18
-
19
- error_hash
20
- end
21
-
22
- def backtrace_for(exception, parent_backtrace = nil)
23
- backtrace = exception.backtrace || []
24
- if parent_backtrace
25
- common_lines = backtrace.reverse.zip(parent_backtrace.reverse).take_while { |a, b| a == b }
26
-
27
- backtrace = backtrace[0...-common_lines.length] if common_lines.any?
28
- end
29
-
30
- backtrace
31
- end
32
- end