appsignal 3.0.5 → 3.0.6
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 +5 -0
- data/lib/appsignal/hooks.rb +1 -0
- data/lib/appsignal/hooks/excon.rb +19 -0
- data/lib/appsignal/integrations/excon.rb +20 -0
- data/lib/appsignal/integrations/redis.rb +8 -5
- data/lib/appsignal/version.rb +1 -1
- data/spec/lib/appsignal/hooks/excon_spec.rb +74 -0
- data/spec/lib/appsignal/hooks/redis_spec.rb +34 -10
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7497a8e24e7219e936d3056dfa2c835b35b40faec1f8e9502dcc93e7ec7b7b5
|
4
|
+
data.tar.gz: 4e74a0eaac0b0e6330ecfcbd63762d80359ff880395e66644d39db4879c823a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c4ee25807db79abac6b10cf247deaef410c2108cd05500dc2bf1d78f5c2989c6e7fd2f249f4bc5016a542a41a467cb078bea7565ae5485fa5d997d62c44f06b
|
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
|
data/lib/appsignal/hooks.rb
CHANGED
@@ -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
|
7
|
-
|
8
|
-
|
9
|
-
|
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,
|
14
|
+
Appsignal.instrument "query.redis", id, sanitized_command do
|
12
15
|
super
|
13
16
|
end
|
14
17
|
end
|
data/lib/appsignal/version.rb
CHANGED
@@ -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
|
-
|
42
|
+
"stub_id"
|
42
43
|
end
|
43
44
|
|
44
|
-
def
|
45
|
-
|
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
|
-
|
56
|
-
expect(
|
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
|
-
|
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.
|
4
|
+
version: 3.0.6
|
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: 2021-05-
|
13
|
+
date: 2021-05-31 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|
@@ -210,6 +210,7 @@ files:
|
|
210
210
|
- lib/appsignal/hooks/celluloid.rb
|
211
211
|
- lib/appsignal/hooks/data_mapper.rb
|
212
212
|
- lib/appsignal/hooks/delayed_job.rb
|
213
|
+
- lib/appsignal/hooks/excon.rb
|
213
214
|
- lib/appsignal/hooks/mongo_ruby_driver.rb
|
214
215
|
- lib/appsignal/hooks/net_http.rb
|
215
216
|
- lib/appsignal/hooks/passenger.rb
|
@@ -229,6 +230,7 @@ files:
|
|
229
230
|
- lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
|
230
231
|
- lib/appsignal/integrations/data_mapper.rb
|
231
232
|
- lib/appsignal/integrations/delayed_job_plugin.rb
|
233
|
+
- lib/appsignal/integrations/excon.rb
|
232
234
|
- lib/appsignal/integrations/grape.rb
|
233
235
|
- lib/appsignal/integrations/mongo_ruby_driver.rb
|
234
236
|
- lib/appsignal/integrations/net_http.rb
|
@@ -305,6 +307,7 @@ files:
|
|
305
307
|
- spec/lib/appsignal/hooks/celluloid_spec.rb
|
306
308
|
- spec/lib/appsignal/hooks/data_mapper_spec.rb
|
307
309
|
- spec/lib/appsignal/hooks/delayed_job_spec.rb
|
310
|
+
- spec/lib/appsignal/hooks/excon_spec.rb
|
308
311
|
- spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
|
309
312
|
- spec/lib/appsignal/hooks/net_http_spec.rb
|
310
313
|
- spec/lib/appsignal/hooks/passenger_spec.rb
|
@@ -453,6 +456,7 @@ test_files:
|
|
453
456
|
- spec/lib/appsignal/hooks/celluloid_spec.rb
|
454
457
|
- spec/lib/appsignal/hooks/data_mapper_spec.rb
|
455
458
|
- spec/lib/appsignal/hooks/delayed_job_spec.rb
|
459
|
+
- spec/lib/appsignal/hooks/excon_spec.rb
|
456
460
|
- spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
|
457
461
|
- spec/lib/appsignal/hooks/net_http_spec.rb
|
458
462
|
- spec/lib/appsignal/hooks/passenger_spec.rb
|