appsignal 2.11.0.beta.2 → 2.11.0.beta.3
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/hooks/active_job.rb +24 -5
- data/lib/appsignal/version.rb +1 -1
- data/spec/lib/appsignal/hooks/activejob_spec.rb +73 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d8565582bb357410dee8c4683c62da303f2b1cbbb9dc5dcc0494b03761a7c55
|
4
|
+
data.tar.gz: 7270ef47a9574e21887a8044d1934abdddb75293f919ab3ebda55ce5fb4afd3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 233fc5bb7044fab5c6743a6516be7e2058f211aa4ce94529f4a7bde232fc803f6b4833987bf308578c4f7760b86a9ea3f437edf91b796b977fb115100d1e4ee4
|
7
|
+
data.tar.gz: 123e21c4bd820b766d011fdbc221c243ca2b746745e8a8b9de785fe432b599315d3b17c72b8627479c25490d754947d00501d8dd796ff402758343e0fc53a06e
|
data/CHANGELOG.md
CHANGED
@@ -16,6 +16,8 @@
|
|
16
16
|
integrations. PR #630
|
17
17
|
- Fix issue with unknown events from being reported as often for long running
|
18
18
|
agents. Commit ba9afb538f44c68b8035a8cf40a39d89bc77b021
|
19
|
+
- Add support for Active Job priority. PR #632
|
20
|
+
- Track Active Job job metrics for magic dashboard. PR #633
|
19
21
|
|
20
22
|
# 2.10.9
|
21
23
|
- Use http proxy if configured when downloading agent. PR #606
|
@@ -15,10 +15,9 @@ module Appsignal
|
|
15
15
|
.extend ::Appsignal::Hooks::ActiveJobHook::ActiveJobClassInstrumentation
|
16
16
|
end
|
17
17
|
|
18
|
-
# @todo Add queue time support for Rails 6's enqueued_at. For both
|
19
|
-
# existing and new transactions.
|
20
18
|
module ActiveJobClassInstrumentation
|
21
19
|
def execute(job)
|
20
|
+
job_status = nil
|
22
21
|
current_transaction = Appsignal::Transaction.current
|
23
22
|
transaction =
|
24
23
|
if current_transaction.nil_transaction?
|
@@ -38,9 +37,16 @@ module Appsignal
|
|
38
37
|
|
39
38
|
super
|
40
39
|
rescue Exception => exception # rubocop:disable Lint/RescueException
|
40
|
+
job_status = :failed
|
41
41
|
transaction.set_error(exception)
|
42
42
|
raise exception
|
43
43
|
ensure
|
44
|
+
tags = {}
|
45
|
+
queue = job["queue_name"]
|
46
|
+
tags[:queue] = queue if queue
|
47
|
+
priority = job["priority"]
|
48
|
+
tags[:priority] = priority if priority
|
49
|
+
|
44
50
|
if transaction
|
45
51
|
transaction.params =
|
46
52
|
Appsignal::Utils::HashSanitizer.sanitize(
|
@@ -48,10 +54,12 @@ module Appsignal
|
|
48
54
|
Appsignal.config[:filter_parameters]
|
49
55
|
)
|
50
56
|
|
51
|
-
|
57
|
+
transaction_tags = tags
|
52
58
|
provider_job_id = job["provider_job_id"]
|
53
|
-
|
54
|
-
|
59
|
+
if provider_job_id
|
60
|
+
transaction_tags[:provider_job_id] = provider_job_id
|
61
|
+
end
|
62
|
+
transaction.set_tags(transaction_tags)
|
55
63
|
|
56
64
|
transaction.set_action_if_nil(ActiveJobHelpers.action_name(job))
|
57
65
|
enqueued_at = job["enqueued_at"]
|
@@ -65,6 +73,13 @@ module Appsignal
|
|
65
73
|
Appsignal::Transaction.complete_current!
|
66
74
|
end
|
67
75
|
end
|
76
|
+
|
77
|
+
if job_status
|
78
|
+
ActiveJobHelpers.increment_counter "queue_job_count", 1,
|
79
|
+
tags.merge(:status => job_status)
|
80
|
+
end
|
81
|
+
ActiveJobHelpers.increment_counter "queue_job_count", 1,
|
82
|
+
tags.merge(:status => :processed)
|
68
83
|
end
|
69
84
|
end
|
70
85
|
|
@@ -83,6 +98,10 @@ module Appsignal
|
|
83
98
|
"#{job["job_class"]}#perform"
|
84
99
|
end
|
85
100
|
end
|
101
|
+
|
102
|
+
def self.increment_counter(key, value, tags = {})
|
103
|
+
Appsignal.increment_counter "active_job_#{key}", value, tags
|
104
|
+
end
|
86
105
|
end
|
87
106
|
end
|
88
107
|
end
|
data/lib/appsignal/version.rb
CHANGED
@@ -21,7 +21,7 @@ if DependencyHelper.active_job_present?
|
|
21
21
|
|
22
22
|
describe "#install" do
|
23
23
|
it "extends ActiveJob::Base with the AppSignal ActiveJob plugin" do
|
24
|
-
|
24
|
+
start_agent
|
25
25
|
|
26
26
|
path, _line_number = ActiveJob::Base.method(:execute).source_location
|
27
27
|
expect(path).to end_with("/lib/appsignal/hooks/active_job.rb")
|
@@ -32,6 +32,7 @@ if DependencyHelper.active_job_present?
|
|
32
32
|
describe Appsignal::Hooks::ActiveJobHook::ActiveJobClassInstrumentation do
|
33
33
|
let(:time) { Time.parse("2001-01-01 10:00:00UTC") }
|
34
34
|
let(:namespace) { Appsignal::Transaction::BACKGROUND_JOB }
|
35
|
+
let(:queue) { "default" }
|
35
36
|
let(:log) { StringIO.new }
|
36
37
|
let(:parameterized_given_args) do
|
37
38
|
{
|
@@ -78,14 +79,26 @@ if DependencyHelper.active_job_present?
|
|
78
79
|
raise "uh oh"
|
79
80
|
end
|
80
81
|
end
|
82
|
+
|
83
|
+
class ActiveJobCustomQueueTestJob < ActiveJob::Base
|
84
|
+
queue_as :custom_queue
|
85
|
+
|
86
|
+
def perform(*_args)
|
87
|
+
end
|
88
|
+
end
|
81
89
|
end
|
82
90
|
around { |example| keep_transactions { example.run } }
|
83
91
|
after do
|
84
92
|
Object.send(:remove_const, :ActiveJobTestJob)
|
85
93
|
Object.send(:remove_const, :ActiveJobErrorTestJob)
|
94
|
+
Object.send(:remove_const, :ActiveJobCustomQueueTestJob)
|
86
95
|
end
|
87
96
|
|
88
97
|
it "reports the name from the ActiveJob integration" do
|
98
|
+
tags = { :queue => queue }
|
99
|
+
expect(Appsignal).to receive(:increment_counter)
|
100
|
+
.with("active_job_queue_job_count", 1, tags.merge(:status => :processed))
|
101
|
+
|
89
102
|
perform_job(ActiveJobTestJob)
|
90
103
|
|
91
104
|
transaction = last_transaction
|
@@ -97,9 +110,7 @@ if DependencyHelper.active_job_present?
|
|
97
110
|
"metadata" => {},
|
98
111
|
"sample_data" => hash_including(
|
99
112
|
"params" => [],
|
100
|
-
"tags" => {
|
101
|
-
"queue" => "default"
|
102
|
-
}
|
113
|
+
"tags" => { "queue" => queue }
|
103
114
|
)
|
104
115
|
)
|
105
116
|
events = transaction_hash["events"]
|
@@ -108,8 +119,64 @@ if DependencyHelper.active_job_present?
|
|
108
119
|
expect(events).to eq(["perform_start.active_job", "perform.active_job"])
|
109
120
|
end
|
110
121
|
|
122
|
+
context "with custom queue" do
|
123
|
+
it "reports the custom queue as tag on the transaction" do
|
124
|
+
tags = { :queue => "custom_queue" }
|
125
|
+
expect(Appsignal).to receive(:increment_counter)
|
126
|
+
.with("active_job_queue_job_count", 1, tags.merge(:status => :processed))
|
127
|
+
perform_job(ActiveJobCustomQueueTestJob)
|
128
|
+
|
129
|
+
transaction = last_transaction
|
130
|
+
transaction_hash = transaction.to_h
|
131
|
+
expect(transaction_hash).to include(
|
132
|
+
"sample_data" => hash_including(
|
133
|
+
"tags" => { "queue" => "custom_queue" }
|
134
|
+
)
|
135
|
+
)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
if DependencyHelper.rails_version >= Gem::Version.new("5.0.0")
|
140
|
+
context "with priority" do
|
141
|
+
before do
|
142
|
+
class ActiveJobPriorityTestJob < ActiveJob::Base
|
143
|
+
queue_with_priority 10
|
144
|
+
|
145
|
+
def perform(*_args)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
after do
|
150
|
+
Object.send(:remove_const, :ActiveJobPriorityTestJob)
|
151
|
+
end
|
152
|
+
|
153
|
+
it "reports the priority as tag on the transaction" do
|
154
|
+
tags = { :priority => 10, :queue => queue }
|
155
|
+
expect(Appsignal).to receive(:increment_counter)
|
156
|
+
.with("active_job_queue_job_count", 1, tags.merge(:status => :processed))
|
157
|
+
|
158
|
+
perform_job(ActiveJobPriorityTestJob)
|
159
|
+
|
160
|
+
transaction = last_transaction
|
161
|
+
transaction_hash = transaction.to_h
|
162
|
+
expect(transaction_hash).to include(
|
163
|
+
"sample_data" => hash_including(
|
164
|
+
"tags" => { "queue" => queue, "priority" => 10 }
|
165
|
+
)
|
166
|
+
)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
111
171
|
context "with error" do
|
112
172
|
it "reports the error on the transaction from the ActiveRecord integration" do
|
173
|
+
allow(Appsignal).to receive(:increment_counter) # Other calls we're testing in another test
|
174
|
+
tags = { :queue => queue }
|
175
|
+
expect(Appsignal).to receive(:increment_counter)
|
176
|
+
.with("active_job_queue_job_count", 1, tags.merge(:status => :failed))
|
177
|
+
expect(Appsignal).to receive(:increment_counter)
|
178
|
+
.with("active_job_queue_job_count", 1, tags.merge(:status => :processed))
|
179
|
+
|
113
180
|
expect do
|
114
181
|
perform_job(ActiveJobErrorTestJob)
|
115
182
|
end.to raise_error(RuntimeError, "uh oh")
|
@@ -127,9 +194,7 @@ if DependencyHelper.active_job_present?
|
|
127
194
|
"metadata" => {},
|
128
195
|
"sample_data" => hash_including(
|
129
196
|
"params" => [],
|
130
|
-
"tags" => {
|
131
|
-
"queue" => "default"
|
132
|
-
}
|
197
|
+
"tags" => { "queue" => queue }
|
133
198
|
)
|
134
199
|
)
|
135
200
|
events = transaction_hash["events"]
|
@@ -162,9 +227,7 @@ if DependencyHelper.active_job_present?
|
|
162
227
|
"metadata" => {},
|
163
228
|
"sample_data" => hash_including(
|
164
229
|
"params" => [],
|
165
|
-
"tags" => {
|
166
|
-
"queue" => "default"
|
167
|
-
}
|
230
|
+
"tags" => { "queue" => queue }
|
168
231
|
)
|
169
232
|
)
|
170
233
|
events = transaction_hash["events"]
|
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: 2.11.0.beta.
|
4
|
+
version: 2.11.0.beta.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Beekman
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-07-
|
13
|
+
date: 2020-07-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|