monit_request_client 0.4.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 797531319b18579ac3abf863c08dc7a1821b3526770c336f3ff9f394540351d3
4
- data.tar.gz: 1b9281cd866c27bce5901e5c498daf337c00315424fdf54ea0117b5c678706ca
3
+ metadata.gz: 8bd5f8ec96857f33a6a8701e831503ec2c5f01171b5f1dbb61f58c6b95e6e31d
4
+ data.tar.gz: f0754a6efbf67dcd6d2de5396466c2de6f9f4c4ac745792f97830d7749a1f74a
5
5
  SHA512:
6
- metadata.gz: b4174a4ce1833bcb0aae9dcf96dc0a6621daba9366d300e5c3bd1d6217bb84de61ccbc743acd1d4f73929e360f837346a52c50c0646cafde02bef19cc9224c65
7
- data.tar.gz: 261b2bbe1f98de4487d82cece386639d44f4f69185a99238397bedfd42ab0436ae4fe7f1a923da9ebc63a18d8ebdb8e9226f27b9350af5b645efa146e3b857fa
6
+ metadata.gz: 3dfca5eb9babe17e769497e5782084a9aa5c9b15abb2ad84715f7311a52407a22b7345a18b603b63436dc8d34f07407ae2c419b01406ff6d5b26c0b5317aae19
7
+ data.tar.gz: 9d24ccb8f159a1292d903a2be1c07caf0acebb458c87642a0f7f9de6375759349ca872c5c9d1b1ac317cd39452b439b424b56d24704240112c4460a77a57637b
@@ -1,7 +1,8 @@
1
1
  require "monit_request_client/version"
2
2
 
3
3
  module MonitRequestClient
4
- class Error < StandardError; end
4
+ class Error < StandardError;
5
+ end
5
6
  # Your code goes here...
6
7
  require 'bunny'
7
8
  class Statistic
@@ -15,7 +16,7 @@ module MonitRequestClient
15
16
  conn = Bunny.new(@config["connect"])
16
17
  conn.start
17
18
  channel = conn.create_channel
18
- @queue = channel.queue(@config["queue_name"])
19
+ @queue = channel.queue(@config["queue_name"])
19
20
  @app = app
20
21
  end
21
22
 
@@ -33,13 +34,17 @@ module MonitRequestClient
33
34
  raise e
34
35
  ensure
35
36
  if @config["collect_data"] == true && request.path.start_with?(@config["path_prifex"])
36
- begin
37
- Thread.new do
38
- if response
39
- body = JSON.parse(response.body)["head"]["code"]
40
- if body && body["head"] && body["head"]["code"]
41
- code = body["head"]["code"]
37
+
38
+ Thread.new do
39
+ begin
40
+ begin
41
+ if response && request.format == "json"
42
+ body = JSON.parse(response.body)["head"]["code"]
43
+ if body && body["head"] && body["head"]["code"]
44
+ code = body["head"]["code"]
45
+ end
42
46
  end
47
+ rescue => e
43
48
  end
44
49
  stop = Time.now
45
50
  data = {"path" => request.path}
@@ -51,11 +56,11 @@ module MonitRequestClient
51
56
  data["exception"] = exception_message
52
57
  data["exception_content"] = trace
53
58
  data["ip"] = request.ip
54
- data["user_id"] = env["current_user_id"]
59
+ data["user_id"] = env["current_user_id"]
55
60
  data["user_agent"] = request.user_agent
56
61
  @queue.publish(data.to_json)
62
+ rescue => e
57
63
  end
58
- rescue => e
59
64
  end
60
65
  end
61
66
  end
@@ -1,3 +1,3 @@
1
1
  module MonitRequestClient
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monit_request_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - xuxh