appsignal 2.11.1.beta.2-java → 2.11.5-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.
@@ -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
 
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.1.beta.2
4
+ version: 2.11.5
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-12-15 00:00:00.000000000 Z
13
+ date: 2021-01-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
@@ -247,6 +247,8 @@ files:
247
247
  - lib/appsignal/integrations/grape.rb
248
248
  - lib/appsignal/integrations/mongo_ruby_driver.rb
249
249
  - lib/appsignal/integrations/object.rb
250
+ - lib/appsignal/integrations/object_ruby_19.rb
251
+ - lib/appsignal/integrations/object_ruby_modern.rb
250
252
  - lib/appsignal/integrations/padrino.rb
251
253
  - lib/appsignal/integrations/que.rb
252
254
  - lib/appsignal/integrations/railtie.rb
@@ -336,6 +338,7 @@ files:
336
338
  - spec/lib/appsignal/integrations/data_mapper_spec.rb
337
339
  - spec/lib/appsignal/integrations/grape_spec.rb
338
340
  - spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb
341
+ - spec/lib/appsignal/integrations/object_19_spec.rb
339
342
  - spec/lib/appsignal/integrations/object_spec.rb
340
343
  - spec/lib/appsignal/integrations/padrino_spec.rb
341
344
  - spec/lib/appsignal/integrations/que_spec.rb
@@ -413,7 +416,7 @@ metadata:
413
416
  documentation_uri: https://docs.appsignal.com/ruby/
414
417
  homepage_uri: https://docs.appsignal.com/ruby/
415
418
  source_code_uri: https://github.com/appsignal/appsignal-ruby
416
- post_install_message:
419
+ post_install_message:
417
420
  rdoc_options: []
418
421
  require_paths:
419
422
  - lib
@@ -425,12 +428,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
425
428
  version: '1.9'
426
429
  required_rubygems_version: !ruby/object:Gem::Requirement
427
430
  requirements:
428
- - - ">"
431
+ - - ">="
429
432
  - !ruby/object:Gem::Version
430
- version: 1.3.1
433
+ version: '0'
431
434
  requirements: []
432
- rubygems_version: 3.1.2
433
- signing_key:
435
+ rubygems_version: 3.2.6
436
+ signing_key:
434
437
  specification_version: 4
435
438
  summary: Logs performance and exception data from your app to appsignal.com
436
439
  test_files:
@@ -488,6 +491,7 @@ test_files:
488
491
  - spec/lib/appsignal/integrations/data_mapper_spec.rb
489
492
  - spec/lib/appsignal/integrations/grape_spec.rb
490
493
  - spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb
494
+ - spec/lib/appsignal/integrations/object_19_spec.rb
491
495
  - spec/lib/appsignal/integrations/object_spec.rb
492
496
  - spec/lib/appsignal/integrations/padrino_spec.rb
493
497
  - spec/lib/appsignal/integrations/que_spec.rb