wat_catcher 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/lib/wat_catcher/middleware.rb +2 -24
- data/lib/wat_catcher/sidekiq_middleware.rb +1 -11
- data/lib/wat_catcher/sidekiq_poster.rb +32 -1
- data/lib/wat_catcher/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e96646c31ecf9a0473cc40c7b79aa1324d03e83
|
4
|
+
data.tar.gz: c04e03599a4ae71659bad0330254bd9297c85d0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e80033c1674f7c944526847fedf560c6065c1d12102e73b4114e69e2d80104258a98f73dfd9f10b5b24eaa633506c5f168f44419625b106d035d98a9a3be251
|
7
|
+
data.tar.gz: df20ba615c49ad9e45af4963246c701b5e21eb97bd7700150773cec160f8047a53e61ff63452b597ea2d496c360795d0c29fc7dc394d6a45751212cace880043
|
@@ -6,30 +6,8 @@ module WatCatcher
|
|
6
6
|
|
7
7
|
def call(env)
|
8
8
|
@app.call(env)
|
9
|
-
rescue
|
10
|
-
|
11
|
-
request = env["action_controller.instance"].request
|
12
|
-
params = request.filtered_parameters
|
13
|
-
session = request.session.as_json
|
14
|
-
page_url = request.url
|
15
|
-
|
16
|
-
# Build the clean url (hide the port if it is obvious)
|
17
|
-
url = "#{request.scheme}://#{request.host}"
|
18
|
-
url << ":#{request.port}" unless [80, 443].include?(request.port)
|
19
|
-
url << request.fullpath
|
20
|
-
|
21
|
-
::WatCatcher::SidekiqPoster.perform_async(
|
22
|
-
"#{WatCatcher.configuration.host}/wats",
|
23
|
-
{
|
24
|
-
wat: {
|
25
|
-
page_url: page_url,
|
26
|
-
request_params: params,
|
27
|
-
session: session,
|
28
|
-
backtrace: excpt.backtrace.to_a,
|
29
|
-
message: excpt.message,
|
30
|
-
error_class: excpt.class.to_s
|
31
|
-
}
|
32
|
-
})
|
9
|
+
rescue Exception => exception
|
10
|
+
SidekiqPoster.report(exception, request: env["action_controller.instance"].request)
|
33
11
|
raise
|
34
12
|
end
|
35
13
|
end
|
@@ -5,17 +5,7 @@ module WatCatcher
|
|
5
5
|
yield
|
6
6
|
rescue => excpt
|
7
7
|
raise if msg["class"] == WatCatcher::SidekiqPoster.to_s
|
8
|
-
SidekiqPoster.
|
9
|
-
"#{WatCatcher.configuration.host}/wats",
|
10
|
-
{
|
11
|
-
wat: {
|
12
|
-
backtrace: excpt.backtrace.to_a,
|
13
|
-
message: excpt.message,
|
14
|
-
error_class: excpt.class.to_s,
|
15
|
-
sidekiq_msg: msg
|
16
|
-
|
17
|
-
}
|
18
|
-
})
|
8
|
+
WatCatcher::SidekiqPoster.report(excpt, sidekiq: msg)
|
19
9
|
raise
|
20
10
|
end
|
21
11
|
end
|
@@ -4,9 +4,40 @@ module WatCatcher
|
|
4
4
|
class SidekiqPoster
|
5
5
|
include Sidekiq::Worker
|
6
6
|
|
7
|
+
def self.report(exception, request: nil, sidekiq: nil)
|
8
|
+
params = {
|
9
|
+
wat: {
|
10
|
+
backtrace: exception.backtrace.to_a,
|
11
|
+
message: exception.message,
|
12
|
+
error_class: exception.class.to_s,
|
13
|
+
app_env: ::Rails.env.to_s
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
if request
|
18
|
+
request_params = request.filtered_parameters
|
19
|
+
session = request.session.as_json
|
20
|
+
page_url = request.url
|
21
|
+
|
22
|
+
params.merge!({
|
23
|
+
page_url: page_url,
|
24
|
+
request_params: request_params,
|
25
|
+
session: session,
|
26
|
+
})
|
27
|
+
end
|
28
|
+
|
29
|
+
if sidekiq
|
30
|
+
params[:wat].merge!({
|
31
|
+
sidekiq_msg: sidekiq
|
32
|
+
})
|
33
|
+
end
|
34
|
+
|
35
|
+
::WatCatcher::SidekiqPoster.perform_async("#{WatCatcher.configuration.host}/wats", params)
|
36
|
+
end
|
37
|
+
|
7
38
|
def perform(url, params)
|
8
39
|
HTTPClient.post_content(url,
|
9
|
-
body: params["wat"].
|
40
|
+
body: params["wat"].to_json,
|
10
41
|
header: {"Content-Type" => "application/json; charset=utf-8"})
|
11
42
|
end
|
12
43
|
end
|
data/lib/wat_catcher/version.rb
CHANGED