sidekiq-logging-json 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +4 -0
- data/lib/sidekiq/logging/json.rb +22 -21
- data/lib/sidekiq/logging/json/version.rb +1 -1
- data/sidekiq-logging-json.gemspec +1 -1
- data/spec/sidekiq/logging/json_spec.rb +26 -16
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ff0f8dd857e176ed01156393972c0d0937f89d1
|
4
|
+
data.tar.gz: 5ce9b30ae414561a2b0b6e72d81be2065c27aae5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba590683e12f4fad5dc89c1b446626c7b32cc42b55e700e408758569247788221be36f6c4812cb51f8f8161655a7e1b768d480ebd8e35d53f15b4082d09a65f7
|
7
|
+
data.tar.gz: a048483e78df758c1639a290ddafb7c062b16e5eb5c131cfcd7d6532db00bc3e22245591eb208063e7d80022b5743790e92cbc525a4709681072fdac8f6a99c0
|
data/Rakefile
CHANGED
data/lib/sidekiq/logging/json.rb
CHANGED
@@ -21,34 +21,35 @@ module Sidekiq
|
|
21
21
|
'@status' => nil,
|
22
22
|
'@severity' => severity,
|
23
23
|
'@run_time' => nil,
|
24
|
-
|
25
|
-
}.merge(process_message(severity, time, program_name, message)).to_json + "\n"
|
24
|
+
}.merge(process_message(message)).to_json + "\n"
|
26
25
|
end
|
27
26
|
|
28
|
-
def process_message(
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
def process_message(message)
|
28
|
+
case message
|
29
|
+
when Exception
|
30
|
+
{ '@status' => 'exception', '@message' => message.message }
|
31
|
+
when Hash
|
32
32
|
if message["retry"]
|
33
|
-
|
34
|
-
|
33
|
+
{
|
34
|
+
'@status' => 'retry',
|
35
|
+
'@message' => "#{message['class']} failed, retrying with args #{message['args']}."
|
36
|
+
}
|
35
37
|
else
|
36
|
-
|
37
|
-
|
38
|
+
{
|
39
|
+
'@status' => 'dead',
|
40
|
+
'@message' => "#{message['class']} failed with args #{message['args']}, not retrying."
|
41
|
+
}
|
38
42
|
end
|
39
|
-
|
40
|
-
|
41
|
-
|
43
|
+
else
|
44
|
+
result = message.split(" ")
|
45
|
+
status = result[0].match(/^(start|done|fail):?$/) || []
|
46
|
+
|
47
|
+
{
|
48
|
+
'@status' => status[1], # start or done
|
49
|
+
'@run_time' => status[1] && result[1] && result[1].to_f, # run time in seconds
|
50
|
+
'@message' => message
|
42
51
|
}
|
43
52
|
end
|
44
|
-
|
45
|
-
result = message.split(" ")
|
46
|
-
status = result[0].match(/^(start|done|fail):?$/) || []
|
47
|
-
|
48
|
-
{
|
49
|
-
'@status' => status[1], # start or done
|
50
|
-
'@run_time' => status[1] && result[1] && result[1].to_f # run time in seconds
|
51
|
-
}
|
52
53
|
end
|
53
54
|
end
|
54
55
|
end
|
@@ -11,33 +11,33 @@ describe "Sidekiq::Logging::Json" do
|
|
11
11
|
let(:time) { Time.now }
|
12
12
|
let(:program_name) { "RSpec" }
|
13
13
|
|
14
|
-
it { expect(
|
15
|
-
it { expect(
|
16
|
-
it { expect(
|
14
|
+
it { expect(message).to match(/#{logentry}/) }
|
15
|
+
it { expect(status).to eq(nil) }
|
16
|
+
it { expect(run_time).to eq(nil) }
|
17
17
|
|
18
18
|
context "start" do
|
19
19
|
let(:logentry) { "start" }
|
20
20
|
|
21
|
-
it { expect(
|
22
|
-
it { expect(
|
23
|
-
it { expect(
|
21
|
+
it { expect(message).to match(/#{logentry}/) }
|
22
|
+
it { expect(status).to eq("start") }
|
23
|
+
it { expect(run_time).to eq(nil) }
|
24
24
|
end
|
25
25
|
|
26
26
|
context "done" do
|
27
27
|
let(:logentry) { "done: 51.579 sec" }
|
28
28
|
|
29
|
-
it { expect(
|
30
|
-
it { expect(
|
31
|
-
it { expect(
|
29
|
+
it { expect(message).to match(/#{logentry}/) }
|
30
|
+
it { expect(status).to eq("done") }
|
31
|
+
it { expect(run_time).to eq(51.579) }
|
32
32
|
end
|
33
33
|
|
34
34
|
context "exception" do
|
35
35
|
let(:exception_message) { "This is the message that should be logged." }
|
36
|
-
let(:logentry) { NoMethodError.new(
|
36
|
+
let(:logentry) { NoMethodError.new(exception_message) }
|
37
37
|
|
38
|
-
it { expect(message).to match(
|
39
|
-
it { expect(
|
40
|
-
it { expect(
|
38
|
+
it { expect(message).to match(exception_message) }
|
39
|
+
it { expect(status).to eq("exception") }
|
40
|
+
it { expect(run_time).to eq(nil) }
|
41
41
|
end
|
42
42
|
|
43
43
|
context "retry" do
|
@@ -45,9 +45,19 @@ describe "Sidekiq::Logging::Json" do
|
|
45
45
|
{"retry"=>true, "queue"=>"default", "class"=>"MarkTest", "args"=>["markie"], "jid"=>"0ca71f2580fdc0ae19a59063", "enqueued_at"=>1405957471.1871092}
|
46
46
|
end
|
47
47
|
|
48
|
-
it { expect(message).to match(
|
49
|
-
it { expect(
|
50
|
-
it { expect(
|
48
|
+
it { expect(message).to match("MarkTest failed, retrying.") }
|
49
|
+
it { expect(status).to eq("retry") }
|
50
|
+
it { expect(run_time).to eq(nil) }
|
51
|
+
end
|
52
|
+
|
53
|
+
context "dead" do
|
54
|
+
let(:logentry) do
|
55
|
+
{"retry"=>false, "queue"=>"default", "class"=>"MarkTest", "args"=>["markie"], "jid"=>"0ca71f2580fdc0ae19a59063", "enqueued_at"=>1405957471.1871092}
|
56
|
+
end
|
57
|
+
|
58
|
+
it { expect(message).to match("MarkTest failed with args #{logentry["args"]}, not retrying.") }
|
59
|
+
it { expect(status).to eq("dead") }
|
60
|
+
it { expect(run_time).to eq(nil) }
|
51
61
|
end
|
52
62
|
end
|
53
63
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-logging-json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wouter de Vos
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-04-
|
12
|
+
date: 2016-04-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -60,6 +60,9 @@ dependencies:
|
|
60
60
|
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '3'
|
63
|
+
- - "<"
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '5'
|
63
66
|
type: :runtime
|
64
67
|
prerelease: false
|
65
68
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -67,6 +70,9 @@ dependencies:
|
|
67
70
|
- - ">="
|
68
71
|
- !ruby/object:Gem::Version
|
69
72
|
version: '3'
|
73
|
+
- - "<"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5'
|
70
76
|
description: |
|
71
77
|
At Springest, we use Logstash to ship all our logs to Elasticsearch. An Elasticsearch index consists of JSON documents.
|
72
78
|
To make it possible to make fine grained queries on Sidekiq logs, we needed logging in JSON format.
|