appsignal 0.11.13.beta.4 → 0.11.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e385f15b5a860be6ff6f5a9d51c2bbdaf9b16102
4
- data.tar.gz: e3bcf119da2785bfac804db2ae618514c1f6b394
3
+ metadata.gz: 939d3b7a54a4b39ec139e95f135fcd25565fac74
4
+ data.tar.gz: d186dc6f7a065ae88bff571e3963955dd0bf74a0
5
5
  SHA512:
6
- metadata.gz: 6eebba7ef93cebef3a80053473b15b405c58166000e04012041c483ece7c81120c14392f03565f49988f11e15f78df8322f468700027d502e8f86085ee320ae3
7
- data.tar.gz: 620bdfab71b0e033fbb3f7a289e8d2d068e84743d8a4925836173e25f098744162dc1d0397239b9fea8efd953891d6a0537013f2bc10e6337b1efb0809fcb84a
6
+ metadata.gz: c8f57aee9899c31b32997a99652702c36f9e3234d35c1e29acfcfc40d19285bd28a1cc244818c0cdbc6fcf804fa3680c770a83929e51765f46c52ae2524807b2
7
+ data.tar.gz: d5f6ea1bcf79f0c5c23e169baff789e52a5c6ee8f0f75717ed285b3f84aa147694ae403f430a0007e967aae7b706a371c9b00b54174a577176dc77cf65d7a271
@@ -25,23 +25,38 @@ module Padrino::Routing::InstanceMethods
25
25
  if env['sinatra.static_file']
26
26
  route_without_appsignal(base, pass_block)
27
27
  else
28
- payload = {
28
+ request_payload = {
29
29
  :params => request.params,
30
30
  :session => request.session,
31
31
  :method => request.request_method,
32
32
  :path => request.path
33
33
  }
34
- ActiveSupport::Notifications.instrument('process_action.padrino', payload) do |payload|
34
+ ActiveSupport::Notifications.instrument('process_action.padrino', request_payload) do |request_payload|
35
35
  begin
36
36
  route_without_appsignal(base, pass_block)
37
37
  rescue => e
38
38
  Appsignal.add_exception(e); raise e
39
39
  ensure
40
- payload[:action] = "#{settings.name}:#{request.controller}##{request.action}"
40
+ request_payload[:action] = get_payload_action(request)
41
41
  end
42
42
  end
43
43
  end
44
44
  end
45
+
46
+ def get_payload_action(request)
47
+ # Short-circut is there's no request object to obtain information from
48
+ return "#{settings.name}" if request.nil?
49
+
50
+ # Older versions of Padrino work with a route object
51
+ route_obj = defined?(request.route_obj) && request.route_obj
52
+ if route_obj && route_obj.respond_to?(:original_path)
53
+ return "#{settings.name}:#{request.route_obj.original_path}"
54
+ end
55
+
56
+ # Newer versions expose the action / controller on the request class
57
+ request_data = request.respond_to?(:action) ? request.action : request.fullpath
58
+ "#{settings.name}:#{request.controller}##{request_data}"
59
+ end
45
60
  end
46
61
 
47
62
  Padrino.after_load do
@@ -48,7 +48,7 @@ if defined?(::Sidekiq)
48
48
  end
49
49
 
50
50
  def truncate(text)
51
- text.size > 100 ? "#{text[0...97]}..." : text
51
+ text.size > 200 ? "#{text[0...197]}..." : text
52
52
  end
53
53
  end
54
54
  end
@@ -1,3 +1,3 @@
1
1
  module Appsignal
2
- VERSION = '0.11.13.beta.4'
2
+ VERSION = '0.11.13'
3
3
  end
@@ -8,13 +8,13 @@ if padrino_present?
8
8
  include Padrino::Routing
9
9
  end
10
10
 
11
- before :all do
11
+ before do
12
12
  @events = []
13
13
  @subscriber = ActiveSupport::Notifications.subscribe do |*args|
14
14
  @events << ActiveSupport::Notifications::Event.new(*args)
15
15
  end
16
16
  end
17
- after :all do
17
+ after do
18
18
  ActiveSupport::Notifications.unsubscribe(@subscriber)
19
19
  end
20
20
 
@@ -56,76 +56,116 @@ if padrino_present?
56
56
  let(:env) { {} }
57
57
  let(:settings) { double(:name => 'TestApp') }
58
58
 
59
- let(:request) do
60
- double(
61
- :params => {'id' => 1},
62
- :session => {'user_id' => 123},
63
- :request_method => 'GET',
64
- :path => '/users/1',
65
- :controller => 'users',
66
- :action => 'show'
67
- )
68
- end
59
+ describe "#route!" do
60
+ let(:request) do
61
+ double(
62
+ :params => {'id' => 1},
63
+ :session => {'user_id' => 123},
64
+ :request_method => 'GET',
65
+ :path => '/users/1',
66
+ :controller => 'users',
67
+ :action => 'show'
68
+ )
69
+ end
69
70
 
70
- before do
71
- router.stub(
72
- :route_without_appsignal => true,
73
- :request => request,
74
- :env => env,
75
- :settings => settings
76
- )
77
- end
71
+ before do
72
+ router.stub(
73
+ :route_without_appsignal => true,
74
+ :request => request,
75
+ :env => env,
76
+ :settings => settings,
77
+ :get_payload_action => 'controller#action'
78
+ )
79
+ end
80
+
81
+ context "when Sinatra tells us it's a static file" do
82
+ let(:env) { {'sinatra.static_file' => true} }
83
+
84
+ it "should call the original method" do
85
+ expect( router ).to receive(:route_without_appsignal)
86
+ end
78
87
 
79
- context "when Sinatra tells us it's a static file" do
80
- let(:env) { {'sinatra.static_file' => true} }
88
+ it "should not instrument the request" do
89
+ expect( ActiveSupport::Notifications ).to_not receive(:instrument)
90
+ end
81
91
 
82
- it "should call the original method" do
83
- expect( router ).to receive(:route_without_appsignal)
92
+ after { router.route!(base) }
84
93
  end
85
94
 
86
- it "should not instrument the request" do
87
- expect( ActiveSupport::Notifications ).to_not receive(:instrument)
95
+ context "with a dynamic request" do
96
+
97
+ it "should call the original method" do
98
+ expect( router ).to receive(:route_without_appsignal)
99
+ end
100
+
101
+ it "should instrument the action" do
102
+ expect( ActiveSupport::Notifications ).to receive(:instrument).with(
103
+ 'process_action.padrino',
104
+ {
105
+ :params => {'id' => 1},
106
+ :session => {'user_id' => 123},
107
+ :method => 'GET',
108
+ :path => '/users/1'
109
+ }
110
+ )
111
+ end
112
+
113
+ after { router.route!(base) }
88
114
  end
89
115
 
90
- after { router.route!(base) }
91
- end
116
+ it "should add the action to the payload" do
117
+ router.route!(base)
118
+
119
+ expect( @events.first.payload[:action] ).to eql('controller#action')
120
+ end
92
121
 
93
- context "with a dynamic request" do
122
+ context "with an exception" do
123
+ before { router.stub(:route_without_appsignal).and_raise(VerySpecificError) }
94
124
 
95
- it "should call the original method" do
96
- expect( router ).to receive(:route_without_appsignal)
125
+ it "should add the exception to the current transaction" do
126
+ expect( Appsignal ).to receive(:add_exception)
127
+
128
+ router.route!(base) rescue VerySpecificError
129
+ end
97
130
  end
131
+ end
98
132
 
99
- it "should instrument the action" do
100
- expect( ActiveSupport::Notifications ).to receive(:instrument).with(
101
- 'process_action.padrino',
102
- {
103
- :params => {'id' => 1},
104
- :session => {'user_id' => 123},
105
- :method => 'GET',
106
- :path => '/users/1'
107
- }
108
- )
133
+ describe "#get_payload_action" do
134
+ before { router.stub(:settings => settings) }
135
+
136
+ context "when request is nil" do
137
+ it "should return the site" do
138
+ expect( router.get_payload_action(nil) ).to eql('TestApp')
139
+ end
109
140
  end
110
141
 
111
- after { router.route!(base) }
112
- end
142
+ context "when there's no route object" do
143
+ let(:request) { double(:controller => 'Controller', :action => 'action') }
113
144
 
114
- it "should add the action to the payload" do
115
- router.route!(base)
145
+ it "should return the site name, controller and action" do
146
+ expect( router.get_payload_action(request) ).to eql('TestApp:Controller#action')
147
+ end
116
148
 
117
- expect( @events.first.payload[:action] ).to eql('TestApp:users#show')
118
- end
149
+ context "when there's no action" do
150
+ let(:request) { double(:controller => 'Controller', :fullpath => '/action') }
119
151
 
120
- context "with an exception" do
121
- before { router.stub(:route_without_appsignal).and_raise(VerySpecificError) }
152
+ it "should return the site name, controller and fullpath" do
153
+ expect( router.get_payload_action(request) ).to eql('TestApp:Controller#/action')
154
+ end
155
+ end
156
+ end
122
157
 
123
- it "should add the exception to the current transaction" do
124
- expect( Appsignal ).to receive(:add_exception)
158
+ context "when request has a route object" do
159
+ let(:request) { double }
160
+ let(:route_object) { double(:original_path => '/accounts/edit/:id') }
161
+ before { request.stub(:route_obj => route_object) }
125
162
 
126
- router.route!(base) rescue VerySpecificError
163
+ it "should return the original path" do
164
+ expect( router.get_payload_action(request) ).to eql('TestApp:/accounts/edit/:id')
165
+ end
127
166
  end
128
167
  end
168
+
129
169
  end
130
170
  end
131
171
  end
@@ -104,11 +104,11 @@ describe "Sidekiq integration" do
104
104
 
105
105
  describe "#truncate" do
106
106
  let(:very_long_text) do
107
- "a" * 200
107
+ "a" * 400
108
108
  end
109
109
 
110
- it "should truncate the text to 100 chars max" do
111
- plugin.truncate(very_long_text).should == "#{'a' * 97}..."
110
+ it "should truncate the text to 200 chars max" do
111
+ plugin.truncate(very_long_text).should == "#{'a' * 197}..."
112
112
  end
113
113
  end
114
114
 
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.11.13.beta.4
4
+ version: 0.11.13
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: 2015-08-05 00:00:00.000000000 Z
15
+ date: 2015-08-10 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rack
@@ -261,9 +261,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
261
261
  version: '1.9'
262
262
  required_rubygems_version: !ruby/object:Gem::Requirement
263
263
  requirements:
264
- - - ">"
264
+ - - ">="
265
265
  - !ruby/object:Gem::Version
266
- version: 1.3.1
266
+ version: '0'
267
267
  requirements: []
268
268
  rubyforge_project:
269
269
  rubygems_version: 2.4.5