fluent-plugin-finagle 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 +7 -0
- data/.gitignore +20 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +24 -0
- data/Rakefile +12 -0
- data/fluent-plugin-finagle.gemspec +27 -0
- data/lib/fluent/plugin/in_finagle.rb +67 -0
- data/test/helper.rb +28 -0
- data/test/plugin/test_in_finagle.rb +27 -0
- metadata +139 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 01333988164feafa878de11a40d324faf82bc400
|
4
|
+
data.tar.gz: eda074bb6a664378ce65dc8638ba3da2c95de8c4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cbdbcca012fea8c23c7dd1bd90a4011f54400069d4fb42d2b66a384d5994b69da0940f8dbbb6cd2c15e9e957c98b7a6ddbc41df9a6eed877e9da477383cf94f9
|
7
|
+
data.tar.gz: ba7fdfba448f583a5e1299167deafb6cc36f673c94b557ef9944cb3858da26c76275225ef97fe197dfd4f97c9d7cd81b3e1b36aba89a15135ec57013fca394d8
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Kai Sasaki
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Fluent Input Plugin for Finagle metric
|
2
|
+
======================================
|
3
|
+
|
4
|
+
# Usage
|
5
|
+
|
6
|
+
```yaml
|
7
|
+
<source>
|
8
|
+
@type finagle
|
9
|
+
|
10
|
+
finagle_host exmaple.com
|
11
|
+
finagle_port 9990
|
12
|
+
metrics ['finagle/clientregistry/size', 'finagle/timer/pending_tasks.sum']
|
13
|
+
run_interval 10
|
14
|
+
</source>
|
15
|
+
```
|
16
|
+
|
17
|
+
Finagle input plugin forwards selected metrics along replacement of slash '/' with underscore '_'.
|
18
|
+
|
19
|
+
# Build
|
20
|
+
|
21
|
+
```
|
22
|
+
$ bundle exec gem build fluent-plugin-finagle.gemspec
|
23
|
+
```
|
24
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
# coding: utf-8
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fluent-plugin-finagle"
|
8
|
+
spec.version = "0.0.1"
|
9
|
+
spec.authors = ["Kai Sasaki"]
|
10
|
+
spec.email = ["lewuathe@me.com"]
|
11
|
+
spec.summary = %q{fluentd input plugin for Finagle metric}
|
12
|
+
spec.description = %q{fluentd input plugin for Finagle metric}
|
13
|
+
spec.homepage = "http://github.com/Lewuathe/fluent-plugin-finagle"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "fluentd"
|
22
|
+
spec.add_runtime_dependency "faraday"
|
23
|
+
spec.add_runtime_dependency "yajl-ruby"
|
24
|
+
spec.add_runtime_dependency "test-unit"
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'fluent/input'
|
2
|
+
require 'json'
|
3
|
+
require 'faraday'
|
4
|
+
|
5
|
+
module Fluent
|
6
|
+
|
7
|
+
class FinagleInput < Input
|
8
|
+
Plugin.register_input('finagle', self)
|
9
|
+
|
10
|
+
config_param :tag, :string, :default => nil
|
11
|
+
config_param :finagle_host, :string
|
12
|
+
config_param :finagle_port, :string
|
13
|
+
config_param :metrics, :array
|
14
|
+
config_param :run_interval, :time, :default => 60
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def configure(conf)
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def start
|
25
|
+
super
|
26
|
+
@finished = false
|
27
|
+
@thread = Thread.new(&method(:run_periodic))
|
28
|
+
@conn = Faraday.new(:url => "http://#{@finagle_host}:#{@finagle_port}") do |faraday|
|
29
|
+
faraday.request :url_encoded # form-encode POST params
|
30
|
+
faraday.response :logger # log requests to STDOUT
|
31
|
+
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def shutdown
|
36
|
+
@finished = true
|
37
|
+
@thread.join
|
38
|
+
super
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# Main loop
|
43
|
+
#
|
44
|
+
def run_periodic
|
45
|
+
until @finished
|
46
|
+
sleep @run_interval
|
47
|
+
|
48
|
+
begin
|
49
|
+
response = @conn.get '/admin/metrics.json'
|
50
|
+
json_response = JSON.parse(response.body)
|
51
|
+
|
52
|
+
@metrics.each do |metric|
|
53
|
+
router.emit(
|
54
|
+
"#{@tag}.#{metric.gsub("/", "_")}",
|
55
|
+
Engine.now.to_i,
|
56
|
+
json_response[metric]
|
57
|
+
)
|
58
|
+
end
|
59
|
+
rescue => e
|
60
|
+
$log.warn "Failed to get Finagle metrics, but ignored: #{e.message}"
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
13
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
+
require 'fluent/test'
|
15
|
+
unless ENV.has_key?('VERBOSE')
|
16
|
+
nulllogger = Object.new
|
17
|
+
nulllogger.instance_eval {|obj|
|
18
|
+
def method_missing(method, *args)
|
19
|
+
# pass
|
20
|
+
end
|
21
|
+
}
|
22
|
+
$log = nulllogger
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'fluent/plugin/in_finagle'
|
26
|
+
|
27
|
+
class Test::Unit::TestCase
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
require 'fluent/test'
|
4
|
+
require 'fluent/plugin/in_finagle'
|
5
|
+
|
6
|
+
class FinagleInputTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
CONFIG = %[
|
9
|
+
finagle_host 127.0.0.1
|
10
|
+
finagle_port 9990
|
11
|
+
metrics ["metricA", "metricB"]
|
12
|
+
]
|
13
|
+
def setup
|
14
|
+
Fluent::Test.setup
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_driver(conf=CONFIG)
|
18
|
+
Fluent::Test::InputTestDriver.new(Fluent::FinagleInput).configure(conf, true)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_configure
|
22
|
+
d = create_driver
|
23
|
+
assert_equal '127.0.0.1', d.instance.finagle_host
|
24
|
+
assert_equal '9990', d.instance.finagle_port
|
25
|
+
assert_equal ['metricA', 'metricB'], d.instance.metrics
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-finagle
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kai Sasaki
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fluentd
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: yajl-ruby
|
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: test-unit
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.5'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.5'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: fluentd input plugin for Finagle metric
|
98
|
+
email:
|
99
|
+
- lewuathe@me.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- Gemfile
|
106
|
+
- LICENSE
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- fluent-plugin-finagle.gemspec
|
110
|
+
- lib/fluent/plugin/in_finagle.rb
|
111
|
+
- test/helper.rb
|
112
|
+
- test/plugin/test_in_finagle.rb
|
113
|
+
homepage: http://github.com/Lewuathe/fluent-plugin-finagle
|
114
|
+
licenses:
|
115
|
+
- MIT
|
116
|
+
metadata: {}
|
117
|
+
post_install_message:
|
118
|
+
rdoc_options: []
|
119
|
+
require_paths:
|
120
|
+
- lib
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
requirements: []
|
132
|
+
rubyforge_project:
|
133
|
+
rubygems_version: 2.5.1
|
134
|
+
signing_key:
|
135
|
+
specification_version: 4
|
136
|
+
summary: fluentd input plugin for Finagle metric
|
137
|
+
test_files:
|
138
|
+
- test/helper.rb
|
139
|
+
- test/plugin/test_in_finagle.rb
|