raygun-apm-rails 1.0.39 → 1.0.57
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/raygun/apm/rails/middleware.rb +28 -21
- data/lib/raygun/apm/rails/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77b2cb6b362699a84104a6482f78b07e048cfe4078f6e9c8bb4c3ccb3f68790d
|
4
|
+
data.tar.gz: 87841e971bf4b9c11bd307425d3a4c3fcd8a64c3146ecf6d5da31c8f21f507ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
19
|
-
|
20
|
-
|
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
|
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
|
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] =
|
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
|
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
|
-
|
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
|
|
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.
|
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:
|
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.
|
104
|
+
rubygems_version: 3.1.2
|
105
105
|
signing_key:
|
106
106
|
specification_version: 4
|
107
107
|
summary: Raygun application performance monitoring for Rails
|