appsignal 2.1.2 → 2.2.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +14 -0
- data/.rubocop_todo.yml +16 -171
- data/.travis.yml +14 -1
- data/.yardopts +8 -0
- data/CHANGELOG.md +21 -3
- data/README.md +20 -2
- data/Rakefile +60 -62
- data/appsignal.gemspec +24 -23
- data/ext/agent.yml +11 -11
- data/ext/appsignal_extension.c +43 -12
- data/ext/extconf.rb +9 -9
- data/gemfiles/padrino.gemfile +1 -1
- data/lib/appsignal.rb +403 -26
- data/lib/appsignal/auth_check.rb +28 -1
- data/lib/appsignal/cli.rb +1 -0
- data/lib/appsignal/cli/demo.rb +40 -0
- data/lib/appsignal/cli/diagnose.rb +345 -89
- data/lib/appsignal/cli/helpers.rb +9 -4
- data/lib/appsignal/cli/install.rb +6 -6
- data/lib/appsignal/cli/notify_of_deploy.rb +58 -0
- data/lib/appsignal/config.rb +40 -38
- data/lib/appsignal/demo.rb +20 -0
- data/lib/appsignal/event_formatter.rb +4 -0
- data/lib/appsignal/event_formatter/action_view/render_formatter.rb +1 -0
- data/lib/appsignal/event_formatter/active_record/instantiation_formatter.rb +1 -0
- data/lib/appsignal/event_formatter/active_record/sql_formatter.rb +1 -0
- data/lib/appsignal/event_formatter/elastic_search/search_formatter.rb +1 -0
- data/lib/appsignal/event_formatter/faraday/request_formatter.rb +1 -0
- data/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter.rb +2 -1
- data/lib/appsignal/event_formatter/moped/query_formatter.rb +1 -0
- data/lib/appsignal/extension.rb +1 -0
- data/lib/appsignal/garbage_collection_profiler.rb +20 -19
- data/lib/appsignal/hooks.rb +1 -0
- data/lib/appsignal/hooks/active_support_notifications.rb +1 -0
- data/lib/appsignal/hooks/celluloid.rb +1 -0
- data/lib/appsignal/hooks/data_mapper.rb +1 -0
- data/lib/appsignal/hooks/delayed_job.rb +1 -0
- data/lib/appsignal/hooks/mongo_ruby_driver.rb +1 -0
- data/lib/appsignal/hooks/net_http.rb +1 -0
- data/lib/appsignal/hooks/passenger.rb +1 -0
- data/lib/appsignal/hooks/puma.rb +1 -0
- data/lib/appsignal/hooks/rake.rb +1 -0
- data/lib/appsignal/hooks/redis.rb +1 -0
- data/lib/appsignal/hooks/sequel.rb +1 -0
- data/lib/appsignal/hooks/shoryuken.rb +1 -0
- data/lib/appsignal/hooks/sidekiq.rb +1 -0
- data/lib/appsignal/hooks/unicorn.rb +1 -0
- data/lib/appsignal/hooks/webmachine.rb +1 -0
- data/lib/appsignal/integrations/capistrano/appsignal.cap +4 -4
- data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +2 -0
- data/lib/appsignal/integrations/data_mapper.rb +1 -1
- data/lib/appsignal/integrations/delayed_job_plugin.rb +1 -0
- data/lib/appsignal/integrations/grape.rb +3 -1
- data/lib/appsignal/integrations/mongo_ruby_driver.rb +1 -0
- data/lib/appsignal/integrations/padrino.rb +36 -21
- data/lib/appsignal/integrations/railtie.rb +2 -2
- data/lib/appsignal/integrations/resque.rb +1 -0
- data/lib/appsignal/integrations/resque_active_job.rb +1 -0
- data/lib/appsignal/integrations/webmachine.rb +27 -24
- data/lib/appsignal/js_exception_transaction.rb +8 -8
- data/lib/appsignal/marker.rb +41 -4
- data/lib/appsignal/minutely.rb +1 -0
- data/lib/appsignal/rack/generic_instrumentation.rb +3 -2
- data/lib/appsignal/rack/js_exception_catcher.rb +55 -15
- data/lib/appsignal/rack/rails_instrumentation.rb +2 -1
- data/lib/appsignal/rack/sinatra_instrumentation.rb +4 -2
- data/lib/appsignal/rack/streaming_listener.rb +4 -2
- data/lib/appsignal/system.rb +5 -31
- data/lib/appsignal/transaction.rb +71 -6
- data/lib/appsignal/transmitter.rb +24 -13
- data/lib/appsignal/utils.rb +18 -11
- data/lib/appsignal/utils/params_sanitizer.rb +2 -1
- data/lib/appsignal/utils/query_params_sanitizer.rb +1 -0
- data/lib/appsignal/version.rb +1 -1
- data/resources/appsignal.yml.erb +1 -1
- data/spec/lib/appsignal/auth_check_spec.rb +64 -22
- data/spec/lib/appsignal/cli/diagnose_spec.rb +539 -81
- data/spec/lib/appsignal/cli/helpers_spec.rb +74 -2
- data/spec/lib/appsignal/cli/install_spec.rb +3 -3
- data/spec/lib/appsignal/config_spec.rb +38 -72
- data/spec/lib/appsignal/demo_spec.rb +2 -2
- data/spec/lib/appsignal/event_formatter_spec.rb +2 -2
- data/spec/lib/appsignal/extension_spec.rb +4 -0
- data/spec/lib/appsignal/garbage_collection_profiler_spec.rb +18 -21
- data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +1 -1
- data/spec/lib/appsignal/hooks/redis_spec.rb +34 -44
- data/spec/lib/appsignal/hooks/sidekiq_spec.rb +2 -2
- data/spec/lib/appsignal/integrations/grape_spec.rb +6 -6
- data/spec/lib/appsignal/integrations/padrino_spec.rb +241 -122
- data/spec/lib/appsignal/integrations/railtie_spec.rb +34 -16
- data/spec/lib/appsignal/integrations/resque_spec.rb +1 -1
- data/spec/lib/appsignal/integrations/sinatra_spec.rb +38 -10
- data/spec/lib/appsignal/integrations/webmachine_spec.rb +2 -2
- data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +7 -6
- data/spec/lib/appsignal/rack/js_exception_catcher_spec.rb +95 -58
- data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +9 -6
- data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +11 -10
- data/spec/lib/appsignal/rack/streaming_listener_spec.rb +20 -13
- data/spec/lib/appsignal/system_spec.rb +2 -32
- data/spec/lib/appsignal/transaction_spec.rb +48 -7
- data/spec/lib/appsignal/transmitter_spec.rb +52 -33
- data/spec/lib/appsignal/utils/params_sanitizer_spec.rb +3 -1
- data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +3 -3
- data/spec/lib/appsignal/utils_spec.rb +49 -6
- data/spec/lib/appsignal_spec.rb +60 -5
- data/spec/spec_helper.rb +4 -3
- data/spec/support/helpers/api_request_helper.rb +1 -4
- data/spec/support/helpers/dependency_helper.rb +4 -0
- data/spec/support/helpers/system_helpers.rb +1 -17
- data/spec/support/helpers/time_helpers.rb +1 -1
- metadata +19 -8
- data/spec/lib/appsignal/system/container_spec.rb +0 -67
- data/spec/lib/appsignal/utils/gzip_spec.rb +0 -10
@@ -43,7 +43,7 @@ describe Appsignal::Utils::QueryParamsSanitizer do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
context "when value is an array" do
|
46
|
-
let(:value) {
|
46
|
+
let(:value) { %w(foo bar) }
|
47
47
|
|
48
48
|
it "should only return the first level of the object" do
|
49
49
|
expect(subject).to eq("?")
|
@@ -51,7 +51,7 @@ describe Appsignal::Utils::QueryParamsSanitizer do
|
|
51
51
|
|
52
52
|
it "should not modify source value" do
|
53
53
|
subject
|
54
|
-
expect(value).to eq(
|
54
|
+
expect(value).to eq(%w(foo bar))
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -115,7 +115,7 @@ describe Appsignal::Utils::QueryParamsSanitizer do
|
|
115
115
|
end
|
116
116
|
|
117
117
|
context "when value is an array" do
|
118
|
-
let(:value) {
|
118
|
+
let(:value) { %w(foo bar) }
|
119
119
|
|
120
120
|
it "should sanitize all hash values with a single questionmark" do
|
121
121
|
expect(subject).to eq(["?"])
|
@@ -8,7 +8,11 @@ describe Appsignal::Utils do
|
|
8
8
|
let(:body) do
|
9
9
|
{
|
10
10
|
"the" => "payload",
|
11
|
-
"int" => 1,
|
11
|
+
"int" => 1, # Fixnum
|
12
|
+
"int61" => 1 << 61, # Fixnum
|
13
|
+
"int62" => 1 << 62, # Bignum, this one still works
|
14
|
+
"int63" => 1 << 63, # Bignum, turnover point for C, too big for long
|
15
|
+
"int64" => 1 << 64, # Bignum
|
12
16
|
"float" => 1.0,
|
13
17
|
1 => true,
|
14
18
|
nil => "test",
|
@@ -20,21 +24,60 @@ describe Appsignal::Utils do
|
|
20
24
|
|
21
25
|
it { is_expected.to eq Appsignal::Utils.data_generate(body) }
|
22
26
|
it { is_expected.to_not eq Appsignal::Utils.data_generate({}) }
|
23
|
-
it { is_expected.to_not eq "a string" }
|
24
27
|
|
25
28
|
describe "#to_s" do
|
26
|
-
it do
|
27
|
-
expect(subject.to_s).to eq %({"":"test",
|
29
|
+
it "returns a serialized hash" do
|
30
|
+
expect(subject.to_s).to eq %({"":"test",) +
|
31
|
+
%("1":true,) +
|
32
|
+
%("bar":null,) +
|
33
|
+
%("baz":{"arr":[1,2],"foo":"bʊr"},) +
|
34
|
+
%("float":1.0,) +
|
35
|
+
%("foo":[1,2,"three",{"foo":"bar"}],) +
|
36
|
+
%("int":1,) +
|
37
|
+
%("int61":#{1 << 61},) +
|
38
|
+
%("int62":#{1 << 62},) +
|
39
|
+
%("int63":"bigint:#{1 << 63}",) +
|
40
|
+
%("int64":"bigint:#{1 << 64}",) +
|
41
|
+
%("the":"payload"})
|
28
42
|
end
|
29
43
|
end
|
30
44
|
end
|
31
45
|
|
32
46
|
context "with a valid array body" do
|
33
47
|
let(:body) do
|
34
|
-
[
|
48
|
+
[
|
49
|
+
nil,
|
50
|
+
true,
|
51
|
+
false,
|
52
|
+
"string",
|
53
|
+
1, # Fixnum
|
54
|
+
1.0, # Float
|
55
|
+
1 << 61, # Fixnum
|
56
|
+
1 << 62, # Bignum, this one still works
|
57
|
+
1 << 63, # Bignum, turnover point for C, too big for long
|
58
|
+
1 << 64, # Bignum
|
59
|
+
{ "arr" => [1, 2, "three"], "foo" => "bʊr" }
|
60
|
+
]
|
35
61
|
end
|
36
62
|
|
37
|
-
it {
|
63
|
+
it { is_expected.to eq Appsignal::Utils.data_generate(body) }
|
64
|
+
it { is_expected.to_not eq Appsignal::Utils.data_generate({}) }
|
65
|
+
|
66
|
+
describe "#to_s" do
|
67
|
+
it "returns a serialized array" do
|
68
|
+
expect(subject.to_s).to eq %([null,) +
|
69
|
+
%(true,) +
|
70
|
+
%(false,) +
|
71
|
+
%(\"string\",) +
|
72
|
+
%(1,) +
|
73
|
+
%(1.0,) +
|
74
|
+
%(#{1 << 61},) +
|
75
|
+
%(#{1 << 62},) +
|
76
|
+
%("bigint:#{1 << 63}",) +
|
77
|
+
%("bigint:#{1 << 64}",) +
|
78
|
+
%({\"arr\":[1,2,\"three\"],\"foo\":\"bʊr\"}])
|
79
|
+
end
|
80
|
+
end
|
38
81
|
end
|
39
82
|
|
40
83
|
context "with a body that contains strings with invalid utf-8 content" do
|
data/spec/lib/appsignal_spec.rb
CHANGED
@@ -283,6 +283,14 @@ describe Appsignal do
|
|
283
283
|
end
|
284
284
|
end
|
285
285
|
|
286
|
+
describe ".set_namespace" do
|
287
|
+
it "should do nothing" do
|
288
|
+
expect do
|
289
|
+
Appsignal.set_namespace("custom")
|
290
|
+
end.to_not raise_error
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
286
294
|
describe ".tag_request" do
|
287
295
|
it "should do nothing" do
|
288
296
|
expect do
|
@@ -554,7 +562,6 @@ describe Appsignal do
|
|
554
562
|
:log_path => log_path
|
555
563
|
)
|
556
564
|
end
|
557
|
-
around { |example| recognize_as_container(:none) { example.run } }
|
558
565
|
after { FileUtils.rm_rf(log_path) }
|
559
566
|
|
560
567
|
context "when the log path is writable" do
|
@@ -582,7 +589,7 @@ describe Appsignal do
|
|
582
589
|
context "when the log file is not writable" do
|
583
590
|
before do
|
584
591
|
FileUtils.touch log_file
|
585
|
-
FileUtils.chmod
|
592
|
+
FileUtils.chmod 0o444, log_file
|
586
593
|
|
587
594
|
capture_stdout(out_stream) do
|
588
595
|
Appsignal.start_logger
|
@@ -609,8 +616,8 @@ describe Appsignal do
|
|
609
616
|
|
610
617
|
context "when the log path and fallback path are not writable" do
|
611
618
|
before do
|
612
|
-
FileUtils.chmod
|
613
|
-
FileUtils.chmod
|
619
|
+
FileUtils.chmod 0o444, log_path
|
620
|
+
FileUtils.chmod 0o444, Appsignal::Config::SYSTEM_TMP_DIR
|
614
621
|
|
615
622
|
capture_stdout(out_stream) do
|
616
623
|
Appsignal.start_logger
|
@@ -618,7 +625,7 @@ describe Appsignal do
|
|
618
625
|
end
|
619
626
|
end
|
620
627
|
after do
|
621
|
-
FileUtils.chmod
|
628
|
+
FileUtils.chmod 0o755, Appsignal::Config::SYSTEM_TMP_DIR
|
622
629
|
end
|
623
630
|
|
624
631
|
it "logs to stdout" do
|
@@ -792,6 +799,54 @@ describe Appsignal do
|
|
792
799
|
end
|
793
800
|
end
|
794
801
|
|
802
|
+
describe ".set_action" do
|
803
|
+
before { allow(Appsignal::Transaction).to receive(:current).and_return(transaction) }
|
804
|
+
|
805
|
+
it "should set the namespace to the current transaction" do
|
806
|
+
expect(transaction).to receive(:set_action).with("custom")
|
807
|
+
|
808
|
+
Appsignal.set_action("custom")
|
809
|
+
end
|
810
|
+
|
811
|
+
it "should do nothing if there is no current transaction" do
|
812
|
+
allow(Appsignal::Transaction).to receive(:current).and_return(nil)
|
813
|
+
|
814
|
+
expect(transaction).to_not receive(:set_action)
|
815
|
+
|
816
|
+
Appsignal.set_action("custom")
|
817
|
+
end
|
818
|
+
|
819
|
+
it "should do nothing if the error is nil" do
|
820
|
+
expect(transaction).to_not receive(:set_action)
|
821
|
+
|
822
|
+
Appsignal.set_action(nil)
|
823
|
+
end
|
824
|
+
end
|
825
|
+
|
826
|
+
describe ".set_namespace" do
|
827
|
+
before { allow(Appsignal::Transaction).to receive(:current).and_return(transaction) }
|
828
|
+
|
829
|
+
it "should set the namespace to the current transaction" do
|
830
|
+
expect(transaction).to receive(:set_namespace).with("custom")
|
831
|
+
|
832
|
+
Appsignal.set_namespace("custom")
|
833
|
+
end
|
834
|
+
|
835
|
+
it "should do nothing if there is no current transaction" do
|
836
|
+
allow(Appsignal::Transaction).to receive(:current).and_return(nil)
|
837
|
+
|
838
|
+
expect(transaction).to_not receive(:set_namespace)
|
839
|
+
|
840
|
+
Appsignal.set_namespace("custom")
|
841
|
+
end
|
842
|
+
|
843
|
+
it "should do nothing if the error is nil" do
|
844
|
+
expect(transaction).to_not receive(:set_namespace)
|
845
|
+
|
846
|
+
Appsignal.set_namespace(nil)
|
847
|
+
end
|
848
|
+
end
|
849
|
+
|
795
850
|
describe ".instrument" do
|
796
851
|
before do
|
797
852
|
expect(Appsignal::Transaction).to receive(:current).at_least(:once).and_return(transaction)
|
data/spec/spec_helper.rb
CHANGED
@@ -6,6 +6,7 @@ APPSIGNAL_SPEC_DIR = File.expand_path(File.dirname(__FILE__))
|
|
6
6
|
$LOAD_PATH.unshift(File.join(APPSIGNAL_SPEC_DIR, "support/stubs"))
|
7
7
|
|
8
8
|
Bundler.require :default
|
9
|
+
require "cgi"
|
9
10
|
require "rack"
|
10
11
|
require "rspec"
|
11
12
|
require "pry"
|
@@ -66,9 +67,9 @@ RSpec.configure do |config|
|
|
66
67
|
ENV["PADRINO_ENV"] ||= "test"
|
67
68
|
|
68
69
|
# Clean environment
|
69
|
-
|
70
|
-
|
71
|
-
|
70
|
+
appsignal_key_prefixes = %w(APPSIGNAL_ _APPSIGNAL_)
|
71
|
+
env_keys = ENV.keys.select { |key| key.start_with?(*appsignal_key_prefixes) }
|
72
|
+
env_keys.each { |key| ENV.delete(key) }
|
72
73
|
end
|
73
74
|
|
74
75
|
config.after do
|
@@ -9,13 +9,10 @@ module ApiRequestHelper
|
|
9
9
|
:gem_version => Appsignal::VERSION
|
10
10
|
},
|
11
11
|
:headers => {
|
12
|
-
"Content-Encoding" => "gzip",
|
13
12
|
"Content-Type" => "application/json; charset=UTF-8"
|
14
13
|
}
|
15
14
|
}
|
16
|
-
if body.is_a? Hash
|
17
|
-
body = Appsignal::Utils::Gzip.compress(Appsignal::Utils::JSON.generate(body))
|
18
|
-
end
|
15
|
+
body = Appsignal::Utils::JSON.generate(body) if body.is_a? Hash
|
19
16
|
options[:body] = body if body
|
20
17
|
stub_request(:post, "#{config[:endpoint]}/1/#{path}").with(options)
|
21
18
|
end
|
@@ -1,24 +1,8 @@
|
|
1
1
|
module SystemHelpers
|
2
2
|
def recognize_as_heroku
|
3
3
|
ENV["DYNO"] = "dyno1"
|
4
|
-
value = recognize_as_container :lxc do
|
5
|
-
yield
|
6
|
-
end
|
7
|
-
ENV.delete "DYNO"
|
8
|
-
value
|
9
|
-
end
|
10
|
-
|
11
|
-
def recognize_as_container(file)
|
12
|
-
org_cgroup_file = Appsignal::System::Container::CGROUP_FILE
|
13
|
-
Appsignal::System::Container.send :remove_const, :CGROUP_FILE
|
14
|
-
Appsignal::System::Container.send :const_set, :CGROUP_FILE,
|
15
|
-
File.join(DirectoryHelper.fixtures_dir, "containers", "cgroups", file.to_s)
|
16
|
-
|
17
4
|
value = yield
|
18
|
-
|
19
|
-
Appsignal::System::Container.send :remove_const, :CGROUP_FILE
|
20
|
-
Appsignal::System::Container.send :const_set, :CGROUP_FILE, org_cgroup_file
|
21
|
-
|
5
|
+
ENV.delete "DYNO"
|
22
6
|
value
|
23
7
|
end
|
24
8
|
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.1
|
4
|
+
version: 2.2.0.beta.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Beekman
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-04-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -123,6 +123,20 @@ dependencies:
|
|
123
123
|
- - '='
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: 0.46.0
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: yard
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
126
140
|
description: The official appsignal.com gem
|
127
141
|
email:
|
128
142
|
- support@appsignal.com
|
@@ -137,6 +151,7 @@ files:
|
|
137
151
|
- ".rubocop.yml"
|
138
152
|
- ".rubocop_todo.yml"
|
139
153
|
- ".travis.yml"
|
154
|
+
- ".yardopts"
|
140
155
|
- CHANGELOG.md
|
141
156
|
- Gemfile
|
142
157
|
- LICENSE
|
@@ -288,11 +303,9 @@ files:
|
|
288
303
|
- spec/lib/appsignal/rack/rails_instrumentation_spec.rb
|
289
304
|
- spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb
|
290
305
|
- spec/lib/appsignal/rack/streaming_listener_spec.rb
|
291
|
-
- spec/lib/appsignal/system/container_spec.rb
|
292
306
|
- spec/lib/appsignal/system_spec.rb
|
293
307
|
- spec/lib/appsignal/transaction_spec.rb
|
294
308
|
- spec/lib/appsignal/transmitter_spec.rb
|
295
|
-
- spec/lib/appsignal/utils/gzip_spec.rb
|
296
309
|
- spec/lib/appsignal/utils/params_sanitizer_spec.rb
|
297
310
|
- spec/lib/appsignal/utils/query_params_sanitizer_spec.rb
|
298
311
|
- spec/lib/appsignal/utils_spec.rb
|
@@ -342,9 +355,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
342
355
|
version: '1.9'
|
343
356
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
344
357
|
requirements:
|
345
|
-
- - "
|
358
|
+
- - ">"
|
346
359
|
- !ruby/object:Gem::Version
|
347
|
-
version:
|
360
|
+
version: 1.3.1
|
348
361
|
requirements: []
|
349
362
|
rubyforge_project:
|
350
363
|
rubygems_version: 2.6.10
|
@@ -408,11 +421,9 @@ test_files:
|
|
408
421
|
- spec/lib/appsignal/rack/rails_instrumentation_spec.rb
|
409
422
|
- spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb
|
410
423
|
- spec/lib/appsignal/rack/streaming_listener_spec.rb
|
411
|
-
- spec/lib/appsignal/system/container_spec.rb
|
412
424
|
- spec/lib/appsignal/system_spec.rb
|
413
425
|
- spec/lib/appsignal/transaction_spec.rb
|
414
426
|
- spec/lib/appsignal/transmitter_spec.rb
|
415
|
-
- spec/lib/appsignal/utils/gzip_spec.rb
|
416
427
|
- spec/lib/appsignal/utils/params_sanitizer_spec.rb
|
417
428
|
- spec/lib/appsignal/utils/query_params_sanitizer_spec.rb
|
418
429
|
- spec/lib/appsignal/utils_spec.rb
|
@@ -1,67 +0,0 @@
|
|
1
|
-
describe Appsignal::System::Container do
|
2
|
-
describe ".id" do
|
3
|
-
subject { described_class.id }
|
4
|
-
|
5
|
-
context "when in docker" do
|
6
|
-
context "when running normally" do
|
7
|
-
around { |example| recognize_as_container(:docker) { example.run } }
|
8
|
-
|
9
|
-
it "returns id" do
|
10
|
-
expect(subject).to eq("0c703b75cdeaad7c933aa68b4678cc5c37a12d5ef5d7cb52c9cefe684d98e575")
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
context "when running with systemd" do
|
15
|
-
around do |example|
|
16
|
-
# Fabricated example. I'm unable to set up an environment that
|
17
|
-
# produces such a cgroups file.
|
18
|
-
recognize_as_container(:docker_systemd) { example.run }
|
19
|
-
end
|
20
|
-
|
21
|
-
it "returns id" do
|
22
|
-
expect(subject).to eq("09f1c4d420025670a3633edbc9b31450f1d6b2ff87b5912a10c320ad398c7215")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context "when in LXC" do
|
28
|
-
around { |example| recognize_as_container(:lxc) { example.run } }
|
29
|
-
|
30
|
-
it "returns id" do
|
31
|
-
expect(subject).to eq("1a2e485e-3947-4bb6-8c24-8774f0859648")
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context "when not in container" do
|
36
|
-
around { |example| recognize_as_container(:none) { example.run } }
|
37
|
-
|
38
|
-
it "returns nil" do
|
39
|
-
expect(subject).to be_nil
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context "when no permission to read cgroup file" do
|
44
|
-
let(:out_stream) { StringIO.new }
|
45
|
-
let(:no_permission_file) do
|
46
|
-
File.join(fixtures_dir, "containers", "cgroups", "no_permission")
|
47
|
-
end
|
48
|
-
before do
|
49
|
-
File.chmod 0333, no_permission_file
|
50
|
-
Appsignal.logger = Logger.new(out_stream)
|
51
|
-
end
|
52
|
-
around { |example| recognize_as_container(:no_permission) { example.run } }
|
53
|
-
after { File.chmod 0644, no_permission_file }
|
54
|
-
|
55
|
-
it "returns nil" do
|
56
|
-
expect(subject).to be_nil
|
57
|
-
end
|
58
|
-
|
59
|
-
it "logs the error" do
|
60
|
-
subject
|
61
|
-
expect(out_stream.string).to include \
|
62
|
-
"Unable to read '#{no_permission_file}' to determine cgroup",
|
63
|
-
"Permission denied"
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
describe Appsignal::Utils::Gzip do
|
2
|
-
describe ".compress" do
|
3
|
-
let(:value) { "foo" }
|
4
|
-
subject { described_class.compress(value).force_encoding("UTF-8") }
|
5
|
-
|
6
|
-
it "returns a gziped value" do
|
7
|
-
expect(subject).to eq("x\u0001K\xCB\xCF\a\u0000\u0002\x82\u0001E")
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|