appsignal 2.11.0-java → 2.11.1.beta.2-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +7 -1
- data/Rakefile +11 -5
- data/ext/agent.yml +17 -25
- data/ext/appsignal_extension.c +1 -1
- data/lib/appsignal/hooks.rb +1 -0
- data/lib/appsignal/hooks/action_mailer.rb +22 -0
- data/lib/appsignal/hooks/active_support_notifications.rb +72 -0
- data/lib/appsignal/version.rb +1 -1
- data/spec/lib/appsignal/hooks/action_mailer_spec.rb +54 -0
- data/spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb +35 -0
- data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +145 -0
- data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +69 -0
- data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +9 -137
- data/spec/support/helpers/dependency_helper.rb +4 -0
- metadata +17 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39550ae73032457877f07d154e3d1cce26102d81c06a824d73f23dd167cc4e62
|
4
|
+
data.tar.gz: b9ac926d2970b7411ae6c43251069f1c1ef30792babbd38dd7f109be6add0d16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9774fa709aa0d1f03ebc4648c3ef84c721676c63970bbf9c9c1d1a0715a178ae3bcd78caa18d96591bd441f241191e2bbbba35576023a574cedeb4d93edca70
|
7
|
+
data.tar.gz: 314ed92a0db002ad311958b585fc9c90c61c2cc593ece93b174453473b42cacde2c6561a7e275ce4effb4060494a55192916bcd3cff83f13b740db262a94c187
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
# 2.11.1
|
4
|
+
- Support AS notifications instrumenters that use `start` and `finish`.
|
5
|
+
- Updated agent with better logging and an IO stats fix.
|
6
|
+
- ActionMailer magic dashboard
|
7
|
+
|
3
8
|
# 2.11.0
|
4
9
|
- Track queue time regardless of namespace. Support custom namespaces. PR #602
|
5
10
|
- Improve deprecation message from frontend error middleware. PR #620
|
data/README.md
CHANGED
@@ -219,12 +219,18 @@ BUNDLE_GEMFILE=gemfiles/capistrano3.gemfile bundle exec rspec
|
|
219
219
|
BUNDLE_GEMFILE=gemfiles/grape.gemfile bundle exec rspec
|
220
220
|
BUNDLE_GEMFILE=gemfiles/no_dependencies.gemfile bundle exec rspec
|
221
221
|
BUNDLE_GEMFILE=gemfiles/padrino.gemfile bundle exec rspec
|
222
|
+
BUNDLE_GEMFILE=gemfiles/que.gemfile bundle exec rspec
|
223
|
+
BUNDLE_GEMFILE=gemfiles/que_beta.gemfile bundle exec rspec
|
222
224
|
BUNDLE_GEMFILE=gemfiles/rails-3.2.gemfile bundle exec rspec
|
223
225
|
BUNDLE_GEMFILE=gemfiles/rails-4.0.gemfile bundle exec rspec
|
224
226
|
BUNDLE_GEMFILE=gemfiles/rails-4.1.gemfile bundle exec rspec
|
225
227
|
BUNDLE_GEMFILE=gemfiles/rails-4.2.gemfile bundle exec rspec
|
226
228
|
BUNDLE_GEMFILE=gemfiles/rails-5.0.gemfile bundle exec rspec
|
227
|
-
BUNDLE_GEMFILE=gemfiles/
|
229
|
+
BUNDLE_GEMFILE=gemfiles/rails-5.1.gemfile bundle exec rspec
|
230
|
+
BUNDLE_GEMFILE=gemfiles/rails-5.2.gemfile bundle exec rspec
|
231
|
+
BUNDLE_GEMFILE=gemfiles/rails-6.0.gemfile bundle exec rspec
|
232
|
+
BUNDLE_GEMFILE=gemfiles/resque-1.gemfile bundle exec rspec
|
233
|
+
BUNDLE_GEMFILE=gemfiles/resque-2.gemfile bundle exec rspec
|
228
234
|
BUNDLE_GEMFILE=gemfiles/sequel-435.gemfile bundle exec rspec
|
229
235
|
BUNDLE_GEMFILE=gemfiles/sequel.gemfile bundle exec rspec
|
230
236
|
BUNDLE_GEMFILE=gemfiles/sinatra.gemfile bundle exec rspec
|
data/Rakefile
CHANGED
@@ -39,6 +39,10 @@ def build_task(ruby_version, type = nil)
|
|
39
39
|
}
|
40
40
|
end
|
41
41
|
|
42
|
+
def gems_with_gemfiles
|
43
|
+
YAML.load_file("build_matrix.yml")["matrix"]["gems"].map { |g| g["gem"] }.freeze
|
44
|
+
end
|
45
|
+
|
42
46
|
namespace :build_matrix do
|
43
47
|
namespace :semaphore do
|
44
48
|
task :generate do
|
@@ -310,17 +314,19 @@ task :publish => [
|
|
310
314
|
desc "Install the AppSignal gem, extension and all possible dependencies."
|
311
315
|
task :install => "extension:install" do
|
312
316
|
Bundler.with_clean_env do
|
313
|
-
|
317
|
+
gems_with_gemfiles.each do |gemfile|
|
314
318
|
system "bundle --gemfile gemfiles/#{gemfile}.gemfile"
|
315
319
|
end
|
316
320
|
end
|
317
321
|
end
|
318
322
|
|
319
323
|
task :spec_all_gemfiles do
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
+
Bundler.with_clean_env do
|
325
|
+
gems_with_gemfiles.each do |gemfile|
|
326
|
+
puts "Running tests for #{gemfile}"
|
327
|
+
unless system("env BUNDLE_GEMFILE=gemfiles/#{gemfile}.gemfile bundle exec rspec")
|
328
|
+
raise "Not successful"
|
329
|
+
end
|
324
330
|
end
|
325
331
|
end
|
326
332
|
end
|
data/ext/agent.yml
CHANGED
@@ -1,70 +1,62 @@
|
|
1
1
|
---
|
2
|
-
version:
|
2
|
+
version: 361340a
|
3
3
|
mirrors:
|
4
4
|
- https://appsignal-agent-releases.global.ssl.fastly.net
|
5
5
|
- https://d135dj0rjqvssy.cloudfront.net
|
6
6
|
triples:
|
7
7
|
x86_64-darwin:
|
8
8
|
static:
|
9
|
-
checksum:
|
9
|
+
checksum: 4e08cb0cef0ea7e30f8d507380b923f6cfa14adaea12c81804e118acd6395b57
|
10
10
|
filename: appsignal-x86_64-darwin-all-static.tar.gz
|
11
11
|
dynamic:
|
12
|
-
checksum:
|
12
|
+
checksum: 1a9c3e26bd453fe60a2f511d536e64bdeddb1f939664bda90d6a41eaeedf5250
|
13
13
|
filename: appsignal-x86_64-darwin-all-dynamic.tar.gz
|
14
14
|
universal-darwin:
|
15
15
|
static:
|
16
|
-
checksum:
|
16
|
+
checksum: 4e08cb0cef0ea7e30f8d507380b923f6cfa14adaea12c81804e118acd6395b57
|
17
17
|
filename: appsignal-x86_64-darwin-all-static.tar.gz
|
18
18
|
dynamic:
|
19
|
-
checksum:
|
19
|
+
checksum: 1a9c3e26bd453fe60a2f511d536e64bdeddb1f939664bda90d6a41eaeedf5250
|
20
20
|
filename: appsignal-x86_64-darwin-all-dynamic.tar.gz
|
21
21
|
i686-linux:
|
22
22
|
static:
|
23
|
-
checksum:
|
23
|
+
checksum: 01c027b3e472cb39d844284fcc8ba532628c00731b912e0e9718646ed124ae6e
|
24
24
|
filename: appsignal-i686-linux-all-static.tar.gz
|
25
25
|
dynamic:
|
26
|
-
checksum:
|
26
|
+
checksum: 30696eac3ae5646bcb21ff86a1824dd4511a41dd323514e4a97a41b5ff09e2f8
|
27
27
|
filename: appsignal-i686-linux-all-dynamic.tar.gz
|
28
28
|
x86-linux:
|
29
29
|
static:
|
30
|
-
checksum:
|
30
|
+
checksum: 01c027b3e472cb39d844284fcc8ba532628c00731b912e0e9718646ed124ae6e
|
31
31
|
filename: appsignal-i686-linux-all-static.tar.gz
|
32
32
|
dynamic:
|
33
|
-
checksum:
|
33
|
+
checksum: 30696eac3ae5646bcb21ff86a1824dd4511a41dd323514e4a97a41b5ff09e2f8
|
34
34
|
filename: appsignal-i686-linux-all-dynamic.tar.gz
|
35
|
-
i686-linux-musl:
|
36
|
-
static:
|
37
|
-
checksum: 28b69e895da6b2a30402eed29cf8c3bbc4f647d6ce9cc5e0b11b4a771d7a1021
|
38
|
-
filename: appsignal-i686-linux-musl-all-static.tar.gz
|
39
|
-
x86-linux-musl:
|
40
|
-
static:
|
41
|
-
checksum: 28b69e895da6b2a30402eed29cf8c3bbc4f647d6ce9cc5e0b11b4a771d7a1021
|
42
|
-
filename: appsignal-i686-linux-musl-all-static.tar.gz
|
43
35
|
x86_64-linux:
|
44
36
|
static:
|
45
|
-
checksum:
|
37
|
+
checksum: fe2038d6fa468fc23900fea6d8179d2b37d41d54f4ff33c573116183ac1cb491
|
46
38
|
filename: appsignal-x86_64-linux-all-static.tar.gz
|
47
39
|
dynamic:
|
48
|
-
checksum:
|
40
|
+
checksum: bcbf9546b078fb8bbaae5e7df4ed84831346c814bc865a47d32a3a095a84acbb
|
49
41
|
filename: appsignal-x86_64-linux-all-dynamic.tar.gz
|
50
42
|
x86_64-linux-musl:
|
51
43
|
static:
|
52
|
-
checksum:
|
44
|
+
checksum: b2ee5579a62b76a1d2f41f4e06749c4c549f9aaa40764862eff49c5a6a8841f1
|
53
45
|
filename: appsignal-x86_64-linux-musl-all-static.tar.gz
|
54
46
|
dynamic:
|
55
|
-
checksum:
|
47
|
+
checksum: 53cd2464853e61c2d8f911ec32ff98cb48f824293ffd575da6743bc34625a7eb
|
56
48
|
filename: appsignal-x86_64-linux-musl-all-dynamic.tar.gz
|
57
49
|
x86_64-freebsd:
|
58
50
|
static:
|
59
|
-
checksum:
|
51
|
+
checksum: f228dd2f2cf951c9eb9f04487be50fdfdc3d29a956e639787a4022bd73f02e53
|
60
52
|
filename: appsignal-x86_64-freebsd-all-static.tar.gz
|
61
53
|
dynamic:
|
62
|
-
checksum:
|
54
|
+
checksum: 030b322b2cb15607260cbb0424c03f6e41646dca7aacc43a30279ad63a336541
|
63
55
|
filename: appsignal-x86_64-freebsd-all-dynamic.tar.gz
|
64
56
|
amd64-freebsd:
|
65
57
|
static:
|
66
|
-
checksum:
|
58
|
+
checksum: f228dd2f2cf951c9eb9f04487be50fdfdc3d29a956e639787a4022bd73f02e53
|
67
59
|
filename: appsignal-x86_64-freebsd-all-static.tar.gz
|
68
60
|
dynamic:
|
69
|
-
checksum:
|
61
|
+
checksum: 030b322b2cb15607260cbb0424c03f6e41646dca7aacc43a30279ad63a336541
|
70
62
|
filename: appsignal-x86_64-freebsd-all-dynamic.tar.gz
|
data/ext/appsignal_extension.c
CHANGED
@@ -485,7 +485,7 @@ static VALUE data_append_boolean(VALUE self, VALUE value) {
|
|
485
485
|
return Qnil;
|
486
486
|
}
|
487
487
|
|
488
|
-
static VALUE data_append_nil(VALUE self
|
488
|
+
static VALUE data_append_nil(VALUE self) {
|
489
489
|
appsignal_data_t* data;
|
490
490
|
|
491
491
|
Data_Get_Struct(self, appsignal_data_t, data);
|
data/lib/appsignal/hooks.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Appsignal
|
2
|
+
class Hooks
|
3
|
+
class ActionMailerHook < Appsignal::Hooks::Hook
|
4
|
+
register :action_mailer
|
5
|
+
|
6
|
+
def dependencies_present?
|
7
|
+
defined?(::ActionMailer)
|
8
|
+
end
|
9
|
+
|
10
|
+
def install
|
11
|
+
ActiveSupport::Notifications
|
12
|
+
.subscribe("process.action_mailer") do |_, _, _, _, payload|
|
13
|
+
Appsignal.increment_counter(
|
14
|
+
:action_mailer_process,
|
15
|
+
1,
|
16
|
+
:mailer => payload[:mailer], :action => payload[:action]
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -23,6 +23,21 @@ module Appsignal
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
instrumenter = ::ActiveSupport::Notifications::Instrumenter
|
27
|
+
|
28
|
+
if instrumenter.method_defined?(:start) && instrumenter.method_defined?(:finish)
|
29
|
+
install_start_finish
|
30
|
+
else
|
31
|
+
install_instrument
|
32
|
+
end
|
33
|
+
|
34
|
+
# rubocop:disable Style/GuardClause
|
35
|
+
if instrumenter.method_defined?(:finish_with_state)
|
36
|
+
install_finish_with_state
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def install_instrument
|
26
41
|
::ActiveSupport::Notifications::Instrumenter.class_eval do
|
27
42
|
alias instrument_without_appsignal instrument
|
28
43
|
|
@@ -46,6 +61,63 @@ module Appsignal
|
|
46
61
|
end
|
47
62
|
end
|
48
63
|
end
|
64
|
+
|
65
|
+
def install_start_finish
|
66
|
+
::ActiveSupport::Notifications::Instrumenter.class_eval do
|
67
|
+
alias start_without_appsignal start
|
68
|
+
|
69
|
+
def start(name, payload = {})
|
70
|
+
# Events that start with a bang are internal to Rails
|
71
|
+
instrument_this = name[0] != BANG
|
72
|
+
|
73
|
+
Appsignal::Transaction.current.start_event if instrument_this
|
74
|
+
|
75
|
+
start_without_appsignal(name, payload)
|
76
|
+
end
|
77
|
+
|
78
|
+
alias finish_without_appsignal finish
|
79
|
+
|
80
|
+
def finish(name, payload = {})
|
81
|
+
# Events that start with a bang are internal to Rails
|
82
|
+
instrument_this = name[0] != BANG
|
83
|
+
|
84
|
+
if instrument_this
|
85
|
+
title, body, body_format = Appsignal::EventFormatter.format(name, payload)
|
86
|
+
Appsignal::Transaction.current.finish_event(
|
87
|
+
name.to_s,
|
88
|
+
title,
|
89
|
+
body,
|
90
|
+
body_format
|
91
|
+
)
|
92
|
+
end
|
93
|
+
|
94
|
+
finish_without_appsignal(name, payload)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def install_finish_with_state
|
100
|
+
::ActiveSupport::Notifications::Instrumenter.class_eval do
|
101
|
+
alias finish_with_state_without_appsignal finish_with_state
|
102
|
+
|
103
|
+
def finish_with_state(listeners_state, name, payload = {})
|
104
|
+
# Events that start with a bang are internal to Rails
|
105
|
+
instrument_this = name[0] != BANG
|
106
|
+
|
107
|
+
if instrument_this
|
108
|
+
title, body, body_format = Appsignal::EventFormatter.format(name, payload)
|
109
|
+
Appsignal::Transaction.current.finish_event(
|
110
|
+
name.to_s,
|
111
|
+
title,
|
112
|
+
body,
|
113
|
+
body_format
|
114
|
+
)
|
115
|
+
end
|
116
|
+
|
117
|
+
finish_with_state_without_appsignal(listeners_state, name, payload)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
49
121
|
end
|
50
122
|
end
|
51
123
|
end
|
data/lib/appsignal/version.rb
CHANGED
@@ -0,0 +1,54 @@
|
|
1
|
+
describe Appsignal::Hooks::ActionMailerHook do
|
2
|
+
if DependencyHelper.action_mailer_present? &&
|
3
|
+
DependencyHelper.rails_version >= Gem::Version.new("4.0.0")
|
4
|
+
context "with ActionMailer" do
|
5
|
+
require "action_mailer"
|
6
|
+
|
7
|
+
class UserMailer < ActionMailer::Base
|
8
|
+
default :from => "test@example.com"
|
9
|
+
|
10
|
+
def welcome
|
11
|
+
mail(:to => "test@example.com", :subject => "ActionMailer test", :content_type => "text/html") do |format|
|
12
|
+
format.html { render :html => "This is a test" }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
UserMailer.delivery_method = :test
|
17
|
+
|
18
|
+
describe ".dependencies_present?" do
|
19
|
+
subject { described_class.new.dependencies_present? }
|
20
|
+
|
21
|
+
it "returns true" do
|
22
|
+
is_expected.to be_truthy
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe ".install" do
|
27
|
+
before do
|
28
|
+
start_agent
|
29
|
+
expect(Appsignal.active?).to be_truthy
|
30
|
+
end
|
31
|
+
|
32
|
+
it "is subscribed to 'process.action_mailer' and processes instrumentation" do
|
33
|
+
expect(Appsignal).to receive(:increment_counter).with(
|
34
|
+
:action_mailer_process,
|
35
|
+
1,
|
36
|
+
:mailer => "UserMailer", :action => :welcome
|
37
|
+
)
|
38
|
+
|
39
|
+
UserMailer.welcome.deliver_now
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
else
|
44
|
+
context "without ActionMailer" do
|
45
|
+
describe ".dependencies_present?" do
|
46
|
+
subject { described_class.new.dependencies_present? }
|
47
|
+
|
48
|
+
it "returns false" do
|
49
|
+
is_expected.to be_falsy
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
shared_examples "activesupport finish_with_state override" do
|
2
|
+
let(:instrumenter) { as.instrumenter }
|
3
|
+
|
4
|
+
it "instruments an ActiveSupport::Notifications.start/finish event with payload on finish" do
|
5
|
+
listeners_state = instrumenter.start("sql.active_record", {})
|
6
|
+
instrumenter.finish_with_state(listeners_state, "sql.active_record", :sql => "SQL")
|
7
|
+
|
8
|
+
expect(transaction.to_h["events"]).to match([
|
9
|
+
{
|
10
|
+
"allocation_count" => kind_of(Integer),
|
11
|
+
"body" => "SQL",
|
12
|
+
"body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
|
13
|
+
"child_allocation_count" => kind_of(Integer),
|
14
|
+
"child_duration" => kind_of(Float),
|
15
|
+
"child_gc_duration" => kind_of(Float),
|
16
|
+
"count" => 1,
|
17
|
+
"duration" => kind_of(Float),
|
18
|
+
"gc_duration" => kind_of(Float),
|
19
|
+
"name" => "sql.active_record",
|
20
|
+
"start" => kind_of(Float),
|
21
|
+
"title" => ""
|
22
|
+
}
|
23
|
+
])
|
24
|
+
end
|
25
|
+
|
26
|
+
it "does not instrument events whose name starts with a bang" do
|
27
|
+
expect(Appsignal::Transaction.current).not_to receive(:start_event)
|
28
|
+
expect(Appsignal::Transaction.current).not_to receive(:finish_event)
|
29
|
+
|
30
|
+
listeners_state = instrumenter.start("!sql.active_record", {})
|
31
|
+
instrumenter.finish_with_state(listeners_state, "!sql.active_record", :sql => "SQL")
|
32
|
+
|
33
|
+
expect(transaction.to_h["events"]).to be_empty
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
shared_examples "activesupport instrument override" do
|
2
|
+
it "instruments an ActiveSupport::Notifications.instrument event" do
|
3
|
+
return_value = as.instrument("sql.active_record", :sql => "SQL") do
|
4
|
+
"value"
|
5
|
+
end
|
6
|
+
|
7
|
+
expect(return_value).to eq "value"
|
8
|
+
expect(transaction.to_h["events"]).to match([
|
9
|
+
{
|
10
|
+
"allocation_count" => kind_of(Integer),
|
11
|
+
"body" => "SQL",
|
12
|
+
"body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
|
13
|
+
"child_allocation_count" => kind_of(Integer),
|
14
|
+
"child_duration" => kind_of(Float),
|
15
|
+
"child_gc_duration" => kind_of(Float),
|
16
|
+
"count" => 1,
|
17
|
+
"duration" => kind_of(Float),
|
18
|
+
"gc_duration" => kind_of(Float),
|
19
|
+
"name" => "sql.active_record",
|
20
|
+
"start" => kind_of(Float),
|
21
|
+
"title" => ""
|
22
|
+
}
|
23
|
+
])
|
24
|
+
end
|
25
|
+
|
26
|
+
it "instruments an ActiveSupport::Notifications.instrument event with no registered formatter" do
|
27
|
+
return_value = as.instrument("no-registered.formatter", :key => "something") do
|
28
|
+
"value"
|
29
|
+
end
|
30
|
+
|
31
|
+
expect(return_value).to eq "value"
|
32
|
+
expect(transaction.to_h["events"]).to match([
|
33
|
+
{
|
34
|
+
"allocation_count" => kind_of(Integer),
|
35
|
+
"body" => "",
|
36
|
+
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
37
|
+
"child_allocation_count" => kind_of(Integer),
|
38
|
+
"child_duration" => kind_of(Float),
|
39
|
+
"child_gc_duration" => kind_of(Float),
|
40
|
+
"count" => 1,
|
41
|
+
"duration" => kind_of(Float),
|
42
|
+
"gc_duration" => kind_of(Float),
|
43
|
+
"name" => "no-registered.formatter",
|
44
|
+
"start" => kind_of(Float),
|
45
|
+
"title" => ""
|
46
|
+
}
|
47
|
+
])
|
48
|
+
end
|
49
|
+
|
50
|
+
it "converts non-string names to strings" do
|
51
|
+
as.instrument(:not_a_string) {}
|
52
|
+
expect(transaction.to_h["events"]).to match([
|
53
|
+
{
|
54
|
+
"allocation_count" => kind_of(Integer),
|
55
|
+
"body" => "",
|
56
|
+
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
57
|
+
"child_allocation_count" => kind_of(Integer),
|
58
|
+
"child_duration" => kind_of(Float),
|
59
|
+
"child_gc_duration" => kind_of(Float),
|
60
|
+
"count" => 1,
|
61
|
+
"duration" => kind_of(Float),
|
62
|
+
"gc_duration" => kind_of(Float),
|
63
|
+
"name" => "not_a_string",
|
64
|
+
"start" => kind_of(Float),
|
65
|
+
"title" => ""
|
66
|
+
}
|
67
|
+
])
|
68
|
+
end
|
69
|
+
|
70
|
+
it "does not instrument events whose name starts with a bang" do
|
71
|
+
expect(Appsignal::Transaction.current).not_to receive(:start_event)
|
72
|
+
expect(Appsignal::Transaction.current).not_to receive(:finish_event)
|
73
|
+
|
74
|
+
return_value = as.instrument("!sql.active_record", :sql => "SQL") do
|
75
|
+
"value"
|
76
|
+
end
|
77
|
+
|
78
|
+
expect(return_value).to eq "value"
|
79
|
+
end
|
80
|
+
|
81
|
+
context "when an error is raised in an instrumented block" do
|
82
|
+
it "instruments an ActiveSupport::Notifications.instrument event" do
|
83
|
+
expect do
|
84
|
+
as.instrument("sql.active_record", :sql => "SQL") do
|
85
|
+
raise ExampleException, "foo"
|
86
|
+
end
|
87
|
+
end.to raise_error(ExampleException, "foo")
|
88
|
+
|
89
|
+
expect(transaction.to_h["events"]).to match([
|
90
|
+
{
|
91
|
+
"allocation_count" => kind_of(Integer),
|
92
|
+
"body" => "SQL",
|
93
|
+
"body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
|
94
|
+
"child_allocation_count" => kind_of(Integer),
|
95
|
+
"child_duration" => kind_of(Float),
|
96
|
+
"child_gc_duration" => kind_of(Float),
|
97
|
+
"count" => 1,
|
98
|
+
"duration" => kind_of(Float),
|
99
|
+
"gc_duration" => kind_of(Float),
|
100
|
+
"name" => "sql.active_record",
|
101
|
+
"start" => kind_of(Float),
|
102
|
+
"title" => ""
|
103
|
+
}
|
104
|
+
])
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context "when a message is thrown in an instrumented block" do
|
109
|
+
it "instruments an ActiveSupport::Notifications.instrument event" do
|
110
|
+
expect do
|
111
|
+
as.instrument("sql.active_record", :sql => "SQL") do
|
112
|
+
throw :foo
|
113
|
+
end
|
114
|
+
end.to throw_symbol(:foo)
|
115
|
+
|
116
|
+
expect(transaction.to_h["events"]).to match([
|
117
|
+
{
|
118
|
+
"allocation_count" => kind_of(Integer),
|
119
|
+
"body" => "SQL",
|
120
|
+
"body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
|
121
|
+
"child_allocation_count" => kind_of(Integer),
|
122
|
+
"child_duration" => kind_of(Float),
|
123
|
+
"child_gc_duration" => kind_of(Float),
|
124
|
+
"count" => 1,
|
125
|
+
"duration" => kind_of(Float),
|
126
|
+
"gc_duration" => kind_of(Float),
|
127
|
+
"name" => "sql.active_record",
|
128
|
+
"start" => kind_of(Float),
|
129
|
+
"title" => ""
|
130
|
+
}
|
131
|
+
])
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
context "when a transaction is completed in an instrumented block" do
|
136
|
+
it "does not complete the ActiveSupport::Notifications.instrument event" do
|
137
|
+
expect(transaction).to receive(:complete)
|
138
|
+
as.instrument("sql.active_record", :sql => "SQL") do
|
139
|
+
Appsignal::Transaction.complete_current!
|
140
|
+
end
|
141
|
+
|
142
|
+
expect(transaction.to_h["events"]).to match([])
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
shared_examples "activesupport start finish override" do
|
2
|
+
let(:instrumenter) { as.instrumenter }
|
3
|
+
|
4
|
+
it "instruments an ActiveSupport::Notifications.start/finish event with payload on start ignores payload" do
|
5
|
+
instrumenter.start("sql.active_record", :sql => "SQL")
|
6
|
+
instrumenter.finish("sql.active_record", {})
|
7
|
+
|
8
|
+
expect(transaction.to_h["events"]).to match([
|
9
|
+
{
|
10
|
+
"allocation_count" => kind_of(Integer),
|
11
|
+
"body" => "",
|
12
|
+
"body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
|
13
|
+
"child_allocation_count" => kind_of(Integer),
|
14
|
+
"child_duration" => kind_of(Float),
|
15
|
+
"child_gc_duration" => kind_of(Float),
|
16
|
+
"count" => 1,
|
17
|
+
"duration" => kind_of(Float),
|
18
|
+
"gc_duration" => kind_of(Float),
|
19
|
+
"name" => "sql.active_record",
|
20
|
+
"start" => kind_of(Float),
|
21
|
+
"title" => ""
|
22
|
+
}
|
23
|
+
])
|
24
|
+
end
|
25
|
+
|
26
|
+
it "instruments an ActiveSupport::Notifications.start/finish event with payload on finish" do
|
27
|
+
instrumenter.start("sql.active_record", {})
|
28
|
+
instrumenter.finish("sql.active_record", :sql => "SQL")
|
29
|
+
|
30
|
+
expect(transaction.to_h["events"]).to match([
|
31
|
+
{
|
32
|
+
"allocation_count" => kind_of(Integer),
|
33
|
+
"body" => "SQL",
|
34
|
+
"body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
|
35
|
+
"child_allocation_count" => kind_of(Integer),
|
36
|
+
"child_duration" => kind_of(Float),
|
37
|
+
"child_gc_duration" => kind_of(Float),
|
38
|
+
"count" => 1,
|
39
|
+
"duration" => kind_of(Float),
|
40
|
+
"gc_duration" => kind_of(Float),
|
41
|
+
"name" => "sql.active_record",
|
42
|
+
"start" => kind_of(Float),
|
43
|
+
"title" => ""
|
44
|
+
}
|
45
|
+
])
|
46
|
+
end
|
47
|
+
|
48
|
+
it "does not instrument events whose name starts with a bang" do
|
49
|
+
expect(Appsignal::Transaction.current).not_to receive(:start_event)
|
50
|
+
expect(Appsignal::Transaction.current).not_to receive(:finish_event)
|
51
|
+
|
52
|
+
instrumenter.start("!sql.active_record", {})
|
53
|
+
instrumenter.finish("!sql.active_record", {})
|
54
|
+
|
55
|
+
expect(transaction.to_h["events"]).to be_empty
|
56
|
+
end
|
57
|
+
|
58
|
+
context "when a transaction is completed in an instrumented block" do
|
59
|
+
it "does not complete the ActiveSupport::Notifications.instrument event" do
|
60
|
+
expect(transaction).to receive(:complete)
|
61
|
+
|
62
|
+
instrumenter.start("sql.active_record", {})
|
63
|
+
Appsignal::Transaction.complete_current!
|
64
|
+
instrumenter.finish("sql.active_record", {})
|
65
|
+
|
66
|
+
expect(transaction.to_h["events"]).to match([])
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative "./active_support_notifications/instrument_shared_examples"
|
2
|
+
|
1
3
|
describe Appsignal::Hooks::ActiveSupportNotificationsHook do
|
2
4
|
if active_support_present?
|
3
5
|
let(:notifier) { ActiveSupport::Notifications::Fanout.new }
|
@@ -18,148 +20,18 @@ describe Appsignal::Hooks::ActiveSupportNotificationsHook do
|
|
18
20
|
it { is_expected.to be_truthy }
|
19
21
|
end
|
20
22
|
|
21
|
-
|
22
|
-
return_value = as.instrument("sql.active_record", :sql => "SQL") do
|
23
|
-
"value"
|
24
|
-
end
|
25
|
-
|
26
|
-
expect(return_value).to eq "value"
|
27
|
-
expect(transaction.to_h["events"]).to match([
|
28
|
-
{
|
29
|
-
"allocation_count" => kind_of(Integer),
|
30
|
-
"body" => "SQL",
|
31
|
-
"body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
|
32
|
-
"child_allocation_count" => kind_of(Integer),
|
33
|
-
"child_duration" => kind_of(Float),
|
34
|
-
"child_gc_duration" => kind_of(Float),
|
35
|
-
"count" => 1,
|
36
|
-
"duration" => kind_of(Float),
|
37
|
-
"gc_duration" => kind_of(Float),
|
38
|
-
"name" => "sql.active_record",
|
39
|
-
"start" => kind_of(Float),
|
40
|
-
"title" => ""
|
41
|
-
}
|
42
|
-
])
|
43
|
-
end
|
44
|
-
|
45
|
-
it "instruments an ActiveSupport::Notifications.instrument event with no registered formatter" do
|
46
|
-
return_value = as.instrument("no-registered.formatter", :key => "something") do
|
47
|
-
"value"
|
48
|
-
end
|
49
|
-
|
50
|
-
expect(return_value).to eq "value"
|
51
|
-
expect(transaction.to_h["events"]).to match([
|
52
|
-
{
|
53
|
-
"allocation_count" => kind_of(Integer),
|
54
|
-
"body" => "",
|
55
|
-
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
56
|
-
"child_allocation_count" => kind_of(Integer),
|
57
|
-
"child_duration" => kind_of(Float),
|
58
|
-
"child_gc_duration" => kind_of(Float),
|
59
|
-
"count" => 1,
|
60
|
-
"duration" => kind_of(Float),
|
61
|
-
"gc_duration" => kind_of(Float),
|
62
|
-
"name" => "no-registered.formatter",
|
63
|
-
"start" => kind_of(Float),
|
64
|
-
"title" => ""
|
65
|
-
}
|
66
|
-
])
|
67
|
-
end
|
68
|
-
|
69
|
-
it "converts non-string names to strings" do
|
70
|
-
as.instrument(:not_a_string) {}
|
71
|
-
expect(transaction.to_h["events"]).to match([
|
72
|
-
{
|
73
|
-
"allocation_count" => kind_of(Integer),
|
74
|
-
"body" => "",
|
75
|
-
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
76
|
-
"child_allocation_count" => kind_of(Integer),
|
77
|
-
"child_duration" => kind_of(Float),
|
78
|
-
"child_gc_duration" => kind_of(Float),
|
79
|
-
"count" => 1,
|
80
|
-
"duration" => kind_of(Float),
|
81
|
-
"gc_duration" => kind_of(Float),
|
82
|
-
"name" => "not_a_string",
|
83
|
-
"start" => kind_of(Float),
|
84
|
-
"title" => ""
|
85
|
-
}
|
86
|
-
])
|
87
|
-
end
|
88
|
-
|
89
|
-
it "does not instrument events whose name starts with a bang" do
|
90
|
-
expect(Appsignal::Transaction.current).not_to receive(:start_event)
|
91
|
-
expect(Appsignal::Transaction.current).not_to receive(:finish_event)
|
92
|
-
|
93
|
-
return_value = as.instrument("!sql.active_record", :sql => "SQL") do
|
94
|
-
"value"
|
95
|
-
end
|
96
|
-
|
97
|
-
expect(return_value).to eq "value"
|
98
|
-
end
|
99
|
-
|
100
|
-
context "when an error is raised in an instrumented block" do
|
101
|
-
it "instruments an ActiveSupport::Notifications.instrument event" do
|
102
|
-
expect do
|
103
|
-
as.instrument("sql.active_record", :sql => "SQL") do
|
104
|
-
raise ExampleException, "foo"
|
105
|
-
end
|
106
|
-
end.to raise_error(ExampleException, "foo")
|
107
|
-
|
108
|
-
expect(transaction.to_h["events"]).to match([
|
109
|
-
{
|
110
|
-
"allocation_count" => kind_of(Integer),
|
111
|
-
"body" => "SQL",
|
112
|
-
"body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
|
113
|
-
"child_allocation_count" => kind_of(Integer),
|
114
|
-
"child_duration" => kind_of(Float),
|
115
|
-
"child_gc_duration" => kind_of(Float),
|
116
|
-
"count" => 1,
|
117
|
-
"duration" => kind_of(Float),
|
118
|
-
"gc_duration" => kind_of(Float),
|
119
|
-
"name" => "sql.active_record",
|
120
|
-
"start" => kind_of(Float),
|
121
|
-
"title" => ""
|
122
|
-
}
|
123
|
-
])
|
124
|
-
end
|
125
|
-
end
|
23
|
+
it_behaves_like "activesupport instrument override"
|
126
24
|
|
127
|
-
|
128
|
-
|
129
|
-
expect do
|
130
|
-
as.instrument("sql.active_record", :sql => "SQL") do
|
131
|
-
throw :foo
|
132
|
-
end
|
133
|
-
end.to throw_symbol(:foo)
|
25
|
+
if ::ActiveSupport::Notifications::Instrumenter.method_defined?(:start)
|
26
|
+
require_relative "./active_support_notifications/start_finish_shared_examples"
|
134
27
|
|
135
|
-
|
136
|
-
{
|
137
|
-
"allocation_count" => kind_of(Integer),
|
138
|
-
"body" => "SQL",
|
139
|
-
"body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
|
140
|
-
"child_allocation_count" => kind_of(Integer),
|
141
|
-
"child_duration" => kind_of(Float),
|
142
|
-
"child_gc_duration" => kind_of(Float),
|
143
|
-
"count" => 1,
|
144
|
-
"duration" => kind_of(Float),
|
145
|
-
"gc_duration" => kind_of(Float),
|
146
|
-
"name" => "sql.active_record",
|
147
|
-
"start" => kind_of(Float),
|
148
|
-
"title" => ""
|
149
|
-
}
|
150
|
-
])
|
151
|
-
end
|
28
|
+
it_behaves_like "activesupport start finish override"
|
152
29
|
end
|
153
30
|
|
154
|
-
|
155
|
-
|
156
|
-
expect(transaction).to receive(:complete)
|
157
|
-
as.instrument("sql.active_record", :sql => "SQL") do
|
158
|
-
Appsignal::Transaction.complete_current!
|
159
|
-
end
|
31
|
+
if ::ActiveSupport::Notifications::Instrumenter.method_defined?(:finish_with_state)
|
32
|
+
require_relative "./active_support_notifications/finish_with_state_shared_examples"
|
160
33
|
|
161
|
-
|
162
|
-
end
|
34
|
+
it_behaves_like "activesupport finish_with_state override"
|
163
35
|
end
|
164
36
|
else
|
165
37
|
describe "#dependencies_present?" do
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appsignal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.11.
|
4
|
+
version: 2.11.1.beta.2
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Robert Beekman
|
8
8
|
- Thijs Cadier
|
9
9
|
- Tom de Bruijn
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-
|
13
|
+
date: 2020-12-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|
@@ -221,6 +221,7 @@ files:
|
|
221
221
|
- lib/appsignal/helpers/metrics.rb
|
222
222
|
- lib/appsignal/hooks.rb
|
223
223
|
- lib/appsignal/hooks/action_cable.rb
|
224
|
+
- lib/appsignal/hooks/action_mailer.rb
|
224
225
|
- lib/appsignal/hooks/active_job.rb
|
225
226
|
- lib/appsignal/hooks/active_support_notifications.rb
|
226
227
|
- lib/appsignal/hooks/celluloid.rb
|
@@ -309,6 +310,10 @@ files:
|
|
309
310
|
- spec/lib/appsignal/extension_spec.rb
|
310
311
|
- spec/lib/appsignal/garbage_collection_profiler_spec.rb
|
311
312
|
- spec/lib/appsignal/hooks/action_cable_spec.rb
|
313
|
+
- spec/lib/appsignal/hooks/action_mailer_spec.rb
|
314
|
+
- spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb
|
315
|
+
- spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb
|
316
|
+
- spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb
|
312
317
|
- spec/lib/appsignal/hooks/active_support_notifications_spec.rb
|
313
318
|
- spec/lib/appsignal/hooks/activejob_spec.rb
|
314
319
|
- spec/lib/appsignal/hooks/celluloid_spec.rb
|
@@ -408,7 +413,7 @@ metadata:
|
|
408
413
|
documentation_uri: https://docs.appsignal.com/ruby/
|
409
414
|
homepage_uri: https://docs.appsignal.com/ruby/
|
410
415
|
source_code_uri: https://github.com/appsignal/appsignal-ruby
|
411
|
-
post_install_message:
|
416
|
+
post_install_message:
|
412
417
|
rdoc_options: []
|
413
418
|
require_paths:
|
414
419
|
- lib
|
@@ -420,12 +425,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
420
425
|
version: '1.9'
|
421
426
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
422
427
|
requirements:
|
423
|
-
- - "
|
428
|
+
- - ">"
|
424
429
|
- !ruby/object:Gem::Version
|
425
|
-
version:
|
430
|
+
version: 1.3.1
|
426
431
|
requirements: []
|
427
|
-
rubygems_version: 3.1.
|
428
|
-
signing_key:
|
432
|
+
rubygems_version: 3.1.2
|
433
|
+
signing_key:
|
429
434
|
specification_version: 4
|
430
435
|
summary: Logs performance and exception data from your app to appsignal.com
|
431
436
|
test_files:
|
@@ -457,6 +462,10 @@ test_files:
|
|
457
462
|
- spec/lib/appsignal/extension_spec.rb
|
458
463
|
- spec/lib/appsignal/garbage_collection_profiler_spec.rb
|
459
464
|
- spec/lib/appsignal/hooks/action_cable_spec.rb
|
465
|
+
- spec/lib/appsignal/hooks/action_mailer_spec.rb
|
466
|
+
- spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb
|
467
|
+
- spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb
|
468
|
+
- spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb
|
460
469
|
- spec/lib/appsignal/hooks/active_support_notifications_spec.rb
|
461
470
|
- spec/lib/appsignal/hooks/activejob_spec.rb
|
462
471
|
- spec/lib/appsignal/hooks/celluloid_spec.rb
|