appsignal 3.0.5-java → 3.0.6-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09c5ce0f8854cb5d1ad22ab9e47fddfe0e8d381be43237638919d0322d0fd76c'
4
- data.tar.gz: 7df48cb0e05e402266198605774661d3ab62dd3952e8770ec7ab4295ab9bed5a
3
+ metadata.gz: 3a1324bce086be01b0dfae65d0b46f4b985707ca35da77699cbe9f7335f84080
4
+ data.tar.gz: 4e74a0eaac0b0e6330ecfcbd63762d80359ff880395e66644d39db4879c823a8
5
5
  SHA512:
6
- metadata.gz: 4ed67f33ca42879f55229c6c56cc14facbef594a8b5571eb050b0d22f958c9fa8189a816a47ff7e38e9d57ed0a8858ffa9f64a0450382662fd8962028ae901e0
7
- data.tar.gz: 2e3c70b487c91c73d61e5d876cf053d4c6477505ec1d47f3766b7dd4afd9196b78f817def8440c3668609f16d09e468ef1fb7f8712a923bf6034def75dd5c0a2
6
+ metadata.gz: 6c9d4481e24413363bbfe8bfdb0486968d9b5bc45bd0e898e535762f9372e153dfa81890cc8a3f567a1a884f8ba431d5c7c1b543b61cb1eb6ced57a060372c00
7
+ data.tar.gz: 1b728a26ade2bbcdedea7d454e9bb7ad548c1931a2503b79a5ed265e6d768e9f403b268f7e4984a62c5d9f6c679c08fbf6fa23d0365592b6dd2c34b68013a0dd
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # AppSignal for Ruby gem Changelog
2
2
 
3
+ ## 3.0.6
4
+
5
+ - [d354d79b](https://github.com/appsignal/appsignal-ruby/commit/d354d79b293fd549e66cae60d805d1b1e9e9d2d8) patch - Add Excon integration. Track requests and responses from the Excon gem.
6
+ - [4c32e818](https://github.com/appsignal/appsignal-ruby/commit/4c32e8180b797d7987c67b68720c6a5d22935333) patch - Support Redis eval statements better by showing the actual script that was performed. Instead of showing `eval ? ? ?` (for a script with 2 arguments), show `<script> ? ?`, where `<script>` is whatever script was sent to `Redis.new.eval("<script>")`.
7
+
3
8
  ## 3.0.5
4
9
 
5
10
  - [4bddac36](https://github.com/appsignal/appsignal-ruby/commit/4bddac3618ccea03c165eec53cee90e222b68cd6) patch - Skip empty HTTP proxy config. When any of the HTTP proxy config returns an
@@ -108,3 +108,4 @@ require "appsignal/hooks/mongo_ruby_driver"
108
108
  require "appsignal/hooks/webmachine"
109
109
  require "appsignal/hooks/data_mapper"
110
110
  require "appsignal/hooks/que"
111
+ require "appsignal/hooks/excon"
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appsignal
4
+ class Hooks
5
+ # @api private
6
+ class ExconHook < Appsignal::Hooks::Hook
7
+ register :excon
8
+
9
+ def dependencies_present?
10
+ Appsignal.config && defined?(::Excon)
11
+ end
12
+
13
+ def install
14
+ require "appsignal/integrations/excon"
15
+ ::Excon.defaults[:instrumentor] = Appsignal::Integrations::ExconIntegration
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appsignal
4
+ module Integrations
5
+ module ExconIntegration
6
+ def self.instrument(name, data, &block)
7
+ namespace, *event = name.split(".")
8
+ rails_name = [event, namespace].flatten.join(".")
9
+
10
+ title =
11
+ if rails_name == "response.excon"
12
+ data[:host]
13
+ else
14
+ "#{data[:method].to_s.upcase} #{data[:scheme]}://#{data[:host]}"
15
+ end
16
+ Appsignal.instrument(rails_name, title, &block)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -3,12 +3,15 @@
3
3
  module Appsignal
4
4
  module Integrations
5
5
  module RedisIntegration
6
- def process(commands, &block)
7
- sanitized_commands = commands.map do |command, *args|
8
- "#{command}#{" ?" * args.size}"
9
- end.join("\n")
6
+ def write(command)
7
+ sanitized_command =
8
+ if command[0] == :eval
9
+ "#{command[1]}#{" ?" * (command.size - 3)}"
10
+ else
11
+ "#{command[0]}#{" ?" * (command.size - 1)}"
12
+ end
10
13
 
11
- Appsignal.instrument "query.redis", id, sanitized_commands do
14
+ Appsignal.instrument "query.redis", id, sanitized_command do
12
15
  super
13
16
  end
14
17
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- VERSION = "3.0.5".freeze
4
+ VERSION = "3.0.6".freeze
5
5
  end
@@ -0,0 +1,74 @@
1
+ describe Appsignal::Hooks::ExconHook do
2
+ before :context do
3
+ start_agent
4
+ end
5
+
6
+ context "with Excon" do
7
+ before(:context) do
8
+ class Excon
9
+ def self.defaults
10
+ @defaults ||= {}
11
+ end
12
+ end
13
+ Appsignal::Hooks::ExconHook.new.install
14
+ end
15
+ after(:context) { Object.send(:remove_const, :Excon) }
16
+
17
+ describe "#dependencies_present?" do
18
+ subject { described_class.new.dependencies_present? }
19
+
20
+ it { is_expected.to be_truthy }
21
+ end
22
+
23
+ describe "#install" do
24
+ it "adds the AppSignal instrumentor to Excon" do
25
+ expect(Excon.defaults[:instrumentor]).to eql(Appsignal::Integrations::ExconIntegration)
26
+ end
27
+ end
28
+
29
+ describe "instrumentation" do
30
+ let!(:transaction) do
31
+ Appsignal::Transaction.create("uuid", Appsignal::Transaction::HTTP_REQUEST, "test")
32
+ end
33
+ around { |example| keep_transactions { example.run } }
34
+
35
+ it "instruments a http request" do
36
+ data = {
37
+ :host => "www.google.com",
38
+ :method => :get,
39
+ :scheme => "http"
40
+ }
41
+ Excon.defaults[:instrumentor].instrument("excon.request", data) {}
42
+
43
+ expect(transaction.to_h["events"]).to include(
44
+ hash_including(
45
+ "name" => "request.excon",
46
+ "title" => "GET http://www.google.com",
47
+ "body" => ""
48
+ )
49
+ )
50
+ end
51
+
52
+ it "instruments a http response" do
53
+ data = { :host => "www.google.com" }
54
+ Excon.defaults[:instrumentor].instrument("excon.response", data) {}
55
+
56
+ expect(transaction.to_h["events"]).to include(
57
+ hash_including(
58
+ "name" => "response.excon",
59
+ "title" => "www.google.com",
60
+ "body" => ""
61
+ )
62
+ )
63
+ end
64
+ end
65
+ end
66
+
67
+ context "without Excon" do
68
+ describe "#dependencies_present?" do
69
+ subject { described_class.new.dependencies_present? }
70
+
71
+ it { is_expected.to be_falsy }
72
+ end
73
+ end
74
+ end
@@ -33,16 +33,17 @@ describe Appsignal::Hooks::RedisHook do
33
33
 
34
34
  context "instrumentation" do
35
35
  before do
36
+ start_agent
36
37
  # Stub Redis::Client class so that it doesn't perform an actual
37
38
  # Redis query. This class will be included (prepended) with the
38
39
  # AppSignal Redis integration.
39
40
  stub_const("Redis::Client", Class.new do
40
41
  def id
41
- :stub_id
42
+ "stub_id"
42
43
  end
43
44
 
44
- def process(_commands)
45
- :stub_process
45
+ def write(_commands)
46
+ "stub_write"
46
47
  end
47
48
  end)
48
49
  # Load the integration again for the stubbed Redis::Client class.
@@ -50,17 +51,40 @@ describe Appsignal::Hooks::RedisHook do
50
51
  # track if it was installed already or not.
51
52
  Appsignal::Hooks::RedisHook.new.install
52
53
  end
54
+ let!(:transaction) do
55
+ Appsignal::Transaction.create("uuid", Appsignal::Transaction::HTTP_REQUEST, "test")
56
+ end
57
+ around { |example| keep_transactions { example.run } }
53
58
 
54
59
  it "instrument a redis call" do
55
- Appsignal::Transaction.create("uuid", Appsignal::Transaction::HTTP_REQUEST, "test")
56
- expect(Appsignal::Transaction.current).to receive(:start_event)
57
- .at_least(:once)
58
- expect(Appsignal::Transaction.current).to receive(:finish_event)
59
- .at_least(:once)
60
- .with("query.redis", :stub_id, "get ?", 0)
60
+ client = Redis::Client.new
61
+ expect(client.write([:get, "key"])).to eql("stub_write")
61
62
 
63
+ transaction_hash = transaction.to_h
64
+ expect(transaction_hash["events"]).to include(
65
+ hash_including(
66
+ "name" => "query.redis",
67
+ "body" => "get ?",
68
+ "title" => "stub_id"
69
+ )
70
+ )
71
+ end
72
+
73
+ it "instrument a redis script call" do
62
74
  client = Redis::Client.new
63
- expect(client.process([[:get, "key"]])).to eql(:stub_process)
75
+ script = "return redis.call('set',KEYS[1],ARGV[1])"
76
+ keys = ["foo"]
77
+ argv = ["bar"]
78
+ expect(client.write([:eval, script, keys.size, keys, argv])).to eql("stub_write")
79
+
80
+ transaction_hash = transaction.to_h
81
+ expect(transaction_hash["events"]).to include(
82
+ hash_including(
83
+ "name" => "query.redis",
84
+ "body" => "#{script} ? ?",
85
+ "title" => "stub_id"
86
+ )
87
+ )
64
88
  end
65
89
  end
66
90
  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: 3.0.5
4
+ version: 3.0.6
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: 2021-05-21 00:00:00.000000000 Z
13
+ date: 2021-05-31 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
@@ -224,6 +224,7 @@ files:
224
224
  - lib/appsignal/hooks/celluloid.rb
225
225
  - lib/appsignal/hooks/data_mapper.rb
226
226
  - lib/appsignal/hooks/delayed_job.rb
227
+ - lib/appsignal/hooks/excon.rb
227
228
  - lib/appsignal/hooks/mongo_ruby_driver.rb
228
229
  - lib/appsignal/hooks/net_http.rb
229
230
  - lib/appsignal/hooks/passenger.rb
@@ -243,6 +244,7 @@ files:
243
244
  - lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
244
245
  - lib/appsignal/integrations/data_mapper.rb
245
246
  - lib/appsignal/integrations/delayed_job_plugin.rb
247
+ - lib/appsignal/integrations/excon.rb
246
248
  - lib/appsignal/integrations/grape.rb
247
249
  - lib/appsignal/integrations/mongo_ruby_driver.rb
248
250
  - lib/appsignal/integrations/net_http.rb
@@ -319,6 +321,7 @@ files:
319
321
  - spec/lib/appsignal/hooks/celluloid_spec.rb
320
322
  - spec/lib/appsignal/hooks/data_mapper_spec.rb
321
323
  - spec/lib/appsignal/hooks/delayed_job_spec.rb
324
+ - spec/lib/appsignal/hooks/excon_spec.rb
322
325
  - spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
323
326
  - spec/lib/appsignal/hooks/net_http_spec.rb
324
327
  - spec/lib/appsignal/hooks/passenger_spec.rb
@@ -467,6 +470,7 @@ test_files:
467
470
  - spec/lib/appsignal/hooks/celluloid_spec.rb
468
471
  - spec/lib/appsignal/hooks/data_mapper_spec.rb
469
472
  - spec/lib/appsignal/hooks/delayed_job_spec.rb
473
+ - spec/lib/appsignal/hooks/excon_spec.rb
470
474
  - spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
471
475
  - spec/lib/appsignal/hooks/net_http_spec.rb
472
476
  - spec/lib/appsignal/hooks/passenger_spec.rb