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 CHANGED
@@ -1,7 +1,7 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 7329740d9a00529d51463831c8ee047ec35531c5
4
- data.tar.gz: 13f56bce0d38a336482b41ae50f6c2ec6f498628
5
- SHA512:
6
- metadata.gz: 8a64caa0cfcdbeefac7fb4d9731fa3a507d8a54e23a7d99dcf7749078683b6863ac975df15079e7610ee752081b9742a3356e726a09e9d9d7cbdc13abbdd0065
7
- data.tar.gz: e5c3b41d0a6534eed079c6af31bbee42f5db71f5bd5ba63f4c016672476b9e41dddd6e58331f13d17683f91e625c826291f5efc192ca45e86363cbc4acfc07a5
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 51b599d133e23dba5f4266e8fa347c1792f024aa
4
+ data.tar.gz: a33e7f54214b4506cb5887ba1403a4eca2645165
5
+ SHA512:
6
+ metadata.gz: 01206afb702625ba0bd4afce972670b04e92a36c4ecb712593155e53901b651fbc1d67e12b2828a359db571532dc4c42994e04ff80864d2e606dc73258057e20
7
+ data.tar.gz: 6b53aeb5b82e2fd905df1257662403f7c8a381d55186a6371c4ff05e0ef4186eedbef498aa2999687e8df19058066e7ebf12ac6431b498ef2962e4ad808d2d21
@@ -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 1
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 Exception => e
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, slow_request_threshold=5, sampling_interval=0.1)
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.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.2
5
5
  platform: ruby
6
- authors:
7
- - Xiao Li
8
- autorequire:
6
+ authors:
7
+ - Xiao Li
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
-
12
- date: 2014-06-20 00:00:00 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: sampling_prof
16
- prerelease: false
17
- requirement: &id001 !ruby/object:Gem::Requirement
18
- requirements:
19
- - - ">="
20
- - !ruby/object:Gem::Version
21
- version: 0.4.5
22
- type: :runtime
23
- version_requirements: *id001
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
- email:
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
- files:
36
- - README.md
37
- - lib/corn.rb
38
- - lib/corn/config.rb
39
- - lib/corn/post.rb
40
- - lib/corn/rack.rb
41
- - lib/corn/rack/request_env.rb
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
- - MIT
43
+ licenses:
44
+ - MIT
46
45
  metadata: {}
47
-
48
- post_install_message:
46
+ post_install_message:
49
47
  rdoc_options: []
50
-
51
- require_paths:
52
- - lib
53
- required_ruby_version: !ruby/object:Gem::Requirement
54
- requirements:
55
- - &id002
56
- - ">="
57
- - !ruby/object:Gem::Version
58
- version: "0"
59
- required_rubygems_version: !ruby/object:Gem::Requirement
60
- requirements:
61
- - *id002
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
-