fluent-rubyprof 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +68 -0
- data/Rakefile +14 -0
- data/bin/fluent-rubyprof +6 -0
- data/fluent-rubyprof.gemspec +23 -0
- data/lib/fluent/rubyprof.rb +82 -0
- data/spec/fluent-rubyprof/fluent.conf +8 -0
- data/spec/fluent-rubyprof/rubyprof_spec.rb +28 -0
- data/spec/spec_helper.rb +2 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1c5af4225bd048f530f0bc17efa9b1c1ef302065
|
4
|
+
data.tar.gz: 279ca1e6851adcfc89f9320b9d9b436b6835b069
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9f03e5ea2f437bfb9ec0bdd84ced3bc3060e4c8dad2b9edb36c8f9770273a43795506441aac803dc1ad067be80ad44c3ad3e8ebb1464195d4c745f56ef37f71e
|
7
|
+
data.tar.gz: 15789d6ed25664f8b66771fcc97b6a0061f1e99b2a89f3469624fa42b59bc5dac6852f811ccd1ad2f843e9352a79038ac0ad765e8bc9e5446a8542be4ba78848
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Naotoshi Seo
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Fluent::Rubyprof
|
2
|
+
|
3
|
+
Using fluent-rubyprof, you can start and stop ruby-prof dynamically from outside of fluentd without any configuration changes.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```
|
8
|
+
$ fluent-gem install fluent-rubyprof
|
9
|
+
```
|
10
|
+
|
11
|
+
## Prerequisite
|
12
|
+
|
13
|
+
`in_debug_agent` plugin is required to be enabled.
|
14
|
+
|
15
|
+
```
|
16
|
+
<source>
|
17
|
+
type debug_agent
|
18
|
+
</source>
|
19
|
+
```
|
20
|
+
|
21
|
+
And, `ruby-prof` gem is required.
|
22
|
+
|
23
|
+
```
|
24
|
+
$ fluent-gem install ruby-prof
|
25
|
+
```
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
Start
|
30
|
+
|
31
|
+
```
|
32
|
+
$ fluent-rubyprof start
|
33
|
+
```
|
34
|
+
|
35
|
+
Stop and write a profiling result.
|
36
|
+
|
37
|
+
```
|
38
|
+
$ fluent-rubyprof stop -o /tmp/fluent-rubyprof.txt
|
39
|
+
```
|
40
|
+
|
41
|
+
## Options
|
42
|
+
|
43
|
+
|parameter|description|default|
|
44
|
+
|---|---|---|
|
45
|
+
|-h, --host HOST|fluent host|127.0.0.1|
|
46
|
+
|-p, --port PORT|debug_agent|24230|
|
47
|
+
|-u, --unix PATH|use unix socket instead of tcp||
|
48
|
+
|-o, --output PATH|output file|/tmp/fluent-rubyprof.txt|
|
49
|
+
|
50
|
+
## ChangeLog
|
51
|
+
|
52
|
+
See [CHANGELOG.md](./CHANGELOG.md)
|
53
|
+
|
54
|
+
## Contributing
|
55
|
+
|
56
|
+
1. Fork it ( http://github.com/sonots/fluent-rubyprof/fork )
|
57
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
58
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
59
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
60
|
+
5. Create new Pull Request
|
61
|
+
|
62
|
+
## Copyright
|
63
|
+
|
64
|
+
See [LICENSE.txt](./LICENSE.txt)
|
65
|
+
|
66
|
+
## Special Thanks
|
67
|
+
|
68
|
+
I refered implemention of [fluent-tail](https://github.com/choplin/fluent-tail). Thanks!
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
require 'rspec/core'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
6
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
7
|
+
end
|
8
|
+
task :default => :spec
|
9
|
+
|
10
|
+
desc 'Open an irb session preloaded with the gem library'
|
11
|
+
task :console do
|
12
|
+
sh 'irb -rubygems -I lib'
|
13
|
+
end
|
14
|
+
task :c => :console
|
data/bin/fluent-rubyprof
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "fluent-rubyprof"
|
7
|
+
spec.version = "0.0.1"
|
8
|
+
spec.authors = ["Naotoshi Seo"]
|
9
|
+
spec.email = ["sonots@gmail.com"]
|
10
|
+
spec.summary = %q{Tools for start/stop ruby-prof dynamically from outside of fluentd}
|
11
|
+
spec.description = spec.summary
|
12
|
+
spec.homepage = "https://github.com/sonots/fluent-rubyprof"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_development_dependency "rspec"
|
23
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'drb/drb'
|
3
|
+
|
4
|
+
def parse_options
|
5
|
+
op = OptionParser.new
|
6
|
+
op.banner += ' <start/stop> [output_file]'
|
7
|
+
|
8
|
+
(class<<self;self;end).module_eval do
|
9
|
+
define_method(:usage) do |msg|
|
10
|
+
puts op.to_s
|
11
|
+
puts "error: #{msg}" if msg
|
12
|
+
exit 1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
opts = {
|
17
|
+
host: '127.0.0.1',
|
18
|
+
port: 24230,
|
19
|
+
unix: nil,
|
20
|
+
command: nil, # start or stop
|
21
|
+
output: '/tmp/fluent-rubyprof.txt'
|
22
|
+
}
|
23
|
+
|
24
|
+
op.on('-h', '--host HOST', "fluent host (default: #{opts[:host]})") {|v|
|
25
|
+
opts[:host] = v
|
26
|
+
}
|
27
|
+
|
28
|
+
op.on('-p', '--port PORT', "debug_agent tcp port (default: #{opts[:host]})", Integer) {|v|
|
29
|
+
opts[:port] = v
|
30
|
+
}
|
31
|
+
|
32
|
+
op.on('-u', '--unix PATH', "use unix socket instead of tcp") {|v|
|
33
|
+
opts[:unix] = v
|
34
|
+
}
|
35
|
+
|
36
|
+
op.on('-o', '--output PATH', "output path (default: #{opts[:output]})") {|v|
|
37
|
+
opts[:output] = v
|
38
|
+
}
|
39
|
+
|
40
|
+
begin
|
41
|
+
op.parse!(ARGV)
|
42
|
+
opts[:command] = ARGV.shift
|
43
|
+
unless %w[start stop].include?(opts[:command])
|
44
|
+
usage "`start` or `stop` must be specified as the 1st argument"
|
45
|
+
end
|
46
|
+
rescue
|
47
|
+
usage $!.to_s
|
48
|
+
end
|
49
|
+
|
50
|
+
opts
|
51
|
+
end
|
52
|
+
|
53
|
+
def main
|
54
|
+
opts = parse_options
|
55
|
+
|
56
|
+
unless opts[:unix].nil?
|
57
|
+
uri = "drbunix:#{opts[:unix]}"
|
58
|
+
else
|
59
|
+
uri = "druby://#{opts[:host]}:#{opts[:port]}"
|
60
|
+
end
|
61
|
+
|
62
|
+
$remote_engine = DRb::DRbObject.new_with_uri(uri)
|
63
|
+
|
64
|
+
case opts[:command]
|
65
|
+
when 'start'
|
66
|
+
remote_code = <<-CODE
|
67
|
+
require 'ruby-prof'
|
68
|
+
RubyProf.start
|
69
|
+
CODE
|
70
|
+
when 'stop'
|
71
|
+
remote_code = <<-"CODE"
|
72
|
+
result = RubyProf.stop
|
73
|
+
File.open('#{opts[:output]}', 'w') {|f|
|
74
|
+
RubyProf::FlatPrinter.new(result).print(f)
|
75
|
+
}
|
76
|
+
CODE
|
77
|
+
end
|
78
|
+
|
79
|
+
$remote_engine.method_missing(:instance_eval, remote_code)
|
80
|
+
end
|
81
|
+
|
82
|
+
main
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe 'Fluent::Rubyprof' do
|
5
|
+
CONFIG_PATH = File.join(File.dirname(__FILE__), 'fluent.conf')
|
6
|
+
BIN_DIR = File.join(ROOT, 'bin')
|
7
|
+
OUTPUT_FILE = File.join(File.dirname(__FILE__), 'test.txt')
|
8
|
+
|
9
|
+
before :all do
|
10
|
+
@fluentd_pid = spawn('fluentd', '-c', CONFIG_PATH, out: '/dev/null')
|
11
|
+
sleep 2
|
12
|
+
|
13
|
+
system("#{File.join(BIN_DIR, 'fluent-rubyprof')} start")
|
14
|
+
sleep 2
|
15
|
+
|
16
|
+
system("#{File.join(BIN_DIR, 'fluent-rubyprof')} stop -o #{OUTPUT_FILE}")
|
17
|
+
sleep 1
|
18
|
+
end
|
19
|
+
|
20
|
+
after :all do
|
21
|
+
Process.kill(:TERM, @fluentd_pid)
|
22
|
+
Process.waitall
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'outputs profiling result' do
|
26
|
+
expect(File.size?(OUTPUT_FILE)).to be_truthy
|
27
|
+
end
|
28
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-rubyprof
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Naotoshi Seo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Tools for start/stop ruby-prof dynamically from outside of fluentd
|
56
|
+
email:
|
57
|
+
- sonots@gmail.com
|
58
|
+
executables:
|
59
|
+
- fluent-rubyprof
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/fluent-rubyprof
|
71
|
+
- fluent-rubyprof.gemspec
|
72
|
+
- lib/fluent/rubyprof.rb
|
73
|
+
- spec/fluent-rubyprof/fluent.conf
|
74
|
+
- spec/fluent-rubyprof/rubyprof_spec.rb
|
75
|
+
- spec/spec_helper.rb
|
76
|
+
homepage: https://github.com/sonots/fluent-rubyprof
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.2.0
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Tools for start/stop ruby-prof dynamically from outside of fluentd
|
100
|
+
test_files:
|
101
|
+
- spec/fluent-rubyprof/fluent.conf
|
102
|
+
- spec/fluent-rubyprof/rubyprof_spec.rb
|
103
|
+
- spec/spec_helper.rb
|