appsignal 0.11.5 → 0.11.6.beta.0
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/CHANGELOG.md +4 -0
- data/lib/appsignal.rb +1 -0
- data/lib/appsignal/config.rb +7 -4
- data/lib/appsignal/integrations/sinatra.rb +1 -1
- data/lib/appsignal/rack/sinatra_instrumentation.rb +36 -0
- data/lib/appsignal/transaction.rb +5 -1
- data/lib/appsignal/version.rb +1 -1
- data/spec/lib/appsignal/config_spec.rb +46 -1
- data/spec/lib/appsignal/integrations/sinatra_spec.rb +1 -1
- data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +97 -0
- data/spec/lib/appsignal/transaction_spec.rb +12 -0
- metadata +44 -25
- checksums.yaml +0 -7
data/CHANGELOG.md
CHANGED
data/lib/appsignal.rb
CHANGED
@@ -194,6 +194,7 @@ require 'appsignal/config'
|
|
194
194
|
require 'appsignal/marker'
|
195
195
|
require 'appsignal/rack/listener'
|
196
196
|
require 'appsignal/rack/instrumentation'
|
197
|
+
require 'appsignal/rack/sinatra_instrumentation'
|
197
198
|
require 'appsignal/params_sanitizer'
|
198
199
|
require 'appsignal/transaction'
|
199
200
|
require 'appsignal/transaction/formatter'
|
data/lib/appsignal/config.rb
CHANGED
@@ -27,11 +27,11 @@ module Appsignal
|
|
27
27
|
if File.exists?(config_file)
|
28
28
|
load_config_from_disk
|
29
29
|
elsif ENV['APPSIGNAL_PUSH_API_KEY']
|
30
|
-
|
30
|
+
load_default_config_with_push_api_key_and_name_from_env(
|
31
31
|
ENV['APPSIGNAL_PUSH_API_KEY']
|
32
32
|
)
|
33
33
|
elsif ENV['APPSIGNAL_API_KEY']
|
34
|
-
|
34
|
+
load_default_config_with_push_api_key_and_name_from_env(
|
35
35
|
ENV['APPSIGNAL_API_KEY']
|
36
36
|
)
|
37
37
|
@logger.info(
|
@@ -46,7 +46,7 @@ module Appsignal
|
|
46
46
|
end
|
47
47
|
if config_hash && !config_hash[:name]
|
48
48
|
@logger.debug(
|
49
|
-
"There's no application name set in your config file. " \
|
49
|
+
"There's no application name set in your config file or in the APPSIGNAL_APP_NAME env var. " \
|
50
50
|
"You should set one unless your app runs on Heroku."
|
51
51
|
)
|
52
52
|
end
|
@@ -91,11 +91,14 @@ module Appsignal
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
def
|
94
|
+
def load_default_config_with_push_api_key_and_name_from_env(key)
|
95
|
+
# Get base config by doing the default merge and adding the push api key.
|
95
96
|
@config_hash = merge_config(
|
96
97
|
:push_api_key => key,
|
97
98
|
:active => true
|
98
99
|
)
|
100
|
+
@config_hash[:name] = ENV['APPSIGNAL_APP_NAME'] if ENV['APPSIGNAL_APP_NAME']
|
101
|
+
@config_hash[:active] = ENV['APPSIGNAL_ACTIVE'] == 'true' if ENV['APPSIGNAL_ACTIVE']
|
99
102
|
end
|
100
103
|
|
101
104
|
def merge_config(config)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Appsignal
|
2
|
+
module Rack
|
3
|
+
class SinatraInstrumentation
|
4
|
+
def initialize(app, options = {})
|
5
|
+
Appsignal.logger.debug 'Initializing Appsignal::Rack::SinatraInstrumentation'
|
6
|
+
@app, @options = app, options
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
ActiveSupport::Notifications.instrument(
|
11
|
+
'process_action.sinatra',
|
12
|
+
raw_payload(env)
|
13
|
+
) do |payload|
|
14
|
+
begin
|
15
|
+
@app.call(env)
|
16
|
+
ensure
|
17
|
+
# This information is available only after the
|
18
|
+
# request has been processed by Sinatra.
|
19
|
+
payload[:action] = env['sinatra.route']
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def raw_payload(env)
|
25
|
+
request = @options.fetch(:request_class, ::Sinatra::Request).new(env)
|
26
|
+
params = request.public_send(@options.fetch(:params_method, :params))
|
27
|
+
{
|
28
|
+
:params => params,
|
29
|
+
:session => request.session,
|
30
|
+
:method => request.request_method,
|
31
|
+
:path => request.path
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -71,7 +71,11 @@ module Appsignal
|
|
71
71
|
def set_process_action_event(event)
|
72
72
|
return unless event && event.payload
|
73
73
|
@process_action_event = event.dup
|
74
|
-
|
74
|
+
if @process_action_event.payload[:controller]
|
75
|
+
@action = "#{@process_action_event.payload[:controller]}##{@process_action_event.payload[:action]}"
|
76
|
+
else
|
77
|
+
@action = @process_action_event.payload[:action]
|
78
|
+
end
|
75
79
|
@kind = 'http_request'
|
76
80
|
set_http_queue_start
|
77
81
|
end
|
data/lib/appsignal/version.rb
CHANGED
@@ -123,7 +123,7 @@ describe Appsignal::Config do
|
|
123
123
|
|
124
124
|
it "should merge with the default config, fill the config hash and log about the missing name" do
|
125
125
|
Appsignal.logger.should_receive(:debug).with(
|
126
|
-
"There's no application name set in your config file. You should set one unless your app runs on Heroku."
|
126
|
+
"There's no application name set in your config file or in the APPSIGNAL_APP_NAME env var. You should set one unless your app runs on Heroku."
|
127
127
|
)
|
128
128
|
|
129
129
|
subject.config_hash.should == {
|
@@ -148,6 +148,51 @@ describe Appsignal::Config do
|
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
151
|
+
context "more config in environment" do
|
152
|
+
context "APPSIGNAL_APP_NAME is set" do
|
153
|
+
before do
|
154
|
+
ENV['APPSIGNAL_APP_NAME'] = 'Name from env'
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should set the name" do
|
158
|
+
Appsignal.logger.should_not_receive(:debug)
|
159
|
+
subject[:name].should == 'Name from env'
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
context "APPSIGNAL_ACTIVE" do
|
164
|
+
context "not present" do
|
165
|
+
before do
|
166
|
+
ENV.delete('APPSIGNAL_ACTIVE')
|
167
|
+
end
|
168
|
+
|
169
|
+
it "should still set active to true" do
|
170
|
+
subject[:active].should be_true
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
context "true" do
|
175
|
+
before do
|
176
|
+
ENV['APPSIGNAL_ACTIVE'] = 'true'
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should set active to true" do
|
180
|
+
subject[:active].should be_true
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
context "false" do
|
185
|
+
before do
|
186
|
+
ENV['APPSIGNAL_ACTIVE'] = 'false'
|
187
|
+
end
|
188
|
+
|
189
|
+
it "should set active to false" do
|
190
|
+
subject[:active].should be_false
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
151
196
|
context "with only APPSIGNAL_API_KEY" do
|
152
197
|
before do
|
153
198
|
ENV.delete('APPSIGNAL_PUSH_API_KEY')
|
@@ -36,7 +36,7 @@ if defined?(::Sinatra)
|
|
36
36
|
|
37
37
|
it "should have added the instrumentation middleware" do
|
38
38
|
Sinatra::Application.middleware.to_a.should include(
|
39
|
-
[Appsignal::Rack::
|
39
|
+
[Appsignal::Rack::SinatraInstrumentation, [], nil]
|
40
40
|
)
|
41
41
|
end
|
42
42
|
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'sinatra'
|
5
|
+
rescue LoadError
|
6
|
+
end
|
7
|
+
|
8
|
+
if defined?(::Sinatra)
|
9
|
+
describe Appsignal::Rack::SinatraInstrumentation do
|
10
|
+
before :all do
|
11
|
+
start_agent
|
12
|
+
@events = []
|
13
|
+
@subscriber = ActiveSupport::Notifications.subscribe do |*args|
|
14
|
+
@events << ActiveSupport::Notifications::Event.new(*args)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
after :all do
|
18
|
+
ActiveSupport::Notifications.unsubscribe(@subscriber)
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:app) { double(:call => true) }
|
22
|
+
let(:env) { {} }
|
23
|
+
let(:middleware) { Appsignal::Rack::SinatraInstrumentation.new(app, {}) }
|
24
|
+
|
25
|
+
describe "#call" do
|
26
|
+
before do
|
27
|
+
middleware.stub(:raw_payload => {})
|
28
|
+
env['sinatra.route'] = 'GET /'
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should instrument the call" do
|
32
|
+
app.should_receive(:call).with(env)
|
33
|
+
|
34
|
+
middleware.call(env)
|
35
|
+
|
36
|
+
process_action_event = @events.last
|
37
|
+
process_action_event.name.should == 'process_action.sinatra'
|
38
|
+
process_action_event.payload[:action].should == 'GET /'
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should still set the action if there was an exception" do
|
42
|
+
app.should_receive(:call).with(env).and_raise('the roof')
|
43
|
+
|
44
|
+
lambda {
|
45
|
+
middleware.call(env)
|
46
|
+
}.should raise_error
|
47
|
+
|
48
|
+
process_action_event = @events.last
|
49
|
+
process_action_event.name.should == 'process_action.sinatra'
|
50
|
+
process_action_event.payload[:action].should == 'GET /'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "raw_payload" do
|
55
|
+
let(:env) do
|
56
|
+
{
|
57
|
+
'rack.input' => StringIO.new,
|
58
|
+
'REQUEST_METHOD' => 'GET',
|
59
|
+
'PATH_INFO' => '/homepage',
|
60
|
+
'QUERY_STRING' => 'param=something'
|
61
|
+
}
|
62
|
+
end
|
63
|
+
subject { middleware.raw_payload(env) }
|
64
|
+
|
65
|
+
it { should == {
|
66
|
+
:params => {'param' => 'something'},
|
67
|
+
:session => {},
|
68
|
+
:method => 'GET',
|
69
|
+
:path => '/homepage'
|
70
|
+
} }
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "use a custom request class and parameters method" do
|
74
|
+
let(:request_class) do
|
75
|
+
double(
|
76
|
+
new: double(
|
77
|
+
request_method: 'POST',
|
78
|
+
path: '/somewhere',
|
79
|
+
filtered_params: {'param' => 'changed_something'}
|
80
|
+
)
|
81
|
+
)
|
82
|
+
end
|
83
|
+
let(:options) do
|
84
|
+
{ request_class: request_class, params_method: :filtered_params }
|
85
|
+
end
|
86
|
+
let(:middleware) { Appsignal::Rack::Instrumentation.new(app, options) }
|
87
|
+
subject { middleware.raw_payload(env) }
|
88
|
+
|
89
|
+
it { should == {
|
90
|
+
:action => 'POST:/somewhere',
|
91
|
+
:params => {'param' => 'changed_something'},
|
92
|
+
:method => 'POST',
|
93
|
+
:path => '/somewhere'
|
94
|
+
} }
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -100,6 +100,18 @@ describe Appsignal::Transaction do
|
|
100
100
|
it "should call set_http_queue_start" do
|
101
101
|
transaction.queue_start.should_not be_nil
|
102
102
|
end
|
103
|
+
|
104
|
+
context "if there is no controller" do
|
105
|
+
before do
|
106
|
+
process_action_event.payload[:action] = 'GET /items/:id'
|
107
|
+
process_action_event.payload.delete(:controller)
|
108
|
+
transaction.set_process_action_event(process_action_event)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should set the action without a #" do
|
112
|
+
transaction.action.should == 'GET /items/:id'
|
113
|
+
end
|
114
|
+
end
|
103
115
|
end
|
104
116
|
|
105
117
|
describe "set_perform_job_event" do
|
metadata
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appsignal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.6.beta.0
|
5
|
+
prerelease: 7
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Robert Beekman
|
@@ -12,104 +13,118 @@ authors:
|
|
12
13
|
autorequire:
|
13
14
|
bindir: bin
|
14
15
|
cert_chain: []
|
15
|
-
date: 2015-02-
|
16
|
+
date: 2015-02-16 00:00:00.000000000 Z
|
16
17
|
dependencies:
|
17
18
|
- !ruby/object:Gem::Dependency
|
18
19
|
name: rack
|
19
20
|
requirement: !ruby/object:Gem::Requirement
|
21
|
+
none: false
|
20
22
|
requirements:
|
21
|
-
- -
|
23
|
+
- - ! '>='
|
22
24
|
- !ruby/object:Gem::Version
|
23
25
|
version: '0'
|
24
26
|
type: :runtime
|
25
27
|
prerelease: false
|
26
28
|
version_requirements: !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
27
30
|
requirements:
|
28
|
-
- -
|
31
|
+
- - ! '>='
|
29
32
|
- !ruby/object:Gem::Version
|
30
33
|
version: '0'
|
31
34
|
- !ruby/object:Gem::Dependency
|
32
35
|
name: thread_safe
|
33
36
|
requirement: !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
34
38
|
requirements:
|
35
|
-
- -
|
39
|
+
- - ! '>='
|
36
40
|
- !ruby/object:Gem::Version
|
37
41
|
version: '0'
|
38
42
|
type: :runtime
|
39
43
|
prerelease: false
|
40
44
|
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
41
46
|
requirements:
|
42
|
-
- -
|
47
|
+
- - ! '>='
|
43
48
|
- !ruby/object:Gem::Version
|
44
49
|
version: '0'
|
45
50
|
- !ruby/object:Gem::Dependency
|
46
51
|
name: rake
|
47
52
|
requirement: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
48
54
|
requirements:
|
49
|
-
- -
|
55
|
+
- - ! '>='
|
50
56
|
- !ruby/object:Gem::Version
|
51
57
|
version: '0'
|
52
58
|
type: :development
|
53
59
|
prerelease: false
|
54
60
|
version_requirements: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
55
62
|
requirements:
|
56
|
-
- -
|
63
|
+
- - ! '>='
|
57
64
|
- !ruby/object:Gem::Version
|
58
65
|
version: '0'
|
59
66
|
- !ruby/object:Gem::Dependency
|
60
67
|
name: rspec
|
61
68
|
requirement: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
62
70
|
requirements:
|
63
|
-
- -
|
71
|
+
- - ~>
|
64
72
|
- !ruby/object:Gem::Version
|
65
73
|
version: 2.14.1
|
66
74
|
type: :development
|
67
75
|
prerelease: false
|
68
76
|
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
69
78
|
requirements:
|
70
|
-
- -
|
79
|
+
- - ~>
|
71
80
|
- !ruby/object:Gem::Version
|
72
81
|
version: 2.14.1
|
73
82
|
- !ruby/object:Gem::Dependency
|
74
83
|
name: pry
|
75
84
|
requirement: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
76
86
|
requirements:
|
77
|
-
- -
|
87
|
+
- - ! '>='
|
78
88
|
- !ruby/object:Gem::Version
|
79
89
|
version: '0'
|
80
90
|
type: :development
|
81
91
|
prerelease: false
|
82
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
83
94
|
requirements:
|
84
|
-
- -
|
95
|
+
- - ! '>='
|
85
96
|
- !ruby/object:Gem::Version
|
86
97
|
version: '0'
|
87
98
|
- !ruby/object:Gem::Dependency
|
88
99
|
name: timecop
|
89
100
|
requirement: !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
90
102
|
requirements:
|
91
|
-
- -
|
103
|
+
- - ! '>='
|
92
104
|
- !ruby/object:Gem::Version
|
93
105
|
version: '0'
|
94
106
|
type: :development
|
95
107
|
prerelease: false
|
96
108
|
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
97
110
|
requirements:
|
98
|
-
- -
|
111
|
+
- - ! '>='
|
99
112
|
- !ruby/object:Gem::Version
|
100
113
|
version: '0'
|
101
114
|
- !ruby/object:Gem::Dependency
|
102
115
|
name: webmock
|
103
116
|
requirement: !ruby/object:Gem::Requirement
|
117
|
+
none: false
|
104
118
|
requirements:
|
105
|
-
- -
|
119
|
+
- - ! '>='
|
106
120
|
- !ruby/object:Gem::Version
|
107
121
|
version: '0'
|
108
122
|
type: :development
|
109
123
|
prerelease: false
|
110
124
|
version_requirements: !ruby/object:Gem::Requirement
|
125
|
+
none: false
|
111
126
|
requirements:
|
112
|
-
- -
|
127
|
+
- - ! '>='
|
113
128
|
- !ruby/object:Gem::Version
|
114
129
|
version: '0'
|
115
130
|
description: The official appsignal.com gem
|
@@ -120,9 +135,9 @@ executables:
|
|
120
135
|
extensions: []
|
121
136
|
extra_rdoc_files: []
|
122
137
|
files:
|
123
|
-
-
|
124
|
-
-
|
125
|
-
-
|
138
|
+
- .gitignore
|
139
|
+
- .rspec
|
140
|
+
- .travis.yml
|
126
141
|
- CHANGELOG.md
|
127
142
|
- Gemfile
|
128
143
|
- LICENSE
|
@@ -174,6 +189,7 @@ files:
|
|
174
189
|
- lib/appsignal/params_sanitizer.rb
|
175
190
|
- lib/appsignal/rack/instrumentation.rb
|
176
191
|
- lib/appsignal/rack/listener.rb
|
192
|
+
- lib/appsignal/rack/sinatra_instrumentation.rb
|
177
193
|
- lib/appsignal/transaction.rb
|
178
194
|
- lib/appsignal/transaction/formatter.rb
|
179
195
|
- lib/appsignal/transaction/params_sanitizer.rb
|
@@ -216,6 +232,7 @@ files:
|
|
216
232
|
- spec/lib/appsignal/params_sanitizer_spec.rb
|
217
233
|
- spec/lib/appsignal/rack/instrumentation_spec.rb
|
218
234
|
- spec/lib/appsignal/rack/listener_spec.rb
|
235
|
+
- spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb
|
219
236
|
- spec/lib/appsignal/transaction/formatter_spec.rb
|
220
237
|
- spec/lib/appsignal/transaction_spec.rb
|
221
238
|
- spec/lib/appsignal/transmitter_spec.rb
|
@@ -236,26 +253,27 @@ files:
|
|
236
253
|
homepage: https://github.com/appsignal/appsignal
|
237
254
|
licenses:
|
238
255
|
- MIT
|
239
|
-
metadata: {}
|
240
256
|
post_install_message:
|
241
257
|
rdoc_options: []
|
242
258
|
require_paths:
|
243
259
|
- lib
|
244
260
|
required_ruby_version: !ruby/object:Gem::Requirement
|
261
|
+
none: false
|
245
262
|
requirements:
|
246
|
-
- -
|
263
|
+
- - ! '>='
|
247
264
|
- !ruby/object:Gem::Version
|
248
265
|
version: '1.9'
|
249
266
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
267
|
+
none: false
|
250
268
|
requirements:
|
251
|
-
- -
|
269
|
+
- - ! '>'
|
252
270
|
- !ruby/object:Gem::Version
|
253
|
-
version:
|
271
|
+
version: 1.3.1
|
254
272
|
requirements: []
|
255
273
|
rubyforge_project:
|
256
|
-
rubygems_version:
|
274
|
+
rubygems_version: 1.8.23
|
257
275
|
signing_key:
|
258
|
-
specification_version:
|
276
|
+
specification_version: 3
|
259
277
|
summary: Logs performance and exception data from your app to appsignal.com
|
260
278
|
test_files:
|
261
279
|
- spec/lib/appsignal/agent_spec.rb
|
@@ -286,6 +304,7 @@ test_files:
|
|
286
304
|
- spec/lib/appsignal/params_sanitizer_spec.rb
|
287
305
|
- spec/lib/appsignal/rack/instrumentation_spec.rb
|
288
306
|
- spec/lib/appsignal/rack/listener_spec.rb
|
307
|
+
- spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb
|
289
308
|
- spec/lib/appsignal/transaction/formatter_spec.rb
|
290
309
|
- spec/lib/appsignal/transaction_spec.rb
|
291
310
|
- spec/lib/appsignal/transmitter_spec.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 28b9ade66f02b2901ab65933aa6eb993e32000ad
|
4
|
-
data.tar.gz: 1eb565d3a57c0a62c2e261728dcec8a38f55f141
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 8fe9c09d3c7cb5f2fef232220a1acdd45e09a1b1691a939eba00c00de6299b3cb58c78c6be531ae3bc99d2023bab35ffbc1445cc0d1d9c91acbd79290682fe0e
|
7
|
-
data.tar.gz: 2b166f952ea4f0428ff5e54a4aecb7f2835aa70c19dcfc2c9c315a78a6b694e52a3f1dc9f43e09ef50658c929fd0c063fc61e60f64379c6d5c53ff3616c80db7
|