juan_pelota 1.0.0 → 1.1.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
  SHA1:
3
- metadata.gz: a066dbb363f68680eb376d6ebb576e32e7ff3f6f
4
- data.tar.gz: 903df68213e2268f708bfb0c10259662e7a61fb3
3
+ metadata.gz: 315922e2e7df1add35a7311bf721a65c424a8659
4
+ data.tar.gz: dbe4269b6ec24d713a9dcc42971989a53244682c
5
5
  SHA512:
6
- metadata.gz: d0d55ab1d01eeb15ab085697bc7fd4c8e73958a53102d7ce74621b6edc8a01bff134cea93eb0900e5fdb1b2520239fb7e64725bd78a0440fbde40850e662f15e
7
- data.tar.gz: 255db5502f25d89a9e5f9adffc77de848ef5245eb8c06412f2c49d619f7e3e46cb26819d8a238c16c14e10c24b1888ef9ecdf26bca076e44e22c3b2b793f6f39
6
+ metadata.gz: 46b741affd4584ba2653259e02646db0d1bfc93850afe8b012f8499b34c96433c28c054c08e45d5111966dbda451904f1d6d8b8bc089223339a40f6cdba49caf
7
+ data.tar.gz: 7c3f48f596254ed5151b8ea28f8b2491d87b898c7482c34f2741ab29df963434b569a13226c4767634d6120d3bd229110404bf482534704574117559f0df804f
@@ -52,6 +52,11 @@ class Logger < Sidekiq::Logging::Pretty
52
52
  'message' => @raw_message,
53
53
  'class' => @raw_message.split(' ')[1],
54
54
  }
55
+ elsif @raw_message.respond_to?(:match) &&
56
+ @raw_message.match(/:\d+:in\s`/)
57
+ {
58
+ 'message' => @raw_message.lines.first(10).map(&:chomp),
59
+ }
55
60
  else
56
61
  {
57
62
  'message' => @raw_message,
@@ -12,7 +12,7 @@ class Logging
12
12
  'bid' => job['bid'],
13
13
  'run_time' => nil,
14
14
  'class' => worker.class.to_s,
15
- 'args' => filtered_arguments(job['args']),
15
+ 'args' => filtered_arguments(job['args'].try(:first)),
16
16
  )
17
17
  end
18
18
 
@@ -25,20 +25,27 @@ class Logging
25
25
  'bid' => job['bid'],
26
26
  'run_time' => elapsed(start),
27
27
  'class' => worker.class.to_s,
28
- 'args' => filtered_arguments(job['args']),
28
+ 'args' => filtered_arguments(job['args'].try(:first)),
29
29
  )
30
30
  end
31
- rescue Exception
31
+ rescue Exception => e
32
+ message = {
33
+ 'error_class' => e.class.name,
34
+ 'error_message' => e.message,
35
+ 'error_backtrace' => e.backtrace.first(10),
36
+ }
37
+
32
38
  logger.info(
33
39
  'status' => 'fail',
34
40
  'jid' => job['jid'],
35
41
  'bid' => job['bid'],
36
42
  'run_time' => elapsed(start),
37
43
  'class' => worker.class.to_s,
38
- 'args' => filtered_arguments(job['args']),
44
+ 'message' => message,
45
+ 'args' => filtered_arguments(job['args'].try(:first)),
39
46
  )
40
47
 
41
- raise
48
+ raise e
42
49
  end
43
50
  # rubocop:enable Lint/RescueException, Metrics/AbcSize, Metrics/MethodLength
44
51
 
@@ -51,10 +58,12 @@ class Logging
51
58
  end
52
59
 
53
60
  def filtered_arguments(args)
54
- return if args.nil? || args.empty?
61
+ return if args.nil?
55
62
 
56
63
  @filtered_arguments ||=
57
- args.first.each_with_object({}) do |(key, value), filtered_hash|
64
+ args.each_with_object({}) do |(key, value), filtered_hash|
65
+ value = filtered_arguments(value) if value.is_a? Hash
66
+
58
67
  filtered_hash[key] = value unless config.filtered_arguments.include? key
59
68
  end
60
69
  end
@@ -1,3 +1,3 @@
1
1
  module JuanPelota
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -56,6 +56,58 @@ describe Logger do
56
56
  )
57
57
  end
58
58
 
59
+ # rubocop:disable Metrics/LineLength
60
+ it 'take message as a string and can detect if its a backtrace',
61
+ :time_mock do
62
+
63
+ backtrace = <<-HEREDOC
64
+ /Users/hhd418/Projects/goodscout/good_products/app/workers/good_products/workers/process_item.rb:50:in `perform'
65
+ /usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sidekiq-3.4.1/lib/sidekiq/processor.rb:75:in `execute_job'
66
+ /usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sidekiq-3.4.1/lib/sidekiq/processor.rb:52:in `block (2 levels) in process'
67
+ /usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sidekiq-3.4.1/lib/sidekiq/middleware/chain.rb:127:in `block in invoke'
68
+ /usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/honeybadger-2.0.11/lib/honeybadger/plugins/sidekiq.rb:11:in `block in call'
69
+ /usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/honeybadger-2.0.11/lib/honeybadger/trace.rb:62:in `instrument'
70
+ /usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/honeybadger-2.0.11/lib/honeybadger/trace.rb:18:in `instrument'
71
+ /usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/honeybadger-2.0.11/lib/honeybadger/plugins/sidekiq.rb:10:in `call'
72
+ /usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sidekiq-3.4.1/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
73
+ /usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sidekiq-unique-jobs-3.0.14/lib/sidekiq_unique_jobs/middleware/server/unique_jobs.rb:16:in `call'
74
+ /usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sidekiq-3.4.1/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
75
+ /usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sidekiq-3.4.1/lib/sidekiq/middleware/server/active_record.rb:6:in `call'
76
+ /usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sidekiq-3.4.1/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
77
+ /usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sidekiq-3.4.1/lib/sidekiq/middleware/server/retry_jobs.rb:74:in `call'
78
+ /usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sidekiq-3.4.1/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
79
+ /usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sidekiq-failures-0.4.4/lib/sidekiq/failures/middleware.rb:9:in `call'
80
+ /usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sidekiq-3.4.1/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
81
+ /usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sidekiq-3.4.1/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
82
+ /usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sidekiq-skylight-0.0.4/lib/sidekiq/skylight/server_middleware.rb:8:in `block in call'
83
+ /usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/skylight-0.6.0/lib/skylight/core.rb:70:in `trace'
84
+ HEREDOC
85
+
86
+ json = JuanPelota::Logger.new.call('high',
87
+ Time.now.utc,
88
+ 'our tests',
89
+ backtrace)
90
+
91
+ json_data = JSON.parse(json)
92
+
93
+ expect(json_data).to include(
94
+ '@status' => 'dead',
95
+ '@message' => [
96
+ "/Users/hhd418/Projects/goodscout/good_products/app/workers/good_products/workers/process_item.rb:50:in `perform'",
97
+ "/usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sidekiq-3.4.1/lib/sidekiq/processor.rb:75:in `execute_job'",
98
+ "/usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sidekiq-3.4.1/lib/sidekiq/processor.rb:52:in `block (2 levels) in process'",
99
+ "/usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sidekiq-3.4.1/lib/sidekiq/middleware/chain.rb:127:in `block in invoke'",
100
+ "/usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/honeybadger-2.0.11/lib/honeybadger/plugins/sidekiq.rb:11:in `block in call'",
101
+ "/usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/honeybadger-2.0.11/lib/honeybadger/trace.rb:62:in `instrument'",
102
+ "/usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/honeybadger-2.0.11/lib/honeybadger/trace.rb:18:in `instrument'",
103
+ "/usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/honeybadger-2.0.11/lib/honeybadger/plugins/sidekiq.rb:10:in `call'",
104
+ "/usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sidekiq-3.4.1/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'",
105
+ "/usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sidekiq-unique-jobs-3.0.14/lib/sidekiq_unique_jobs/middleware/server/unique_jobs.rb:16:in `call'",
106
+ ],
107
+ )
108
+ end
109
+ # rubocop:enable Metrics/LineLength
110
+
59
111
  it 'set the status to dead and returns a nil worker if it gets a string without ' \
60
112
  '"queueing" in the message',
61
113
  :time_mock do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: juan_pelota
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thekompanee
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-09 00:00:00.000000000 Z
12
+ date: 2015-07-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sidekiq