raygun-apm-rails 1.0.39 → 1.0.57

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f6a07ee4fbe4f294919714c6f1858d5c63dc4eb10afa5fef80127e5daccc783
4
- data.tar.gz: 6a7c96aefe0dc6fc3555264224a6eaa854bd7792ce3b14c11350bfddeed039d3
3
+ metadata.gz: 77b2cb6b362699a84104a6482f78b07e048cfe4078f6e9c8bb4c3ccb3f68790d
4
+ data.tar.gz: 87841e971bf4b9c11bd307425d3a4c3fcd8a64c3146ecf6d5da31c8f21f507ce
5
5
  SHA512:
6
- metadata.gz: 18d47aae61e21982516f288ba2908eb61be218a7cdfc7acf2ab351496fcf2fde62a10fd721a593800ea205f62d5b7e36a6ca01a409dcb338492e9434b9e7ed66
7
- data.tar.gz: 331f005adb478052aa4970dca6ecf0f891f6e56cb198ce1fa333a2f998d26a258e8a4839b980ed1e6362facdf74e836006e51638f58346f51dfe63f2179839f2
6
+ metadata.gz: 7f08c270b6bb5d837f582a17f64750839042a38218895ae842f7541e18563893703ace59900c7ba6faf6cc9a030a523f19c9c11a8c8c8e9efaca11a8dc2bc51f
7
+ data.tar.gz: daaa001d451f0f7d01c8133021ff1735a645324f55aabb1b1108252f9d1a8bd48a4593e2037e7709832d5d3b18340e9089f8691ed78dd4e10c6d1c44333c2b99
@@ -2,8 +2,10 @@ module Raygun
2
2
  module Apm
3
3
  module Rails
4
4
  class Middleware
5
+ POSTGRESQLSTRING = "postgresql"
5
6
  def initialize(app)
6
7
  @app = app
8
+ @mutex = Mutex.new
7
9
  @tracer = nil
8
10
  end
9
11
 
@@ -15,9 +17,14 @@ module Raygun
15
17
  private
16
18
 
17
19
  def instrument(env)
18
- res = nil
19
- # Can be nil if we had a fatal error
20
- @tracer = Raygun::Apm::Tracer.instance || init_tracer
20
+ # Ignore asset requests
21
+ if env['REQUEST_PATH'].match(/^\/assets\//)
22
+ return @app.call(env)
23
+ end
24
+ @mutex.synchronize do
25
+ # Can be nil if we had a fatal error
26
+ @tracer = Raygun::Apm::Tracer.instance || init_tracer
27
+ end
21
28
  if @tracer
22
29
  # For the exceptional HTTP IN handler
23
30
  @request_started = @tracer.now
@@ -28,25 +35,16 @@ module Raygun
28
35
  Ruby_APM_profiler_trace do
29
36
  begin
30
37
  res = @app.call(env)
31
- if res && (status = res.first) >= 400 && status < 600
32
- message = Rack::Utils::HTTP_STATUS_CODES[status]
33
- begin
34
- raise "HTTP #{status} #{message}"
35
- rescue => e
36
- crash_report_exception(e)
37
- end
38
- exceptional_http_in_handler(env, status) if @tracer
39
- end
40
38
  rescue => e
41
- crash_report_exception(e)
42
- exceptional_http_in_handler(env, 500) if @tracer
39
+ crash_report_exception(e, env)
40
+ exceptional_http_in_handler(env) if @tracer
43
41
  exception = e
44
42
  end
45
43
  end
46
44
  # Can be nil if we had a fatal error
47
45
  if @tracer
48
- @tracer.end_trace
49
46
  @tracer.diagnostics if ENV['PROTON_DIAGNOSTICS']
47
+ @tracer.end_trace
50
48
  end
51
49
  raise exception if exception
52
50
  res
@@ -105,7 +103,7 @@ module Raygun
105
103
  event[:pid] = Process.pid
106
104
  event[:url] = url
107
105
  event[:verb] = verb
108
- event[:status] = notification.payload[:status]
106
+ event[:status] = notification.payload[:status] || notification.payload[:headers]["action_controller.instance"].status
109
107
  # XXX constant milliseconds to microseconds
110
108
  event[:duration] = notification.duration * 1000
111
109
  event[:timestamp] = @tracer.now
@@ -117,13 +115,13 @@ module Raygun
117
115
  end
118
116
 
119
117
  # For middleware chain halts that does not trigger 'process_action.action_controller'
120
- def exceptional_http_in_handler(env, status)
118
+ def exceptional_http_in_handler(env)
121
119
  req = Rack::Request.new env
122
120
  event = http_in_event
123
121
  event[:pid] = Process.pid
124
122
  event[:url] = req.url
125
123
  event[:verb] = req.request_method
126
- event[:status] = status
124
+ event[:status] = 500
127
125
  event[:duration] = @tracer.now - @request_started
128
126
  event[:timestamp] = @tracer.now
129
127
  event[:tid] = @tracer.get_thread_id(Thread.current)
@@ -150,7 +148,7 @@ module Raygun
150
148
 
151
149
  # XXX this is hacky
152
150
  if config = connection.instance_variable_get('@config')
153
- event[:provider] = config[:adapter]
151
+ event[:provider] = get_sql_provider_name(config)
154
152
  event[:host] = config[:host]
155
153
  event[:database] = config[:database]
156
154
  end
@@ -165,6 +163,14 @@ module Raygun
165
163
  raygun_shutdown_handler(e)
166
164
  end
167
165
 
166
+ #This function adjusts the provider name for PostgreSQL to Postgres because all other Raygun profilers use Postgres and this will keep the UI consistent across supported languages
167
+ def get_sql_provider_name(config)
168
+ if config[:adapter] == POSTGRESQLSTRING
169
+ return "postgres"
170
+ end
171
+ config[:adapter]
172
+ end
173
+
168
174
  def sql_event
169
175
  @sql_event ||= Raygun::Apm::Event::Sql.new
170
176
  end
@@ -177,9 +183,10 @@ module Raygun
177
183
  yield
178
184
  end
179
185
 
180
- def crash_report_exception(exception)
186
+ def crash_report_exception(exception, env = {})
181
187
  if Raygun::Apm::Rails.raygun4ruby?
182
- Raygun.track_exception(exception, correlation_id: exception.instance_variable_get(:@__raygun_correlation_id))
188
+ env.merge!(correlation_id: exception.instance_variable_get(:@__raygun_correlation_id))
189
+ Raygun.track_exception(exception, env)
183
190
  end
184
191
  end
185
192
 
@@ -1,7 +1,7 @@
1
1
  module Raygun
2
2
  module Apm
3
3
  module Rails
4
- VERSION = "1.0.39"
4
+ VERSION = "1.0.57"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raygun-apm-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.39
4
+ version: 1.0.57
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raygun
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-07-31 00:00:00.000000000 Z
12
+ date: 2021-02-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: raygun-apm
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  requirements: []
104
- rubygems_version: 3.0.6
104
+ rubygems_version: 3.1.2
105
105
  signing_key:
106
106
  specification_version: 4
107
107
  summary: Raygun application performance monitoring for Rails