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 +4 -4
- data/README.md +16 -6
- data/lib/monit_request_client.rb +14 -11
- data/lib/monit_request_client/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d015b0285e5bb1881feb4e07906691be6d1f6a067f0c3e31a7380a7d8aeb8a5
|
4
|
+
data.tar.gz: 6b7aef3f6c7d11bbeb7f7f2dd1f8a466245a9f843982435f0b13b91ac4ff8cb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ecfaf7a6c35afddfd6cf031b3563ec3f50eb75b207f34dc01886c10994d3f8369145d90fe6459bcba21a2de8c867264afc7778ada2f4b126d0e3bdd5c7a5398
|
7
|
+
data.tar.gz: 635b9e2c6873e504f4c1e9782f738cc8677a61fb58d2f8fd1db17791e01b1cd0f1a955c00190f7ffa88bcd44fa0a7a7bb8207a49ee143bc784561c3ceb0ba74c
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# MonitRequestClient
|
2
2
|
|
3
|
-
|
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
|
-
|
44
|
+
#### set current user
|
45
|
+
```
|
46
|
+
request.env["current_user_id"] = current_user.id
|
47
|
+
```
|
48
|
+
|
49
|
+
|
40
50
|
|
41
51
|
## Development
|
42
52
|
|
data/lib/monit_request_client.rb
CHANGED
@@ -8,16 +8,19 @@ module MonitRequestClient
|
|
8
8
|
class Statistic
|
9
9
|
|
10
10
|
def initialize(app)
|
11
|
-
|
12
|
-
|
13
|
-
@
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|