appsignal 0.5.0 → 0.5.1
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.
- data/README.md +1 -3
- data/config/appsignal.yml +3 -1
- data/lib/appsignal/config.rb +35 -12
- data/lib/appsignal/railtie.rb +7 -3
- data/lib/appsignal/version.rb +1 -1
- data/spec/appsignal/auth_check_spec.rb +1 -1
- data/spec/appsignal/cli_spec.rb +4 -2
- data/spec/appsignal/config_spec.rb +92 -41
- data/spec/support/helpers/notification_helpers.rb +2 -3
- data/spec/support/helpers/transaction_helpers.rb +8 -6
- metadata +45 -39
data/README.md
CHANGED
@@ -40,9 +40,7 @@ Appsignal.postprocessing_middleware.add MiddlewareTemplate
|
|
40
40
|
```ruby
|
41
41
|
class RemoveBoringPayload
|
42
42
|
def call(event)
|
43
|
-
unless event.name == 'interesting'
|
44
|
-
event.payload = {}
|
45
|
-
end
|
43
|
+
event.payload.clear unless event.name == 'interesting'
|
46
44
|
yield
|
47
45
|
end
|
48
46
|
end
|
data/config/appsignal.yml
CHANGED
data/lib/appsignal/config.rb
CHANGED
@@ -11,28 +11,51 @@ module Appsignal
|
|
11
11
|
:slow_request_threshold => 200
|
12
12
|
}.freeze
|
13
13
|
|
14
|
-
|
14
|
+
attr_reader :configurations, :project_path, :env
|
15
15
|
|
16
|
-
def initialize(
|
17
|
-
@
|
18
|
-
@
|
16
|
+
def initialize(project_path, env, logger=Appsignal.logger)
|
17
|
+
@project_path = project_path
|
18
|
+
@env = env.to_sym
|
19
19
|
@logger = logger
|
20
|
+
@configurations = {}
|
20
21
|
end
|
21
22
|
|
22
23
|
def load
|
23
|
-
|
24
|
+
return unless load_configurations_from_disk
|
25
|
+
return unless used_unique_api_keys
|
26
|
+
return unless current_environment_present
|
27
|
+
|
28
|
+
DEFAULT_CONFIG.merge(configurations[env])
|
29
|
+
end
|
30
|
+
|
31
|
+
protected
|
32
|
+
|
33
|
+
def load_configurations_from_disk
|
34
|
+
file = File.join(project_path, 'config', 'appsignal.yml')
|
24
35
|
unless File.exists?(file)
|
25
|
-
carefully_log_error "config not found at: #{file}"
|
26
|
-
return
|
36
|
+
carefully_log_error "config not found at: '#{file}'"
|
37
|
+
return false
|
27
38
|
end
|
39
|
+
@configurations = YAML.load(ERB.new(IO.read(file)).result)
|
40
|
+
configurations.each { |k,v| v.symbolize_keys! }
|
41
|
+
configurations.symbolize_keys!
|
42
|
+
true
|
43
|
+
end
|
28
44
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
45
|
+
def used_unique_api_keys
|
46
|
+
keys = configurations.each_value.map { |config| config[:api_key] }.compact
|
47
|
+
if keys.uniq.count < keys.count
|
48
|
+
carefully_log_error('Duplicate API keys found in appsignal.yml')
|
49
|
+
false
|
50
|
+
else
|
51
|
+
true
|
33
52
|
end
|
53
|
+
end
|
34
54
|
|
35
|
-
|
55
|
+
def current_environment_present
|
56
|
+
return true if configurations[env].present?
|
57
|
+
carefully_log_error "config for '#{env}' not found"
|
58
|
+
false
|
36
59
|
end
|
37
60
|
|
38
61
|
end
|
data/lib/appsignal/railtie.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
module Appsignal
|
2
2
|
class Railtie < Rails::Railtie
|
3
3
|
initializer "appsignal.configure_rails_initialization" do |app|
|
4
|
-
|
5
|
-
|
4
|
+
# Some apps when run from the console do not have Rails.root set, there's
|
5
|
+
# currently no way to spec this.
|
6
|
+
if Rails.root
|
7
|
+
Appsignal.logger = Logger.new(Rails.root.join('log/appsignal.log')).tap do |l|
|
8
|
+
l.level = Logger::INFO
|
9
|
+
end
|
10
|
+
Appsignal.flush_in_memory_log
|
6
11
|
end
|
7
|
-
Appsignal.flush_in_memory_log
|
8
12
|
|
9
13
|
if Appsignal.active?
|
10
14
|
app.middleware.
|
data/lib/appsignal/version.rb
CHANGED
data/spec/appsignal/cli_spec.rb
CHANGED
@@ -89,13 +89,15 @@ describe Appsignal::CLI do
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
describe "notify_of_deploy" do
|
92
|
+
describe "#notify_of_deploy" do
|
93
93
|
it "should validate that all options have been supplied" do
|
94
94
|
options = {}
|
95
95
|
cli.should_receive(:validate_required_options).with(
|
96
96
|
[:revision, :repository, :user, :environment],
|
97
97
|
options
|
98
98
|
)
|
99
|
+
Appsignal::Marker.should_receive(:new).
|
100
|
+
and_return(mock(:transmit => true))
|
99
101
|
cli.notify_of_deploy(options)
|
100
102
|
end
|
101
103
|
|
@@ -104,7 +106,7 @@ describe Appsignal::CLI do
|
|
104
106
|
Appsignal::Transmitter.should_receive(:new).with(
|
105
107
|
'http://localhost:3000/1',
|
106
108
|
'markers',
|
107
|
-
'
|
109
|
+
'def'
|
108
110
|
).and_return(transmitter)
|
109
111
|
transmitter.should_receive(:transmit).with(
|
110
112
|
:revision => 'aaaaa',
|
@@ -2,63 +2,114 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Appsignal::Config do
|
4
4
|
let(:logger_parameter) { [] }
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
:
|
13
|
-
|
5
|
+
let(:path) { Dir.pwd }
|
6
|
+
let(:config) { Appsignal::Config.new(path, 'test', *logger_parameter) }
|
7
|
+
|
8
|
+
describe "#load" do
|
9
|
+
subject { config.load }
|
10
|
+
|
11
|
+
it "should never have logged an error" do
|
12
|
+
Appsignal.logger.should_not_receive(:error)
|
13
|
+
subject
|
14
|
+
end
|
15
|
+
|
16
|
+
it {
|
17
|
+
should == {
|
18
|
+
:ignore_exceptions => [],
|
19
|
+
:endpoint => 'http://localhost:3000/1',
|
20
|
+
:slow_request_threshold => 200,
|
21
|
+
:api_key => 'ghi',
|
22
|
+
:active => true
|
23
|
+
}
|
14
24
|
}
|
15
|
-
}
|
16
25
|
|
17
|
-
|
18
|
-
|
26
|
+
context 'when there is no config file' do
|
27
|
+
before { Dir.stub(:pwd => '/not/existing') }
|
19
28
|
|
20
|
-
|
21
|
-
Appsignal.logger.should_receive(:error).with(
|
22
|
-
"config not found at:"\
|
23
|
-
" /not/existing/config/appsignal.yml"
|
24
|
-
)
|
29
|
+
it { should be_nil }
|
25
30
|
end
|
26
31
|
|
27
|
-
context "
|
28
|
-
|
29
|
-
let(:logger_parameter) { [logger] }
|
32
|
+
context "the env is not in the config" do
|
33
|
+
before { config.stub(:current_environment_present => false) }
|
30
34
|
|
31
|
-
it
|
32
|
-
logger.should_receive(:important).with(
|
33
|
-
"config not found at:"\
|
34
|
-
" /not/existing/config/appsignal.yml"
|
35
|
-
)
|
36
|
-
end
|
35
|
+
it { should be_nil }
|
37
36
|
end
|
38
37
|
|
39
|
-
|
38
|
+
context "when an api key is used for more then one environment" do
|
39
|
+
before { config.stub(:used_unique_api_keys => false) }
|
40
|
+
|
41
|
+
it { should be_nil }
|
42
|
+
end
|
40
43
|
end
|
41
44
|
|
42
|
-
|
43
|
-
subject { Appsignal::Config.new(Dir.pwd, 'staging', *logger_parameter).load }
|
45
|
+
# protected
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
47
|
+
describe "#load_configurations_from_disk" do
|
48
|
+
subject do
|
49
|
+
config.send(:load_configurations_from_disk)
|
50
|
+
config.configurations
|
49
51
|
end
|
50
52
|
|
51
|
-
context "when the
|
52
|
-
|
53
|
-
let(:logger_parameter) { [logger] }
|
53
|
+
context "when the file is present" do
|
54
|
+
before { config.should_not_receive(:carefully_log_error) }
|
54
55
|
|
55
|
-
it
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
it { should_not be_empty }
|
57
|
+
end
|
58
|
+
|
59
|
+
context "when the file is not present" do
|
60
|
+
before do
|
61
|
+
config.should_receive(:carefully_log_error)
|
62
|
+
config.stub(:project_path => '/non/existing')
|
59
63
|
end
|
64
|
+
|
65
|
+
it { should be_empty }
|
60
66
|
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "#used_unique_api_keys" do
|
70
|
+
let(:env) { {:api_key => :foo} }
|
71
|
+
subject { config.send(:used_unique_api_keys) }
|
61
72
|
|
62
|
-
|
73
|
+
context "when using all unique keys" do
|
74
|
+
before do
|
75
|
+
config.should_not_receive(:carefully_log_error)
|
76
|
+
config.stub(:configurations => {1 => env})
|
77
|
+
end
|
78
|
+
|
79
|
+
it { should be_true }
|
80
|
+
end
|
81
|
+
|
82
|
+
context "when using non-unique keys" do
|
83
|
+
before do
|
84
|
+
config.should_receive(:carefully_log_error).
|
85
|
+
with("Duplicate API keys found in appsignal.yml")
|
86
|
+
config.stub(:configurations => {:production => env, :staging => env})
|
87
|
+
end
|
88
|
+
|
89
|
+
it { should be_false }
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "#current_environment_present" do
|
94
|
+
subject { config.send(:current_environment_present) }
|
95
|
+
|
96
|
+
context "when the current environment is present" do
|
97
|
+
before do
|
98
|
+
config.should_not_receive(:carefully_log_error)
|
99
|
+
config.stub(:configurations => {:test => :foo})
|
100
|
+
end
|
101
|
+
|
102
|
+
it { should be_true }
|
103
|
+
end
|
104
|
+
|
105
|
+
context "when the current environment is absent" do
|
106
|
+
before do
|
107
|
+
config.should_receive(:carefully_log_error).
|
108
|
+
with("config for 'test' not found")
|
109
|
+
config.stub(:configurations => {})
|
110
|
+
end
|
111
|
+
|
112
|
+
it { should be_false }
|
113
|
+
end
|
63
114
|
end
|
64
115
|
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
module NotificationHelpers
|
2
2
|
|
3
3
|
def notification_event(args={})
|
4
|
-
time = Time.parse('01-01-2001 10:01:00')
|
5
4
|
args = {
|
6
5
|
:name => 'process_action.action_controller',
|
7
|
-
:start =>
|
8
|
-
:ending =>
|
6
|
+
:start => fixed_time,
|
7
|
+
:ending => fixed_time + 0.1,
|
9
8
|
:tid => '1',
|
10
9
|
:payload => create_payload
|
11
10
|
}.merge(args)
|
@@ -1,5 +1,9 @@
|
|
1
1
|
module TransactionHelpers
|
2
2
|
|
3
|
+
def fixed_time
|
4
|
+
@fixed_time ||= Time.at(978364860.0)
|
5
|
+
end
|
6
|
+
|
3
7
|
def transaction_with_exception
|
4
8
|
appsignal_transaction.tap do |o|
|
5
9
|
begin
|
@@ -18,24 +22,22 @@ module TransactionHelpers
|
|
18
22
|
end
|
19
23
|
|
20
24
|
def slow_transaction(args={})
|
21
|
-
time = Time.parse('01-01-2001 10:01:00')
|
22
25
|
appsignal_transaction(
|
23
26
|
{
|
24
27
|
:process_action_event => notification_event(
|
25
|
-
:start =>
|
26
|
-
:ending =>
|
28
|
+
:start => fixed_time,
|
29
|
+
:ending => fixed_time + Appsignal.config[:slow_request_threshold] / 1000.0
|
27
30
|
)
|
28
31
|
}.merge(args)
|
29
32
|
)
|
30
33
|
end
|
31
34
|
|
32
35
|
def slower_transaction(args={})
|
33
|
-
time = Time.parse('01-01-2001 10:01:00')
|
34
36
|
appsignal_transaction(
|
35
37
|
{
|
36
38
|
:process_action_event => notification_event(
|
37
|
-
:start =>
|
38
|
-
:ending =>
|
39
|
+
:start => fixed_time,
|
40
|
+
:ending => fixed_time + Appsignal.config[:slow_request_threshold] / 500.0
|
39
41
|
)
|
40
42
|
}.merge(args)
|
41
43
|
)
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appsignal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.0
|
5
4
|
prerelease:
|
5
|
+
version: 0.5.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Robert Beekman
|
@@ -13,120 +13,120 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2013-04-
|
16
|
+
date: 2013-04-18 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
|
-
|
20
|
-
requirement: !ruby/object:Gem::Requirement
|
21
|
-
none: false
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
20
|
requirements:
|
23
21
|
- - ~>
|
24
22
|
- !ruby/object:Gem::Version
|
25
23
|
version: '3.0'
|
26
|
-
type: :runtime
|
27
|
-
prerelease: false
|
28
|
-
version_requirements: !ruby/object:Gem::Requirement
|
29
24
|
none: false
|
25
|
+
prerelease: false
|
26
|
+
name: rails
|
27
|
+
requirement: !ruby/object:Gem::Requirement
|
30
28
|
requirements:
|
31
29
|
- - ~>
|
32
30
|
- !ruby/object:Gem::Version
|
33
31
|
version: '3.0'
|
32
|
+
none: false
|
33
|
+
type: :runtime
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
none: false
|
41
|
+
prerelease: false
|
35
42
|
name: rake
|
36
43
|
requirement: !ruby/object:Gem::Requirement
|
37
|
-
none: false
|
38
44
|
requirements:
|
39
45
|
- - ! '>='
|
40
46
|
- !ruby/object:Gem::Version
|
41
47
|
version: '0'
|
48
|
+
none: false
|
42
49
|
type: :runtime
|
43
|
-
|
50
|
+
- !ruby/object:Gem::Dependency
|
44
51
|
version_requirements: !ruby/object:Gem::Requirement
|
45
|
-
none: false
|
46
52
|
requirements:
|
47
53
|
- - ! '>='
|
48
54
|
- !ruby/object:Gem::Version
|
49
55
|
version: '0'
|
50
|
-
|
56
|
+
none: false
|
57
|
+
prerelease: false
|
51
58
|
name: json
|
52
59
|
requirement: !ruby/object:Gem::Requirement
|
53
|
-
none: false
|
54
60
|
requirements:
|
55
61
|
- - ! '>='
|
56
62
|
- !ruby/object:Gem::Version
|
57
63
|
version: '0'
|
64
|
+
none: false
|
58
65
|
type: :runtime
|
59
|
-
|
66
|
+
- !ruby/object:Gem::Dependency
|
60
67
|
version_requirements: !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
68
|
requirements:
|
63
69
|
- - ! '>='
|
64
70
|
- !ruby/object:Gem::Version
|
65
71
|
version: '0'
|
66
|
-
|
72
|
+
none: false
|
73
|
+
prerelease: false
|
67
74
|
name: rspec
|
68
75
|
requirement: !ruby/object:Gem::Requirement
|
69
|
-
none: false
|
70
76
|
requirements:
|
71
77
|
- - ! '>='
|
72
78
|
- !ruby/object:Gem::Version
|
73
79
|
version: '0'
|
80
|
+
none: false
|
74
81
|
type: :development
|
75
|
-
|
82
|
+
- !ruby/object:Gem::Dependency
|
76
83
|
version_requirements: !ruby/object:Gem::Requirement
|
77
|
-
none: false
|
78
84
|
requirements:
|
79
85
|
- - ! '>='
|
80
86
|
- !ruby/object:Gem::Version
|
81
87
|
version: '0'
|
82
|
-
|
88
|
+
none: false
|
89
|
+
prerelease: false
|
83
90
|
name: capistrano
|
84
91
|
requirement: !ruby/object:Gem::Requirement
|
85
|
-
none: false
|
86
92
|
requirements:
|
87
93
|
- - ! '>='
|
88
94
|
- !ruby/object:Gem::Version
|
89
95
|
version: '0'
|
96
|
+
none: false
|
90
97
|
type: :development
|
91
|
-
|
98
|
+
- !ruby/object:Gem::Dependency
|
92
99
|
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
none: false
|
94
100
|
requirements:
|
95
101
|
- - ! '>='
|
96
102
|
- !ruby/object:Gem::Version
|
97
103
|
version: '0'
|
98
|
-
|
104
|
+
none: false
|
105
|
+
prerelease: false
|
99
106
|
name: generator_spec
|
100
107
|
requirement: !ruby/object:Gem::Requirement
|
101
|
-
none: false
|
102
108
|
requirements:
|
103
109
|
- - ! '>='
|
104
110
|
- !ruby/object:Gem::Version
|
105
111
|
version: '0'
|
112
|
+
none: false
|
106
113
|
type: :development
|
107
|
-
|
114
|
+
- !ruby/object:Gem::Dependency
|
108
115
|
version_requirements: !ruby/object:Gem::Requirement
|
109
|
-
none: false
|
110
116
|
requirements:
|
111
117
|
- - ! '>='
|
112
118
|
- !ruby/object:Gem::Version
|
113
119
|
version: '0'
|
114
|
-
|
120
|
+
none: false
|
121
|
+
prerelease: false
|
115
122
|
name: pry
|
116
123
|
requirement: !ruby/object:Gem::Requirement
|
117
|
-
none: false
|
118
124
|
requirements:
|
119
125
|
- - ! '>='
|
120
126
|
- !ruby/object:Gem::Version
|
121
127
|
version: '0'
|
122
|
-
type: :development
|
123
|
-
prerelease: false
|
124
|
-
version_requirements: !ruby/object:Gem::Requirement
|
125
128
|
none: false
|
126
|
-
|
127
|
-
- - ! '>='
|
128
|
-
- !ruby/object:Gem::Version
|
129
|
-
version: '0'
|
129
|
+
type: :development
|
130
130
|
description: The official appsignal.com gem
|
131
131
|
email:
|
132
132
|
- contact@appsignal.com
|
@@ -212,20 +212,26 @@ rdoc_options: []
|
|
212
212
|
require_paths:
|
213
213
|
- lib
|
214
214
|
required_ruby_version: !ruby/object:Gem::Requirement
|
215
|
-
none: false
|
216
215
|
requirements:
|
217
216
|
- - ! '>='
|
218
217
|
- !ruby/object:Gem::Version
|
219
218
|
version: '0'
|
220
|
-
|
219
|
+
segments:
|
220
|
+
- 0
|
221
|
+
hash: -3609057050199006546
|
221
222
|
none: false
|
223
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
222
224
|
requirements:
|
223
225
|
- - ! '>='
|
224
226
|
- !ruby/object:Gem::Version
|
225
227
|
version: '0'
|
228
|
+
segments:
|
229
|
+
- 0
|
230
|
+
hash: -3609057050199006546
|
231
|
+
none: false
|
226
232
|
requirements: []
|
227
233
|
rubyforge_project:
|
228
|
-
rubygems_version: 1.8.
|
234
|
+
rubygems_version: 1.8.24
|
229
235
|
signing_key:
|
230
236
|
specification_version: 3
|
231
237
|
summary: Logs performance and exception data from your app toappsignal.com
|