appsignal 0.8.3.beta.1 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/appsignal/cli.rb +1 -0
- data/lib/appsignal/config.rb +9 -4
- data/lib/appsignal/integrations/capistrano.rb +1 -0
- data/lib/appsignal/integrations/rails.rb +5 -1
- data/lib/appsignal/integrations/sinatra.rb +1 -1
- data/lib/appsignal/version.rb +1 -1
- data/spec/lib/appsignal/config_spec.rb +24 -24
- data/spec/lib/appsignal/integrations/capistrano_spec.rb +2 -0
- data/spec/lib/appsignal/integrations/rails_spec.rb +10 -0
- data/spec/support/helpers/config_helpers.rb +2 -1
- data/spec/support/project_fixture/config/appsignal.yml +4 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
N2UwODdmZmQyMDg4NDRlYzRkOWUyNWFkYzIxZTE4NTNmZWEyNzRiMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MWUwM2ZhOTY0NGVjYmVkZWJjOThmYWYxMGJiZDc0N2QwMmU5NzBhMQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MjAzZWI1YTI5ZjYzYjFkZDQ2NmY3OTM5MzZhZWVlMzdmYzNhMWE0MmQxNzk4
|
10
|
+
OWY3NjVlZTUyNjliNjBlYzA0MDc3NTFiMDk3MmFkNDRmYzQ0NDE4YzZjM2Ri
|
11
|
+
MTFhYmI0NzdmMDZiNzZhNDE1ODM5YTBmYTM3NzMwY2Y4NmJkYjg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MGY1OTM5YjA3YjlmOWNkYTQxYTE0ODE5ZTYzODAzMzUxYzViYWZhMGY3OWI0
|
14
|
+
NTRjZjk5MjNkNDIwZTI0NDMyNjZkNzNkNGNiODI2ZGEwMDFjYTM3NzBkYzgz
|
15
|
+
ZmFjZTNiNmZhMjAzYWUwMDE1YWExZmY2ZjY3Yzc5ZTY0Yjc5MTI=
|
data/lib/appsignal/cli.rb
CHANGED
data/lib/appsignal/config.rb
CHANGED
@@ -12,11 +12,12 @@ module Appsignal
|
|
12
12
|
:slow_request_threshold => 200
|
13
13
|
}.freeze
|
14
14
|
|
15
|
-
attr_reader :root_path, :env, :config_hash
|
15
|
+
attr_reader :root_path, :env, :initial_config, :config_hash
|
16
16
|
|
17
|
-
def initialize(root_path, env, logger=Appsignal.logger)
|
17
|
+
def initialize(root_path, env, initial_config={}, logger=Appsignal.logger)
|
18
18
|
@root_path = root_path
|
19
19
|
@env = env.to_s
|
20
|
+
@initial_config = initial_config
|
20
21
|
@logger = logger
|
21
22
|
|
22
23
|
if File.exists?(config_file)
|
@@ -74,17 +75,21 @@ module Appsignal
|
|
74
75
|
config_for_this_env[:push_api_key] = config_for_this_env[:api_key]
|
75
76
|
end
|
76
77
|
|
77
|
-
@config_hash =
|
78
|
+
@config_hash = merge_config(config_for_this_env)
|
78
79
|
else
|
79
80
|
carefully_log_error("Not loading: config for '#{env}' not found")
|
80
81
|
end
|
81
82
|
end
|
82
83
|
|
83
84
|
def load_default_config_with_push_api_key(key)
|
84
|
-
@config_hash =
|
85
|
+
@config_hash = merge_config(
|
85
86
|
:push_api_key => key,
|
86
87
|
:active => true
|
87
88
|
)
|
88
89
|
end
|
90
|
+
|
91
|
+
def merge_config(config)
|
92
|
+
DEFAULT_CONFIG.merge(initial_config).merge(config)
|
93
|
+
end
|
89
94
|
end
|
90
95
|
end
|
@@ -16,7 +16,11 @@ if defined?(::Rails)
|
|
16
16
|
Appsignal.start_logger(Rails.root.join('log'))
|
17
17
|
|
18
18
|
# Load config
|
19
|
-
Appsignal.config = Appsignal::Config.new(
|
19
|
+
Appsignal.config = Appsignal::Config.new(
|
20
|
+
Rails.root,
|
21
|
+
Rails.env,
|
22
|
+
:name => Rails.application.class.parent_name
|
23
|
+
)
|
20
24
|
|
21
25
|
# Start agent if config for this env is present
|
22
26
|
Appsignal.start if Appsignal.active?
|
@@ -5,7 +5,7 @@ Appsignal.logger.info('Loading Sinatra integration')
|
|
5
5
|
app_settings = ::Sinatra::Application.settings
|
6
6
|
Appsignal.config = Appsignal::Config.new(
|
7
7
|
app_settings.root,
|
8
|
-
app_settings.environment
|
8
|
+
app_settings.environment
|
9
9
|
)
|
10
10
|
|
11
11
|
Appsignal.start_logger(app_settings.root)
|
data/lib/appsignal/version.rb
CHANGED
@@ -12,6 +12,7 @@ describe Appsignal::Config do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
its(:loaded?) { should be_true }
|
15
|
+
its(:active?) { should be_true }
|
15
16
|
|
16
17
|
it "should merge with the default config and fill the config hash" do
|
17
18
|
subject.config_hash.should == {
|
@@ -34,20 +35,10 @@ describe Appsignal::Config do
|
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
37
|
-
describe "#active?" do
|
38
|
-
subject { config.active? }
|
39
|
-
|
40
|
-
it { should be_true }
|
41
|
-
end
|
42
|
-
|
43
38
|
context "if the env is passed as a symbol" do
|
44
39
|
let(:config) { project_fixture_config(:production) }
|
45
40
|
|
46
|
-
|
47
|
-
subject { config.active? }
|
48
|
-
|
49
|
-
it { should be_true }
|
50
|
-
end
|
41
|
+
its(:active?) { should be_true }
|
51
42
|
end
|
52
43
|
|
53
44
|
context "and there's also an env var present" do
|
@@ -60,6 +51,15 @@ describe Appsignal::Config do
|
|
60
51
|
end
|
61
52
|
end
|
62
53
|
|
54
|
+
context "and there is an initial config" do
|
55
|
+
let(:config) { project_fixture_config('production', :name => 'Initial name', :initial_key => 'value') }
|
56
|
+
|
57
|
+
it "should merge with the config" do
|
58
|
+
subject[:name].should == 'TestApp'
|
59
|
+
subject[:initial_key].should == 'value'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
63
|
context "and there is an old-style api_key defined" do
|
64
64
|
let(:config) { project_fixture_config('old_api_key') }
|
65
65
|
|
@@ -80,10 +80,12 @@ describe Appsignal::Config do
|
|
80
80
|
end
|
81
81
|
|
82
82
|
its(:loaded?) { should be_false }
|
83
|
+
its(:active?) { should be_false }
|
83
84
|
end
|
84
85
|
|
85
86
|
context "when there is no config file" do
|
86
|
-
let(:
|
87
|
+
let(:initial_config) { {} }
|
88
|
+
let(:config) { Appsignal::Config.new('/nothing', 'production', initial_config) }
|
87
89
|
|
88
90
|
it "should log an error" do
|
89
91
|
Appsignal::Config.any_instance.should_receive(:carefully_log_error).with(
|
@@ -94,6 +96,7 @@ describe Appsignal::Config do
|
|
94
96
|
end
|
95
97
|
|
96
98
|
its(:loaded?) { should be_false }
|
99
|
+
its(:active?) { should be_false }
|
97
100
|
|
98
101
|
describe "#[]" do
|
99
102
|
it "should return nil" do
|
@@ -101,12 +104,6 @@ describe Appsignal::Config do
|
|
101
104
|
end
|
102
105
|
end
|
103
106
|
|
104
|
-
describe "#active?" do
|
105
|
-
subject { config.active? }
|
106
|
-
|
107
|
-
it { should be_false }
|
108
|
-
end
|
109
|
-
|
110
107
|
context "and an env var is present" do
|
111
108
|
before do
|
112
109
|
ENV['APPSIGNAL_PUSH_API_KEY'] = 'push_api_key'
|
@@ -118,12 +115,7 @@ describe Appsignal::Config do
|
|
118
115
|
end
|
119
116
|
|
120
117
|
its(:loaded?) { should be_true }
|
121
|
-
|
122
|
-
describe "#active?" do
|
123
|
-
subject { config.active? }
|
124
|
-
|
125
|
-
it { should be_true }
|
126
|
-
end
|
118
|
+
its(:active?) { should be_true }
|
127
119
|
|
128
120
|
it "should merge with the default config and fill the config hash" do
|
129
121
|
subject.config_hash.should == {
|
@@ -135,6 +127,14 @@ describe Appsignal::Config do
|
|
135
127
|
}
|
136
128
|
end
|
137
129
|
|
130
|
+
context "and an initial config is present" do
|
131
|
+
let(:initial_config) { {:name => 'Initial Name'} }
|
132
|
+
|
133
|
+
it "should merge with the config" do
|
134
|
+
subject[:name].should == 'Initial Name'
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
138
|
context "with only APPSIGNAL_API_KEY" do
|
139
139
|
before do
|
140
140
|
ENV.delete('APPSIGNAL_PUSH_API_KEY')
|
@@ -33,6 +33,7 @@ describe Appsignal::Integrations::Capistrano do
|
|
33
33
|
Appsignal::Config.should_receive(:new).with(
|
34
34
|
project_fixture_path,
|
35
35
|
'production',
|
36
|
+
{},
|
36
37
|
kind_of(Capistrano::Logger)
|
37
38
|
)
|
38
39
|
end
|
@@ -47,6 +48,7 @@ describe Appsignal::Integrations::Capistrano do
|
|
47
48
|
Appsignal::Config.should_receive(:new).with(
|
48
49
|
project_fixture_path,
|
49
50
|
'rack_production',
|
51
|
+
{},
|
50
52
|
kind_of(Capistrano::Logger)
|
51
53
|
)
|
52
54
|
end
|
@@ -18,6 +18,16 @@ if rails_present?
|
|
18
18
|
subject { Appsignal.config }
|
19
19
|
|
20
20
|
it { should be_a(Appsignal::Config) }
|
21
|
+
|
22
|
+
its(:root_path) { should == Pathname.new(project_fixture_path) }
|
23
|
+
its(:env) { should == 'test' }
|
24
|
+
its([:name]) { should == 'TestApp' }
|
25
|
+
|
26
|
+
context "initial config" do
|
27
|
+
subject { Appsignal.config.initial_config }
|
28
|
+
|
29
|
+
its([:name]) { should == 'MyApp' }
|
30
|
+
end
|
21
31
|
end
|
22
32
|
|
23
33
|
context "agent" do
|
@@ -9,10 +9,11 @@ module ConfigHelpers
|
|
9
9
|
File.join(project_fixture_path, 'log/appsignal.log')
|
10
10
|
end
|
11
11
|
|
12
|
-
def project_fixture_config(env='production', logger=Logger.new(project_fixture_log_file))
|
12
|
+
def project_fixture_config(env='production', initial_config={}, logger=Logger.new(project_fixture_log_file))
|
13
13
|
Appsignal::Config.new(
|
14
14
|
project_fixture_path,
|
15
15
|
env,
|
16
|
+
initial_config,
|
16
17
|
logger
|
17
18
|
)
|
18
19
|
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: 0.8.3
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Beekman
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2014-01-
|
15
|
+
date: 2014-01-14 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: activesupport
|
@@ -237,9 +237,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
237
237
|
version: 1.9.3
|
238
238
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
239
239
|
requirements:
|
240
|
-
- - ! '
|
240
|
+
- - ! '>='
|
241
241
|
- !ruby/object:Gem::Version
|
242
|
-
version:
|
242
|
+
version: '0'
|
243
243
|
requirements: []
|
244
244
|
rubyforge_project:
|
245
245
|
rubygems_version: 2.0.3
|