corn 0.1.6 → 0.1.7

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/corn.rb +21 -4
  3. data/lib/corn/rack.rb +1 -1
  4. metadata +16 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7fafc1677c9b23d84128267bb983baf5a9648849
4
- data.tar.gz: 5e9c661177cc849c775f33d6c0cbdf14f52f21ef
3
+ metadata.gz: ea5e0101cf31cad4b5ec030daadb7e18bc3b4a52
4
+ data.tar.gz: d74e50037d0cc22b80c25e0c832bc0132d041a96
5
5
  SHA512:
6
- metadata.gz: ac8103cd228868d3133c5411762fd5a6432cc956d3f208673a713b5cfd5195368f0f2c13cd8114a786872d7eab8051529a55e080a6fe89a891b9c277e69680e6
7
- data.tar.gz: 086266630498a89dbe7089b4a13c72f0befe8ac0e5e86d1d01d73969cf872072a27aadc1bfa57ca55bfd60751496df04448dfeada70a67a3e7de4f7437cf2c96
6
+ metadata.gz: 1b27f66407aaea5d4cc9d5402a10b7653895c4c63b6446b7e775f8ed0abfc9e3cf2b775d84d6085052018ddc4b5e4b297e512b1ca08cd83f680482f266ad04b5
7
+ data.tar.gz: 54fefb61535630425386803e9645d63dffd6191e9fc3a44563beac9fcb63e6d4d731f4367fdebac3d73550c9718541361c0e9a726d6321e974e1c6e7d0f13a49
@@ -1,4 +1,7 @@
1
1
  require 'sampling_prof'
2
+ require 'net/http'
3
+ require 'net/https'
4
+ require 'net/http/post/multipart'
2
5
  require 'corn/rack'
3
6
 
4
7
  module Corn
@@ -30,10 +33,7 @@ module Corn
30
33
  def submit(name)
31
34
  @prof.stop
32
35
  if configured?
33
- o = `curl -s -F data=@#{@prof.output_file.inspect} -F client_id=#{client_id.inspect} -F name=#{name.inspect} #{submit_url}`
34
- if $?.exitstatus != 0
35
- log("Submit report error: \n#{o}")
36
- end
36
+ upload(@prof.output_file, name)
37
37
  else
38
38
  log("No CORN_CLIENT_ID configured, profiling data is not submitted")
39
39
  end
@@ -46,4 +46,21 @@ module Corn
46
46
  def log(msg)
47
47
  $stderr.puts msg
48
48
  end
49
+
50
+ def upload(file, name)
51
+ url = URI.parse(submit_url)
52
+ File.open(file) do |f|
53
+ req = Net::HTTP::Post::Multipart.new(url.path,
54
+ "data" => UploadIO.new(f, "text/plain"),
55
+ 'client_id' => client_id,
56
+ 'name' => name)
57
+ res = Net::HTTP.start(url.host, url.port) do |http|
58
+ http.use_ssl = url.scheme == 'https'
59
+ http.request(req)
60
+ end
61
+ end
62
+ rescue => e
63
+ log("upload #{file} to #{submit_url} failed: #{e.message}")
64
+ log(e.backtrace.join("\n"))
65
+ end
49
66
  end
@@ -6,7 +6,7 @@ module Corn
6
6
  end
7
7
 
8
8
  def call(env)
9
- if Corn.configured?
9
+ if Corn.configured? && env["QUERY_STRING"] =~ /corn_profiling=true/
10
10
  profile do
11
11
  @app.call(env)
12
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: corn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xiao Li
@@ -9,21 +9,28 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2014-02-13 00:00:00 Z
12
+ date: 2014-03-08 00:00:00 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: sampling_prof
15
+ name: multipart-post
16
16
  prerelease: false
17
17
  requirement: &id001 !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: "0.1"
22
19
  - - ">="
23
20
  - !ruby/object:Gem::Version
24
- version: 0.1.0
21
+ version: "2.0"
25
22
  type: :runtime
26
23
  version_requirements: *id001
24
+ - !ruby/object:Gem::Dependency
25
+ name: sampling_prof
26
+ prerelease: false
27
+ requirement: &id002 !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: "0.1"
32
+ type: :runtime
33
+ version_requirements: *id002
27
34
  description: |
28
35
  Corn collects your application's profiling data by sampling_prof gem, and submits the result to server, so that you can merge multiple server's profiling data and do analysis together.
29
36
 
@@ -51,13 +58,13 @@ require_paths:
51
58
  - lib
52
59
  required_ruby_version: !ruby/object:Gem::Requirement
53
60
  requirements:
54
- - &id002
61
+ - &id003
55
62
  - ">="
56
63
  - !ruby/object:Gem::Version
57
64
  version: "0"
58
65
  required_rubygems_version: !ruby/object:Gem::Requirement
59
66
  requirements:
60
- - *id002
67
+ - *id003
61
68
  requirements: []
62
69
 
63
70
  rubyforge_project: