appsignal 0.11.8.beta.0 → 0.11.8.beta.1
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 +4 -4
- data/CHANGELOG.md +2 -0
- data/lib/appsignal/integrations/delayed_job.rb +5 -3
- data/lib/appsignal/integrations/rails.rb +1 -1
- data/lib/appsignal/integrations/sidekiq.rb +38 -4
- data/lib/appsignal/version.rb +1 -1
- data/spec/lib/appsignal/integrations/delayed_job_spec.rb +18 -14
- data/spec/lib/appsignal/integrations/rails_spec.rb +18 -2
- data/spec/lib/appsignal/integrations/sidekiq_spec.rb +75 -7
- data/spec/support/rails/my_app.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d352412d00bbd2c1cf81315d80ae4a5c08d8115e
|
4
|
+
data.tar.gz: df2cda49d433880e1c89b5c42c1c12cf1abb65bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8347c842bde632030871bbe90392115a744d1676d1afc98c9f796987b587be7ce5d8c56a742019dd004b1f8b580fc05a9250e2b59ed099ef555d6e31052b1deb
|
7
|
+
data.tar.gz: cda5f26ebd0b612f46feca9952f1e420c6370e89e9682e8879e91f1250e9d47edcee7ff61e2cd5b11f6c2e0b08ae1a063451e92e008f1bc4cc10e1d006ec48ca
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# 0.11.8
|
2
2
|
* Add frontend error catcher
|
3
|
+
* Add background job metadata (queue, priority etc.) to transaction overview
|
4
|
+
* Add APPSIGNAL_APP_ENV variable to Rails config, so you can override the environment
|
3
5
|
|
4
6
|
# 0.11.7
|
5
7
|
* Add option to override Job name in Delayed Job
|
@@ -22,9 +22,11 @@ if defined?(::Delayed::Plugin)
|
|
22
22
|
'perform_job.delayed_job',
|
23
23
|
:class => class_name,
|
24
24
|
:method => method_name,
|
25
|
-
:
|
26
|
-
|
27
|
-
|
25
|
+
:metadata => {
|
26
|
+
:priority => job.priority,
|
27
|
+
:attempts => job.attempts,
|
28
|
+
:queue => job.queue,
|
29
|
+
},
|
28
30
|
:queue_start => job.created_at
|
29
31
|
) do
|
30
32
|
block.call(job)
|
@@ -4,18 +4,52 @@ if defined?(::Sidekiq)
|
|
4
4
|
module Appsignal
|
5
5
|
module Integrations
|
6
6
|
class SidekiqPlugin
|
7
|
+
def job_keys
|
8
|
+
@job_keys ||= Set.new(%w(
|
9
|
+
class args retried_at failed_at
|
10
|
+
error_message error_class backtrace
|
11
|
+
error_backtrace enqueued_at retry
|
12
|
+
))
|
13
|
+
end
|
14
|
+
|
7
15
|
def call(worker, item, queue)
|
8
16
|
Appsignal.monitor_transaction(
|
9
17
|
'perform_job.sidekiq',
|
10
|
-
:class
|
11
|
-
:method
|
12
|
-
:
|
13
|
-
:
|
18
|
+
:class => item['class'],
|
19
|
+
:method => 'perform',
|
20
|
+
:metadata => formatted_metadata(item),
|
21
|
+
:params => format_args(item['args']),
|
14
22
|
:queue_start => item['enqueued_at']
|
15
23
|
) do
|
16
24
|
yield
|
17
25
|
end
|
18
26
|
end
|
27
|
+
|
28
|
+
def formatted_metadata(item)
|
29
|
+
{}.tap do |hsh|
|
30
|
+
item.each do |key, val|
|
31
|
+
hsh[key] = truncate(string_or_inspect(val)) unless job_keys.include?(key)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def string_or_inspect(string_or_other)
|
37
|
+
if string_or_other.is_a?(String)
|
38
|
+
string_or_other
|
39
|
+
else
|
40
|
+
string_or_other.inspect
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def format_args(args)
|
45
|
+
args.map do |arg|
|
46
|
+
truncate(string_or_inspect(arg))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def truncate(text)
|
51
|
+
text.size > 100 ? "#{text[0...97]}..." : text
|
52
|
+
end
|
19
53
|
end
|
20
54
|
end
|
21
55
|
end
|
data/lib/appsignal/version.rb
CHANGED
@@ -30,11 +30,11 @@ describe "Delayed Job integration" do
|
|
30
30
|
let(:time) { Time.parse('01-01-2001 10:01:00UTC') }
|
31
31
|
let(:job) do
|
32
32
|
double(
|
33
|
-
:name
|
34
|
-
:priority
|
35
|
-
:attempts
|
36
|
-
:queue
|
37
|
-
:created_at
|
33
|
+
:name => 'TestClass#perform',
|
34
|
+
:priority => 1,
|
35
|
+
:attempts => 1,
|
36
|
+
:queue => 'default',
|
37
|
+
:created_at => time - 60_000,
|
38
38
|
:payload_object => double
|
39
39
|
)
|
40
40
|
end
|
@@ -45,11 +45,13 @@ describe "Delayed Job integration" do
|
|
45
45
|
it "should wrap in a transaction with the correct params" do
|
46
46
|
Appsignal.should_receive(:monitor_transaction).with(
|
47
47
|
'perform_job.delayed_job',
|
48
|
-
:class
|
49
|
-
:method
|
50
|
-
:
|
51
|
-
|
52
|
-
|
48
|
+
:class => 'TestClass',
|
49
|
+
:method => 'perform',
|
50
|
+
:metadata => {
|
51
|
+
:priority => 1,
|
52
|
+
:attempts => 1,
|
53
|
+
:queue => 'default',
|
54
|
+
},
|
53
55
|
:queue_start => time - 60_000,
|
54
56
|
)
|
55
57
|
|
@@ -67,7 +69,7 @@ describe "Delayed Job integration" do
|
|
67
69
|
:name => 'TestClass#perform',
|
68
70
|
:priority => 1,
|
69
71
|
:attempts => 1,
|
70
|
-
:queue
|
72
|
+
:queue => 'default',
|
71
73
|
:created_at => time - 60_000
|
72
74
|
)
|
73
75
|
end
|
@@ -76,9 +78,11 @@ describe "Delayed Job integration" do
|
|
76
78
|
'perform_job.delayed_job',
|
77
79
|
:class => 'CustomClass',
|
78
80
|
:method => 'perform',
|
79
|
-
:
|
80
|
-
|
81
|
-
|
81
|
+
:metadata => {
|
82
|
+
:priority => 1,
|
83
|
+
:attempts => 1,
|
84
|
+
:queue => 'default',
|
85
|
+
},
|
82
86
|
:queue_start => time - 60_000
|
83
87
|
)
|
84
88
|
|
@@ -20,8 +20,8 @@ if rails_present?
|
|
20
20
|
it { should be_a(Appsignal::Config) }
|
21
21
|
|
22
22
|
its(:root_path) { should == Pathname.new(project_fixture_path) }
|
23
|
-
its(:env)
|
24
|
-
its([:name])
|
23
|
+
its(:env) { should == 'test' }
|
24
|
+
its([:name]) { should == 'TestApp' }
|
25
25
|
|
26
26
|
context "initial config" do
|
27
27
|
subject { Appsignal.config.initial_config }
|
@@ -48,5 +48,21 @@ if rails_present?
|
|
48
48
|
MyApp::Application.middleware.to_a.should_not include Appsignal::Rack::Instrumentation
|
49
49
|
end
|
50
50
|
end
|
51
|
+
|
52
|
+
context "with APPSIGNAL_APP_ENV ENV var set" do
|
53
|
+
around do |sample|
|
54
|
+
ENV['APPSIGNAL_APP_ENV'] = 'env_test'
|
55
|
+
|
56
|
+
MyEnvApp::Application.config.root = project_fixture_path
|
57
|
+
MyEnvApp::Application.initialize!
|
58
|
+
|
59
|
+
sample.run
|
60
|
+
|
61
|
+
ENV.delete('APPSIGNAL_APP_ENV')
|
62
|
+
end
|
63
|
+
subject { Appsignal.config }
|
64
|
+
|
65
|
+
its(:env) { should == 'env_test' }
|
66
|
+
end
|
51
67
|
end
|
52
68
|
end
|
@@ -17,11 +17,14 @@ describe "Sidekiq integration" do
|
|
17
17
|
let(:queue) { double }
|
18
18
|
let(:current_transaction) { Appsignal::Transaction.create(SecureRandom.uuid, {}) }
|
19
19
|
let(:item) {{
|
20
|
-
'class'
|
20
|
+
'class' => 'TestClass',
|
21
21
|
'retry_count' => 0,
|
22
|
-
'queue'
|
23
|
-
'enqueued_at' => Time.parse('01-01-2001 10:00:00UTC')
|
22
|
+
'queue' => 'default',
|
23
|
+
'enqueued_at' => Time.parse('01-01-2001 10:00:00UTC'),
|
24
|
+
'args' => ['Model', 1],
|
25
|
+
'extra' => 'data'
|
24
26
|
}}
|
27
|
+
let(:plugin) { Appsignal::Integrations::SidekiqPlugin.new }
|
25
28
|
|
26
29
|
before do
|
27
30
|
Appsignal.stub(:is_ignored_exception? => false)
|
@@ -32,10 +35,14 @@ describe "Sidekiq integration" do
|
|
32
35
|
it "should wrap in a transaction with the correct params" do
|
33
36
|
Appsignal.should_receive(:monitor_transaction).with(
|
34
37
|
'perform_job.sidekiq',
|
35
|
-
:class
|
36
|
-
:method
|
37
|
-
:
|
38
|
-
|
38
|
+
:class => 'TestClass',
|
39
|
+
:method => 'perform',
|
40
|
+
:metadata => {
|
41
|
+
'retry_count' => "0",
|
42
|
+
'queue' => 'default',
|
43
|
+
'extra' => 'data'
|
44
|
+
},
|
45
|
+
:params => ['Model', "1"],
|
39
46
|
:queue_start => Time.parse('01-01-2001 10:00:00UTC')
|
40
47
|
)
|
41
48
|
end
|
@@ -67,6 +74,67 @@ describe "Sidekiq integration" do
|
|
67
74
|
end
|
68
75
|
end
|
69
76
|
|
77
|
+
describe "#formatted_data" do
|
78
|
+
let(:item) do
|
79
|
+
{
|
80
|
+
'foo' => 'bar',
|
81
|
+
'class' => 'TestClass',
|
82
|
+
}
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should only add items to the hash that do not appear in JOB_KEYS" do
|
86
|
+
plugin.formatted_metadata(item).should == {'foo' => 'bar'}
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "#format_args" do
|
91
|
+
let(:object) { Object.new }
|
92
|
+
let(:args) do
|
93
|
+
[
|
94
|
+
'Model',
|
95
|
+
1,
|
96
|
+
object
|
97
|
+
]
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should format the arguments" do
|
101
|
+
plugin.format_args(args).should == ['Model', '1', object.inspect]
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "#truncate" do
|
106
|
+
let(:very_long_text) do
|
107
|
+
"a" * 200
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should truncate the text to 100 chars max" do
|
111
|
+
plugin.truncate(very_long_text).should == "#{'a' * 97}..."
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "#string_or_inspect" do
|
116
|
+
context "when string" do
|
117
|
+
it "should return the string" do
|
118
|
+
plugin.string_or_inspect('foo').should == 'foo'
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
context "when integer" do
|
123
|
+
it "should return the string" do
|
124
|
+
plugin.string_or_inspect(1).should == '1'
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
context "when object" do
|
129
|
+
let(:object) { Object.new }
|
130
|
+
|
131
|
+
it "should return the string" do
|
132
|
+
plugin.string_or_inspect(object).should == object.inspect
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
70
138
|
context "without sidekiq" do
|
71
139
|
before(:all) { Object.send(:remove_const, :Sidekiq) }
|
72
140
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appsignal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.8.beta.
|
4
|
+
version: 0.11.8.beta.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Beekman
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2015-03-
|
15
|
+
date: 2015-03-05 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rack
|