corn 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/lib/corn/post.rb +11 -5
- data/lib/corn/rack/slow_request_profiler.rb +5 -2
- metadata +49 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
5
|
-
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 51b599d133e23dba5f4266e8fa347c1792f024aa
|
4
|
+
data.tar.gz: a33e7f54214b4506cb5887ba1403a4eca2645165
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 01206afb702625ba0bd4afce972670b04e92a36c4ecb712593155e53901b651fbc1d67e12b2828a359db571532dc4c42994e04ff80864d2e606dc73258057e20
|
7
|
+
data.tar.gz: 6b53aeb5b82e2fd905df1257662403f7c8a381d55186a6371c4ff05e0ef4186eedbef498aa2999687e8df19058066e7ebf12ac6431b498ef2962e4ad808d2d21
|
data/lib/corn/post.rb
CHANGED
@@ -5,21 +5,27 @@ require 'time'
|
|
5
5
|
|
6
6
|
module Corn
|
7
7
|
class Post
|
8
|
-
def initialize
|
8
|
+
def initialize(interval)
|
9
9
|
@queue = Queue.new
|
10
|
-
@thread = start_post_thread
|
10
|
+
@thread = start_post_thread(interval)
|
11
11
|
end
|
12
12
|
|
13
13
|
def terminate
|
14
14
|
@thread.terminate
|
15
15
|
end
|
16
16
|
|
17
|
-
def start_post_thread
|
17
|
+
def start_post_thread(interval)
|
18
|
+
if interval < 1
|
19
|
+
Corn.logger.info("Corn post interval < 1 sec, change it to 1 sec")
|
20
|
+
interval = 1
|
21
|
+
else
|
22
|
+
Corn.logger.info("Corn post interval #{interval} sec(s)")
|
23
|
+
end
|
18
24
|
Thread.start do
|
19
25
|
begin
|
20
26
|
loop do
|
21
27
|
http_post(*@queue.pop)
|
22
|
-
sleep
|
28
|
+
sleep interval
|
23
29
|
end
|
24
30
|
rescue => e
|
25
31
|
Corn.logger.error("Corn post thread stopped by error #{e.message}\n#{e.backtrace.join("\n")}")
|
@@ -52,7 +58,7 @@ module Corn
|
|
52
58
|
unless res.is_a?(Net::HTTPSuccess)
|
53
59
|
Corn.logger.error("Post failed: #{res.message}(#{res.code}), response body: \n#{res.body}")
|
54
60
|
end
|
55
|
-
rescue
|
61
|
+
rescue => e
|
56
62
|
Corn.logger.error("post to #{submit_url} failed: #{e.message}\n#{e.backtrace.join("\n")}")
|
57
63
|
end
|
58
64
|
|
@@ -6,11 +6,14 @@ module Corn
|
|
6
6
|
module Rack
|
7
7
|
class SlowRequestProfiler
|
8
8
|
class ProfilingApp
|
9
|
-
def initialize(app,
|
9
|
+
def initialize(app,
|
10
|
+
slow_request_threshold=5,
|
11
|
+
sampling_interval=0.1,
|
12
|
+
post_interval=2)
|
10
13
|
@app = app
|
11
14
|
@slow_request_threshold = slow_request_threshold
|
12
15
|
@sampling_interval = sampling_interval
|
13
|
-
@post = Post.new
|
16
|
+
@post = Post.new(post_interval)
|
14
17
|
@prof = SamplingProf.new(@sampling_interval)
|
15
18
|
at_exit { terminate }
|
16
19
|
end
|
metadata
CHANGED
@@ -1,70 +1,66 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: corn
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
7
|
-
|
8
|
-
autorequire:
|
6
|
+
authors:
|
7
|
+
- Xiao Li
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
11
|
+
date: 2014-07-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sampling_prof
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.4.5
|
20
|
+
requirement: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - '>='
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.4.5
|
25
|
+
prerelease: false
|
26
|
+
type: :runtime
|
24
27
|
description: |
|
25
28
|
Corn collects your application's profiling data by sampling_prof gem, and submits the result to Corn server for analysis.
|
26
|
-
|
27
|
-
|
28
|
-
- swing1979@gmail.com
|
29
|
+
email:
|
30
|
+
- swing1979@gmail.com
|
29
31
|
executables: []
|
30
|
-
|
31
32
|
extensions: []
|
32
|
-
|
33
33
|
extra_rdoc_files: []
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
- lib/corn/rack/slow_request_profiler.rb
|
34
|
+
files:
|
35
|
+
- README.md
|
36
|
+
- lib/corn.rb
|
37
|
+
- lib/corn/config.rb
|
38
|
+
- lib/corn/post.rb
|
39
|
+
- lib/corn/rack.rb
|
40
|
+
- lib/corn/rack/request_env.rb
|
41
|
+
- lib/corn/rack/slow_request_profiler.rb
|
43
42
|
homepage: https://github.com/xli/corn
|
44
|
-
licenses:
|
45
|
-
|
43
|
+
licenses:
|
44
|
+
- MIT
|
46
45
|
metadata: {}
|
47
|
-
|
48
|
-
post_install_message:
|
46
|
+
post_install_message:
|
49
47
|
rdoc_options: []
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
62
60
|
requirements: []
|
63
|
-
|
64
|
-
rubyforge_project:
|
61
|
+
rubyforge_project:
|
65
62
|
rubygems_version: 2.1.9
|
66
|
-
signing_key:
|
63
|
+
signing_key:
|
67
64
|
specification_version: 4
|
68
65
|
summary: Corn submits profiling data to Corn server.
|
69
66
|
test_files: []
|
70
|
-
|