fluent-plugin-ruby-memory-usage-profiler 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 92df6c82ca37fad051b5fd4117cfbe4125378a1b
4
+ data.tar.gz: d4f0a4e8b33e3ca128a1dfae15524de7046ac4b9
5
+ SHA512:
6
+ metadata.gz: 989aa3d31544dcd4558e6780a7b45f125e6938feb8880424973fb198442637dc6b5565fdf110736c6e1c6b3fae14724f2ddc70085a031cb0dcf4fad0ec387ec3
7
+ data.tar.gz: 771ec30bd0700f27bf4e02b7f92775069f0e44dd5f284345fbb3b3390ea74faca28a17a65c1b7a6a7d532dd73c68989cc2a26163caaa8333260d501826b551e7
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-ruby-memory-profiler.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012- TAGOMORI Satoshi
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Fluent::Plugin::Ruby::Memory::Profiler
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'fluent-plugin-ruby-memory-profiler'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install fluent-plugin-ruby-memory-profiler
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/example/emit.conf ADDED
@@ -0,0 +1,7 @@
1
+ <source>
2
+ type ruby_memory_usage_profiler
3
+ </source>
4
+
5
+ <match memory_usage_profile>
6
+ type stdout
7
+ </match>
data/example/log.conf ADDED
@@ -0,0 +1,6 @@
1
+ <source>
2
+ type ruby_memory_usage_profiler
3
+ output_type log
4
+ loglevel info
5
+ </source>
6
+
@@ -0,0 +1,6 @@
1
+ <source>
2
+ type ruby_memory_usage_profiler
3
+ output_type file
4
+ path -
5
+ </source>
6
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "fluent-plugin-ruby-memory-usage-profiler"
5
+ spec.version = "0.0.1"
6
+ spec.authors = ["TAGOMORI Satoshi"]
7
+ spec.email = ["tagomoris@gmail.com"]
8
+ spec.description = %q{Collect memory usage profile information and emit it (or output on fluentd log)}
9
+ spec.summary = %q{Fluentd input plugin for memory usage profile of Ruby runtime and OS}
10
+ spec.homepage = "https://github.com/tagomoris/fluent-plugin-ruby-memory-usage-profiler"
11
+ spec.license = "APLv2"
12
+
13
+ spec.files = `git ls-files`.split($/)
14
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.add_development_dependency "bundler", "~> 1.3"
19
+ spec.add_development_dependency "rake"
20
+
21
+ spec.add_runtime_dependency "fluentd"
22
+ spec.add_runtime_dependency "ruby-memory-usage-profiler", ">= 0.0.2"
23
+ end
@@ -0,0 +1,63 @@
1
+ module Fluent
2
+ class RubyMemoryUsageProfilerInput < Input
3
+ Fluent::Plugin.register_input('ruby_memory_usage_profiler', self)
4
+
5
+ config_param :output_type, :string, :default => 'event' # 'event', 'log' or 'file'
6
+
7
+ config_param :duration, :integer, :default => 1
8
+ config_param :name, :string, :default => 'fluentd_memory'
9
+
10
+ config_param :tag, :string, :default => 'memory_usage_profile'
11
+ config_param :loglevel, :string, :default => 'info'
12
+ config_param :path, :string, :default => nil # for 'output file'
13
+
14
+ def initialize
15
+ super
16
+ require 'memory_usage_profiler'
17
+ end
18
+
19
+ def configure(conf)
20
+ super
21
+
22
+ @banner = MemoryUsageProfiler.banner_items
23
+
24
+ case @output_type
25
+ when 'event'
26
+ @out = lambda{|result| Fluent::Engine.emit(@tag, Fluent::Engine.now, Hash[ [@banner, result].transpose ])}
27
+ when 'log'
28
+ @loglevel = @loglevel.to_sym
29
+ @out = lambda{|result| $log.send(@loglevel, Hash[ [@banner, result].transpose ])}
30
+ when 'file'
31
+ raise Fluent::ConfigError, "'path' must be specified for 'output_type file'" unless @path
32
+ @file = (@path == '-' ? STDOUT : open(@path, 'w+'))
33
+ raise Fluent::ConfigError, "failed to open file '#{@path}' to write" unless @file
34
+ @file.sync = true
35
+ @file.puts @banner.join("\t")
36
+ @out = lambda{|result| @file.puts result.join("\t")}
37
+ else
38
+ raise Fluent::ConfigError, "invalid output_type '#{@output_type}'"
39
+ end
40
+ end
41
+
42
+ def start
43
+ super
44
+ @running = true
45
+ @thread = Thread.new do
46
+ begin
47
+ while @running
48
+ MemoryUsageProfiler.kick(@name) {|result|
49
+ @out.call(result)
50
+ }
51
+ sleep @duration
52
+ end
53
+ rescue => e
54
+ $log.error "Unexpected error in ruby_memory_usage_profiler", :error_class => e.class, :error => e
55
+ end
56
+ end
57
+ end
58
+
59
+ def stop
60
+ @running = false
61
+ end
62
+ end
63
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-ruby-memory-usage-profiler
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - TAGOMORI Satoshi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-04 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
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: fluentd
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: ruby-memory-usage-profiler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.0.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.0.2
69
+ description: Collect memory usage profile information and emit it (or output on fluentd
70
+ log)
71
+ email:
72
+ - tagomoris@gmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - example/emit.conf
83
+ - example/log.conf
84
+ - example/stdout.conf
85
+ - fluent-plugin-ruby-memory-usage-profiler.gemspec
86
+ - lib/fluent/plugin/in_ruby_memory_usage_profiler.rb
87
+ homepage: https://github.com/tagomoris/fluent-plugin-ruby-memory-usage-profiler
88
+ licenses:
89
+ - APLv2
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.0.3
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: Fluentd input plugin for memory usage profile of Ruby runtime and OS
111
+ test_files: []
112
+ has_rdoc: