monit_request_client 0.7.0 → 0.8.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: a4cd7750e4469b9a98f1c4d3131093507384c859d207abc4aeb2059d365970da
4
- data.tar.gz: 5c30f237efb109657b3b68028f04fcf473ca06ffeebbc85f244747acc6b2effa
3
+ metadata.gz: 0d015b0285e5bb1881feb4e07906691be6d1f6a067f0c3e31a7380a7d8aeb8a5
4
+ data.tar.gz: 6b7aef3f6c7d11bbeb7f7f2dd1f8a466245a9f843982435f0b13b91ac4ff8cb3
5
5
  SHA512:
6
- metadata.gz: '038cf859581ad24b953e28b3dbafefcca3b35b6a94fb9dc749ebd91d4861676a7bd4e4e3c5341a95d703e3e43c30a1c0282a62a28b593c6cb42645bca65e52ad'
7
- data.tar.gz: cb3f4c1cac88a985cc1ddcf9a88f2068494900eb05add6884de9b87c35b5e01a1e23b42783a726623422326a0ff51641a3c1ddd460f44a80cf0c6a1096e4bfe1
6
+ metadata.gz: 7ecfaf7a6c35afddfd6cf031b3563ec3f50eb75b207f34dc01886c10994d3f8369145d90fe6459bcba21a2de8c867264afc7778ada2f4b126d0e3bdd5c7a5398
7
+ data.tar.gz: 635b9e2c6873e504f4c1e9782f738cc8677a61fb58d2f8fd1db17791e01b1cd0f1a955c00190f7ffa88bcd44fa0a7a7bb8207a49ee143bc784561c3ceb0ba74c
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # MonitRequestClient
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/monit_request_client`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Put Rails reqeust to rabbitmq to parse. I use golang to parse it and find our application problem
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,7 +20,7 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- #### Config the yaml file
23
+ #### Config the yaml file(config/dashboard.yml)
26
24
  ```
27
25
  connect:
28
26
  host: 127.0.0.1
@@ -33,10 +31,22 @@ connect:
33
31
 
34
32
  queue_name: "tsx"
35
33
  collect_data: true
36
- path_prifex: test
34
+ path_prifex: /test
35
+ ```
36
+
37
+ #### config/application.rb
38
+ ```
39
+ require 'monit_request_client'
40
+
41
+ config.middleware.use MonitRequestClient::Statistic
37
42
  ```
38
43
 
39
- TODO: Write usage instructions here
44
+ #### set current user
45
+ ```
46
+ request.env["current_user_id"] = current_user.id
47
+ ```
48
+
49
+
40
50
 
41
51
  ## Development
42
52
 
@@ -8,16 +8,19 @@ module MonitRequestClient
8
8
  class Statistic
9
9
 
10
10
  def initialize(app)
11
- @config = YAML.load_file(Rails.root.join('config', 'dashboard.yml'))
12
- if @config["collect_data"] == false
13
- @app = app
14
- return
15
- end
16
- conn = Bunny.new(@config["connect"])
17
- conn.start
18
- channel = conn.create_channel
19
- @queue = channel.queue(@config["queue_name"], durable: true)
20
- @exchange = channel.default_exchange
11
+ begin
12
+ @config = YAML.load_file(Rails.root.join('config', 'dashboard.yml'))
13
+ if @config["collect_data"] == false
14
+ @app = app
15
+ return
16
+ end
17
+ conn = Bunny.new(@config["connect"])
18
+ conn.start
19
+ channel = conn.create_channel
20
+ @queue = channel.queue(@config["queue_name"], durable: true)
21
+ @exchange = channel.default_exchange
22
+ rescue => e
23
+ end
21
24
  @app = app
22
25
  end
23
26
 
@@ -34,7 +37,7 @@ module MonitRequestClient
34
37
  raise e
35
38
  ensure
36
39
  request = ::Rack::Request.new(env)
37
- if @config["collect_data"] == true && request.path.start_with?(@config["path_prifex"])
40
+ if @config && @config["collect_data"] == true && request.path.start_with?(@config["path_prifex"])
38
41
 
39
42
  Thread.new do
40
43
  begin
@@ -1,3 +1,3 @@
1
1
  module MonitRequestClient
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.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.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - xuxh