appsignal 2.11.0-java → 2.11.4-java

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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -0
  3. data/.semaphore/semaphore.yml +197 -0
  4. data/CHANGELOG.md +19 -0
  5. data/README.md +16 -1
  6. data/Rakefile +20 -11
  7. data/build_matrix.yml +13 -0
  8. data/ext/agent.yml +17 -25
  9. data/ext/appsignal_extension.c +1 -1
  10. data/ext/base.rb +12 -9
  11. data/gemfiles/no_dependencies.gemfile +7 -0
  12. data/gemfiles/resque-2.gemfile +0 -1
  13. data/gemfiles/webmachine.gemfile +1 -0
  14. data/lib/appsignal/cli/diagnose/utils.rb +8 -11
  15. data/lib/appsignal/cli/install.rb +5 -8
  16. data/lib/appsignal/helpers/instrumentation.rb +32 -0
  17. data/lib/appsignal/hooks.rb +1 -0
  18. data/lib/appsignal/hooks/action_mailer.rb +22 -0
  19. data/lib/appsignal/hooks/active_support_notifications.rb +72 -0
  20. data/lib/appsignal/hooks/shoryuken.rb +43 -4
  21. data/lib/appsignal/integrations/object.rb +4 -34
  22. data/lib/appsignal/integrations/object_ruby_19.rb +37 -0
  23. data/lib/appsignal/integrations/object_ruby_modern.rb +64 -0
  24. data/lib/appsignal/system.rb +4 -0
  25. data/lib/appsignal/transaction.rb +30 -2
  26. data/lib/appsignal/version.rb +1 -1
  27. data/spec/lib/appsignal/hooks/action_mailer_spec.rb +54 -0
  28. data/spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb +35 -0
  29. data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +145 -0
  30. data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +69 -0
  31. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +9 -137
  32. data/spec/lib/appsignal/hooks/resque_spec.rb +10 -2
  33. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +151 -104
  34. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +4 -2
  35. data/spec/lib/appsignal/integrations/object_19_spec.rb +266 -0
  36. data/spec/lib/appsignal/integrations/object_spec.rb +29 -10
  37. data/spec/lib/appsignal/transaction_spec.rb +55 -0
  38. data/spec/lib/appsignal_spec.rb +30 -0
  39. data/spec/support/helpers/dependency_helper.rb +4 -0
  40. metadata +16 -3
@@ -1,18 +1,30 @@
1
1
  require "appsignal/integrations/object"
2
2
 
3
+ def is_ruby_19
4
+ RUBY_VERSION < "2.0"
5
+ end
6
+
3
7
  describe Object do
4
8
  describe "#instrument_method" do
5
9
  context "with instance method" do
6
10
  let(:klass) do
7
11
  Class.new do
8
- def foo
9
- 1
12
+ def foo(param1, options = {}, keyword_param: 1)
13
+ [param1, options, keyword_param]
10
14
  end
11
15
  appsignal_instrument_method :foo
12
16
  end
13
17
  end
14
18
  let(:instance) { klass.new }
15
19
 
20
+ def call_with_arguments
21
+ instance.foo(
22
+ "abc",
23
+ { :foo => "bar" },
24
+ :keyword_param => 2
25
+ )
26
+ end
27
+
16
28
  context "when active" do
17
29
  let(:transaction) { http_request_transaction }
18
30
  before do
@@ -27,7 +39,7 @@ describe Object do
27
39
  expect(transaction).to receive(:start_event)
28
40
  expect(transaction).to receive(:finish_event).with \
29
41
  "foo.AnonymousClass.other", nil, nil, Appsignal::EventFormatter::DEFAULT
30
- expect(instance.foo).to eq(1)
42
+ expect(call_with_arguments).to eq(["abc", { :foo => "bar" }, 2])
31
43
  end
32
44
  end
33
45
 
@@ -116,10 +128,10 @@ describe Object do
116
128
  context "when not active" do
117
129
  let(:transaction) { Appsignal::Transaction.current }
118
130
 
119
- it "should not instrument, but still call the method" do
131
+ it "does not instrument, but still calls the method" do
120
132
  expect(Appsignal.active?).to be_falsy
121
133
  expect(transaction).to_not receive(:start_event)
122
- expect(instance.foo).to eq(1)
134
+ expect(call_with_arguments).to eq(["abc", { :foo => "bar" }, 2])
123
135
  end
124
136
  end
125
137
  end
@@ -127,12 +139,19 @@ describe Object do
127
139
  context "with class method" do
128
140
  let(:klass) do
129
141
  Class.new do
130
- def self.bar
131
- 2
142
+ def self.bar(param1, options = {}, keyword_param: 1)
143
+ [param1, options, keyword_param]
132
144
  end
133
145
  appsignal_instrument_class_method :bar
134
146
  end
135
147
  end
148
+ def call_with_arguments
149
+ klass.bar(
150
+ "abc",
151
+ { :foo => "bar" },
152
+ :keyword_param => 2
153
+ )
154
+ end
136
155
 
137
156
  context "when active" do
138
157
  let(:transaction) { http_request_transaction }
@@ -149,7 +168,7 @@ describe Object do
149
168
  expect(transaction).to receive(:start_event)
150
169
  expect(transaction).to receive(:finish_event).with \
151
170
  "bar.class_method.AnonymousClass.other", nil, nil, Appsignal::EventFormatter::DEFAULT
152
- expect(klass.bar).to eq(2)
171
+ expect(call_with_arguments).to eq(["abc", { :foo => "bar" }, 2])
153
172
  end
154
173
  end
155
174
 
@@ -238,10 +257,10 @@ describe Object do
238
257
  context "when not active" do
239
258
  let(:transaction) { Appsignal::Transaction.current }
240
259
 
241
- it "should not instrument, but still call the method" do
260
+ it "does not instrument, but still call the method" do
242
261
  expect(Appsignal.active?).to be_falsy
243
262
  expect(transaction).to_not receive(:start_event)
244
- expect(klass.bar).to eq(2)
263
+ expect(call_with_arguments).to eq(["abc", { :foo => "bar" }, 2])
245
264
  end
246
265
  end
247
266
  end
@@ -356,6 +356,57 @@ describe Appsignal::Transaction do
356
356
  end
357
357
  end
358
358
 
359
+ describe "#add_breadcrumb" do
360
+ context "when over the limit" do
361
+ before do
362
+ 22.times do |i|
363
+ transaction.add_breadcrumb(
364
+ "network",
365
+ "GET http://localhost",
366
+ "User made external network request",
367
+ { :code => i + 1 },
368
+ Time.parse("10-10-2010 10:00:00 UTC")
369
+ )
370
+ end
371
+ transaction.sample_data
372
+ end
373
+
374
+ it "stores last <LIMIT> breadcrumbs on the transaction" do
375
+ expect(transaction.to_h["sample_data"]["breadcrumbs"].length).to eql(20)
376
+ expect(transaction.to_h["sample_data"]["breadcrumbs"][0]).to eq(
377
+ "action" => "GET http://localhost",
378
+ "category" => "network",
379
+ "message" => "User made external network request",
380
+ "metadata" => { "code" => 3 },
381
+ "time" => 1286704800 # rubocop:disable Style/NumericLiterals
382
+ )
383
+ expect(transaction.to_h["sample_data"]["breadcrumbs"][19]).to eq(
384
+ "action" => "GET http://localhost",
385
+ "category" => "network",
386
+ "message" => "User made external network request",
387
+ "metadata" => { "code" => 22 },
388
+ "time" => 1286704800 # rubocop:disable Style/NumericLiterals
389
+ )
390
+ end
391
+ end
392
+
393
+ context "with defaults" do
394
+ it "stores breadcrumb with defaults on transaction" do
395
+ timeframe_start = Time.now.utc.to_i
396
+ transaction.add_breadcrumb("user_action", "clicked HOME")
397
+ transaction.sample_data
398
+ timeframe_end = Time.now.utc.to_i
399
+
400
+ breadcrumb = transaction.to_h["sample_data"]["breadcrumbs"][0]
401
+ expect(breadcrumb["category"]).to eq("user_action")
402
+ expect(breadcrumb["action"]).to eq("clicked HOME")
403
+ expect(breadcrumb["message"]).to eq("")
404
+ expect(breadcrumb["time"]).to be_between(timeframe_start, timeframe_end)
405
+ expect(breadcrumb["metadata"]).to eq({})
406
+ end
407
+ end
408
+ end
409
+
359
410
  describe "#set_action" do
360
411
  context "when the action is set" do
361
412
  it "updates the action name on the transaction" do
@@ -649,6 +700,10 @@ describe Appsignal::Transaction do
649
700
  "tags",
650
701
  Appsignal::Utils::Data.generate({})
651
702
  ).once
703
+ expect(transaction.ext).to receive(:set_sample_data).with(
704
+ "breadcrumbs",
705
+ Appsignal::Utils::Data.generate([])
706
+ ).once
652
707
 
653
708
  transaction.sample_data
654
709
  end
@@ -491,6 +491,36 @@ describe Appsignal do
491
491
  end
492
492
  end
493
493
 
494
+ describe ".add_breadcrumb" do
495
+ before { allow(Appsignal::Transaction).to receive(:current).and_return(transaction) }
496
+
497
+ context "with transaction" do
498
+ let(:transaction) { double }
499
+ it "should call add_breadcrumb on transaction" do
500
+ expect(transaction).to receive(:add_breadcrumb)
501
+ .with("Network", "http", "User made network request", { :response => 200 }, fixed_time)
502
+ end
503
+
504
+ after do
505
+ Appsignal.add_breadcrumb(
506
+ "Network",
507
+ "http",
508
+ "User made network request",
509
+ { :response => 200 },
510
+ fixed_time
511
+ )
512
+ end
513
+ end
514
+
515
+ context "without transaction" do
516
+ let(:transaction) { nil }
517
+
518
+ it "should not call add_breadcrumb on transaction" do
519
+ expect(Appsignal.add_breadcrumb("Network", "http")).to be_falsy
520
+ end
521
+ end
522
+ end
523
+
494
524
  describe "custom stats" do
495
525
  let(:tags) { { :foo => "bar" } }
496
526
 
@@ -37,6 +37,10 @@ module DependencyHelper
37
37
  dependency_present? "actioncable"
38
38
  end
39
39
 
40
+ def action_mailer_present?
41
+ dependency_present? "actionmailer"
42
+ end
43
+
40
44
  def active_job_present?
41
45
  dependency_present? "activejob"
42
46
  end
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
4
+ version: 2.11.4
5
5
  platform: java
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-08-11 00:00:00.000000000 Z
13
+ date: 2021-01-21 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
@@ -246,6 +247,8 @@ files:
246
247
  - lib/appsignal/integrations/grape.rb
247
248
  - lib/appsignal/integrations/mongo_ruby_driver.rb
248
249
  - lib/appsignal/integrations/object.rb
250
+ - lib/appsignal/integrations/object_ruby_19.rb
251
+ - lib/appsignal/integrations/object_ruby_modern.rb
249
252
  - lib/appsignal/integrations/padrino.rb
250
253
  - lib/appsignal/integrations/que.rb
251
254
  - lib/appsignal/integrations/railtie.rb
@@ -309,6 +312,10 @@ files:
309
312
  - spec/lib/appsignal/extension_spec.rb
310
313
  - spec/lib/appsignal/garbage_collection_profiler_spec.rb
311
314
  - spec/lib/appsignal/hooks/action_cable_spec.rb
315
+ - spec/lib/appsignal/hooks/action_mailer_spec.rb
316
+ - spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb
317
+ - spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb
318
+ - spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb
312
319
  - spec/lib/appsignal/hooks/active_support_notifications_spec.rb
313
320
  - spec/lib/appsignal/hooks/activejob_spec.rb
314
321
  - spec/lib/appsignal/hooks/celluloid_spec.rb
@@ -331,6 +338,7 @@ files:
331
338
  - spec/lib/appsignal/integrations/data_mapper_spec.rb
332
339
  - spec/lib/appsignal/integrations/grape_spec.rb
333
340
  - spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb
341
+ - spec/lib/appsignal/integrations/object_19_spec.rb
334
342
  - spec/lib/appsignal/integrations/object_spec.rb
335
343
  - spec/lib/appsignal/integrations/padrino_spec.rb
336
344
  - spec/lib/appsignal/integrations/que_spec.rb
@@ -424,7 +432,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
424
432
  - !ruby/object:Gem::Version
425
433
  version: '0'
426
434
  requirements: []
427
- rubygems_version: 3.1.4
435
+ rubygems_version: 3.2.6
428
436
  signing_key:
429
437
  specification_version: 4
430
438
  summary: Logs performance and exception data from your app to appsignal.com
@@ -457,6 +465,10 @@ test_files:
457
465
  - spec/lib/appsignal/extension_spec.rb
458
466
  - spec/lib/appsignal/garbage_collection_profiler_spec.rb
459
467
  - spec/lib/appsignal/hooks/action_cable_spec.rb
468
+ - spec/lib/appsignal/hooks/action_mailer_spec.rb
469
+ - spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb
470
+ - spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb
471
+ - spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb
460
472
  - spec/lib/appsignal/hooks/active_support_notifications_spec.rb
461
473
  - spec/lib/appsignal/hooks/activejob_spec.rb
462
474
  - spec/lib/appsignal/hooks/celluloid_spec.rb
@@ -479,6 +491,7 @@ test_files:
479
491
  - spec/lib/appsignal/integrations/data_mapper_spec.rb
480
492
  - spec/lib/appsignal/integrations/grape_spec.rb
481
493
  - spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb
494
+ - spec/lib/appsignal/integrations/object_19_spec.rb
482
495
  - spec/lib/appsignal/integrations/object_spec.rb
483
496
  - spec/lib/appsignal/integrations/padrino_spec.rb
484
497
  - spec/lib/appsignal/integrations/que_spec.rb