fluent-plugin-latency 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -3
- data/CHANGELOG.md +11 -1
- data/Gemfile +0 -1
- data/Gemfile.v0.10 +5 -0
- data/Gemfile.v0.12 +4 -0
- data/Rakefile +6 -5
- data/example.conf +22 -0
- data/fluent-plugin-latency.gemspec +2 -2
- data/lib/fluent/plugin/out_latency.rb +7 -2
- data/test/helper.rb +15 -0
- metadata +12 -11
- data/spec/out_latency_spec.rb +0 -41
- data/spec/spec_helper.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2698d36098fb68c504f5ca49f6bf2937e26dd618
|
4
|
+
data.tar.gz: 5cba743fd33eeec4fa9657443babfb64b6606d0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02d84f8dfbe1ff6ddf2df786efd8364e6128c11a94f4486529780e2bd066d4201cda310339668e5516b7ed4390e924b7aa99e2300902c21b8c330c78ceb04ee3
|
7
|
+
data.tar.gz: b6f987c88c32deca9333fe8ffd8501fd886a7420411a5f07581a352bc625d6c55cd301cc5a71b45b3f2c8f567b745a23ccdea9156fe99178c32f2f075ddc5b4e
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.v0.10
ADDED
data/Gemfile.v0.12
ADDED
data/Rakefile
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "bundler/gem_tasks"
|
3
3
|
|
4
|
-
require '
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
require 'rake/testtask'
|
5
|
+
Rake::TestTask.new(:test) do |test|
|
6
|
+
test.libs << 'lib' << 'test'
|
7
|
+
test.pattern = 'test/**/test_*.rb'
|
8
|
+
test.verbose = true
|
8
9
|
end
|
9
|
-
task :default => :
|
10
|
+
task :default => :test
|
10
11
|
|
11
12
|
desc 'Open an irb session preloaded with the gem library'
|
12
13
|
task :console do
|
data/example.conf
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
<source>
|
2
|
+
type dummy
|
3
|
+
tag raw
|
4
|
+
</source>
|
5
|
+
|
6
|
+
# Latency plugin output comes here
|
7
|
+
<match latency>
|
8
|
+
type stdout
|
9
|
+
</match>
|
10
|
+
|
11
|
+
# All messages come here once.
|
12
|
+
<match **>
|
13
|
+
type copy
|
14
|
+
<store>
|
15
|
+
type latency
|
16
|
+
tag latency
|
17
|
+
interval 1
|
18
|
+
</store>
|
19
|
+
<store>
|
20
|
+
type stdout
|
21
|
+
</store>
|
22
|
+
</match>
|
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.name = "fluent-plugin-latency"
|
6
|
-
gem.version = "0.0.
|
6
|
+
gem.version = "0.0.3"
|
7
7
|
gem.authors = ["Naotoshi Seo"]
|
8
8
|
gem.email = "sonots@gmail.com"
|
9
9
|
gem.homepage = "https://github.com/sonots/fluent-plugin-latency"
|
@@ -19,8 +19,8 @@ Gem::Specification.new do |gem|
|
|
19
19
|
|
20
20
|
gem.add_dependency "fluentd"
|
21
21
|
gem.add_development_dependency "rake"
|
22
|
-
gem.add_development_dependency "rspec"
|
23
22
|
gem.add_development_dependency "pry"
|
24
23
|
gem.add_development_dependency "pry-nav"
|
25
24
|
gem.add_development_dependency "timecop"
|
25
|
+
gem.add_development_dependency "test-unit"
|
26
26
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Fluent
|
2
|
-
class LatencyOutput <
|
2
|
+
class LatencyOutput < MultiOutput
|
3
3
|
Plugin.register_output('latency', self)
|
4
4
|
|
5
5
|
# To support log_level option implemented by Fluentd v0.10.43
|
@@ -7,6 +7,11 @@ module Fluent
|
|
7
7
|
define_method("log") { $log }
|
8
8
|
end
|
9
9
|
|
10
|
+
# Define `router` method of v0.12 to support v0.10 or earlier
|
11
|
+
unless method_defined?(:router)
|
12
|
+
define_method("router") { Fluent::Engine }
|
13
|
+
end
|
14
|
+
|
10
15
|
config_param :tag, :string, :default => 'latency'
|
11
16
|
config_param :interval, :time, :default => 60
|
12
17
|
|
@@ -57,7 +62,7 @@ module Fluent
|
|
57
62
|
max = num == 0 ? 0 : latency.max
|
58
63
|
avg = num == 0 ? 0 : latency.map(&:to_f).inject(:+) / num.to_f
|
59
64
|
message = {"max" => max, "avg" => avg, "num" => num}
|
60
|
-
|
65
|
+
router.emit(@tag, Engine.now, message)
|
61
66
|
end
|
62
67
|
end
|
63
68
|
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
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
|
+
require 'fluent/plugin/in_gc'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-latency
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: pry
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name: pry
|
56
|
+
name: pry-nav
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: timecop
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: test-unit
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -105,13 +105,15 @@ files:
|
|
105
105
|
- ".travis.yml"
|
106
106
|
- CHANGELOG.md
|
107
107
|
- Gemfile
|
108
|
+
- Gemfile.v0.10
|
109
|
+
- Gemfile.v0.12
|
108
110
|
- LICENSE
|
109
111
|
- README.md
|
110
112
|
- Rakefile
|
113
|
+
- example.conf
|
111
114
|
- fluent-plugin-latency.gemspec
|
112
115
|
- lib/fluent/plugin/out_latency.rb
|
113
|
-
-
|
114
|
-
- spec/spec_helper.rb
|
116
|
+
- test/helper.rb
|
115
117
|
homepage: https://github.com/sonots/fluent-plugin-latency
|
116
118
|
licenses:
|
117
119
|
- MIT
|
@@ -132,10 +134,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
134
|
version: '0'
|
133
135
|
requirements: []
|
134
136
|
rubyforge_project:
|
135
|
-
rubygems_version: 2.
|
137
|
+
rubygems_version: 2.5.2
|
136
138
|
signing_key:
|
137
139
|
specification_version: 4
|
138
140
|
summary: Fluentd plugin to measure latency until receiving the messages
|
139
141
|
test_files:
|
140
|
-
-
|
141
|
-
- spec/spec_helper.rb
|
142
|
+
- test/helper.rb
|
data/spec/out_latency_spec.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require_relative 'spec_helper'
|
3
|
-
|
4
|
-
describe Fluent::LatencyOutput do
|
5
|
-
before { Fluent::Test.setup }
|
6
|
-
let(:config) { %[] }
|
7
|
-
let(:tag) { 'tag' }
|
8
|
-
let(:driver) { Fluent::Test::OutputTestDriver.new(Fluent::LatencyOutput, tag).configure(config) }
|
9
|
-
|
10
|
-
describe 'test configure' do
|
11
|
-
subject { driver.instance }
|
12
|
-
|
13
|
-
context "check default" do
|
14
|
-
let(:config) { %[] }
|
15
|
-
its(:tag) { should == 'latency' }
|
16
|
-
its(:interval) { should == 60 }
|
17
|
-
end
|
18
|
-
|
19
|
-
context "check config" do
|
20
|
-
let(:config) { %[tag tag\ninterval 120]}
|
21
|
-
its(:tag) { should == 'tag' }
|
22
|
-
its(:interval) { should == 120 }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe 'test emit' do
|
27
|
-
let(:emit_time) { Time.utc(1,1,1,1,1,2010,nil,nil,nil,nil).to_i }
|
28
|
-
let(:current_time) { Time.utc(2,1,1,1,1,2010,nil,nil,nil,nil).to_i }
|
29
|
-
let(:message) { "INFO GET /ping" }
|
30
|
-
let(:expected) { {"max" => 1.0, "avg" => 1.0, "num" => 1} }
|
31
|
-
before {
|
32
|
-
Timecop.freeze(Time.at(current_time))
|
33
|
-
Fluent::Engine.should_receive(:emit).with("latency", current_time, expected)
|
34
|
-
}
|
35
|
-
after { Timecop.return }
|
36
|
-
it {
|
37
|
-
driver.run { driver.emit({'message' => message}, emit_time) }
|
38
|
-
driver.instance.flush_emit
|
39
|
-
}
|
40
|
-
end
|
41
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'rubygems'
|
3
|
-
require 'bundler'
|
4
|
-
Bundler.setup(:default, :test)
|
5
|
-
Bundler.require(:default, :test)
|
6
|
-
|
7
|
-
require 'fluent/test'
|
8
|
-
require 'rspec'
|
9
|
-
require 'pry'
|
10
|
-
require 'timecop'
|
11
|
-
|
12
|
-
$TESTING=true
|
13
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
14
|
-
require 'fluent/plugin/out_latency'
|