raygun-apm-rails 1.0.40 → 1.0.58
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 -12
- data/lib/raygun/apm/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0960b482d47c77c0448eecb23722f1fb206327b7de89eb2db02e7cc90a51efd4'
|
4
|
+
data.tar.gz: 01537cda34b2134a80fd2eb7fc2d314707756877b17baca4e4818861a7d5e3d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: beb414f861e3b325489e5f14a2527d2dac0507106e1bcf187c1d66f60c9a335ec8001dfae20e70873a9c242d47d7926d93367bef231d133e12371062bcbc051b
|
7
|
+
data.tar.gz: 3a81267f8f9fdd3d796c49db6e0a14d10e3b80050d814bd751da1af858d2d387b0f6ec39022ac4e726fc801d8b6590919ef115e28742fb61a0c7e233b742d4fd
|
@@ -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'] || env['REQUEST_URI']).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
|
@@ -29,15 +36,15 @@ module Raygun
|
|
29
36
|
begin
|
30
37
|
res = @app.call(env)
|
31
38
|
rescue => e
|
32
|
-
crash_report_exception(e)
|
33
|
-
exceptional_http_in_handler(env
|
39
|
+
crash_report_exception(e, env)
|
40
|
+
exceptional_http_in_handler(env) if @tracer
|
34
41
|
exception = e
|
35
42
|
end
|
36
43
|
end
|
37
44
|
# Can be nil if we had a fatal error
|
38
45
|
if @tracer
|
39
|
-
@tracer.end_trace
|
40
46
|
@tracer.diagnostics if ENV['PROTON_DIAGNOSTICS']
|
47
|
+
@tracer.end_trace
|
41
48
|
end
|
42
49
|
raise exception if exception
|
43
50
|
res
|
@@ -96,7 +103,7 @@ module Raygun
|
|
96
103
|
event[:pid] = Process.pid
|
97
104
|
event[:url] = url
|
98
105
|
event[:verb] = verb
|
99
|
-
event[:status] = notification.payload[:status]
|
106
|
+
event[:status] = notification.payload[:status] || notification.payload[:headers]["action_controller.instance"].status
|
100
107
|
# XXX constant milliseconds to microseconds
|
101
108
|
event[:duration] = notification.duration * 1000
|
102
109
|
event[:timestamp] = @tracer.now
|
@@ -108,13 +115,13 @@ module Raygun
|
|
108
115
|
end
|
109
116
|
|
110
117
|
# For middleware chain halts that does not trigger 'process_action.action_controller'
|
111
|
-
def exceptional_http_in_handler(env
|
118
|
+
def exceptional_http_in_handler(env)
|
112
119
|
req = Rack::Request.new env
|
113
120
|
event = http_in_event
|
114
121
|
event[:pid] = Process.pid
|
115
122
|
event[:url] = req.url
|
116
123
|
event[:verb] = req.request_method
|
117
|
-
event[:status] =
|
124
|
+
event[:status] = 500
|
118
125
|
event[:duration] = @tracer.now - @request_started
|
119
126
|
event[:timestamp] = @tracer.now
|
120
127
|
event[:tid] = @tracer.get_thread_id(Thread.current)
|
@@ -141,7 +148,7 @@ module Raygun
|
|
141
148
|
|
142
149
|
# XXX this is hacky
|
143
150
|
if config = connection.instance_variable_get('@config')
|
144
|
-
event[:provider] = config
|
151
|
+
event[:provider] = get_sql_provider_name(config)
|
145
152
|
event[:host] = config[:host]
|
146
153
|
event[:database] = config[:database]
|
147
154
|
end
|
@@ -156,6 +163,14 @@ module Raygun
|
|
156
163
|
raygun_shutdown_handler(e)
|
157
164
|
end
|
158
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
|
+
|
159
174
|
def sql_event
|
160
175
|
@sql_event ||= Raygun::Apm::Event::Sql.new
|
161
176
|
end
|
@@ -168,9 +183,10 @@ module Raygun
|
|
168
183
|
yield
|
169
184
|
end
|
170
185
|
|
171
|
-
def crash_report_exception(exception)
|
186
|
+
def crash_report_exception(exception, env = {})
|
172
187
|
if Raygun::Apm::Rails.raygun4ruby?
|
173
|
-
|
188
|
+
env.merge!(correlation_id: exception.instance_variable_get(:@__raygun_correlation_id))
|
189
|
+
Raygun.track_exception(exception, env)
|
174
190
|
end
|
175
191
|
end
|
176
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.58
|
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-03-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: raygun-apm
|