fluent-plugin-flowcounter-simple 0.0.1 → 0.0.2
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8e491670e8cee03e6d51c446f9badb87951ace5
|
4
|
+
data.tar.gz: 9cb4eef75cba08e0c48dd242ccd61b37b5eaac4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 851accf3bcec68a82e6edc2bdfb64086d1edd6e9dfd58fa169b5d6fde1fb76aeb570e4a1523c20cb36ae0dfcffc3cd92d6e2cefa4f572106476135159b2b00e8
|
7
|
+
data.tar.gz: b4dbea650c4447a9ff946d4703bda7c679dc650fbfc43a5cff38e3145b380b048e8dae287028e1341d71cc637d1ec6cf1914b0e3f2d32693b77a7d5600d38ac7
|
data/README.md
CHANGED
@@ -23,6 +23,10 @@ This plugin does not emit, just writes into the log file as
|
|
23
23
|
|
24
24
|
One of num/byte. Default: num
|
25
25
|
|
26
|
+
- comment
|
27
|
+
|
28
|
+
Just a comment. You may use this to mark where you put flowcounter_simple.
|
29
|
+
|
26
30
|
## Relatives
|
27
31
|
|
28
32
|
There is a [fluent-plugin-flowcounter](https://github.com/tagomoris/fluent-plugin-flowcounter),
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |gem|
|
3
3
|
gem.name = "fluent-plugin-flowcounter-simple"
|
4
|
-
gem.version = "0.0.
|
4
|
+
gem.version = "0.0.2"
|
5
5
|
gem.authors = ["Naotoshi Seo"]
|
6
6
|
gem.email = ["sonots@gmail.com"]
|
7
7
|
gem.summary = %q{Simple Fluentd Plugin to count number of messages and outputs to log}
|
@@ -3,6 +3,7 @@ class Fluent::FlowCounterSimpleOutput < Fluent::Output
|
|
3
3
|
|
4
4
|
config_param :indicator, :string, :default => 'num'
|
5
5
|
config_param :unit, :string, :default => 'second'
|
6
|
+
config_param :comment, :string, :default => nil
|
6
7
|
|
7
8
|
attr_accessor :last_checked
|
8
9
|
|
@@ -35,6 +36,13 @@ class Fluent::FlowCounterSimpleOutput < Fluent::Output
|
|
35
36
|
raise RuntimeError, "@unit must be one of second/minute/hour/day"
|
36
37
|
end
|
37
38
|
|
39
|
+
@output_proc =
|
40
|
+
if @comment
|
41
|
+
Proc.new {|count| "plugin:out_flowcounter_simple\tcount:#{count}\tindicator:#{@indicator}\tunit:#{@unit}\tcomment:#{@comment}" }
|
42
|
+
else
|
43
|
+
Proc.new {|count| "plugin:out_flowcounter_simple\tcount:#{count}\tindicator:#{@indicator}\tunit:#{@unit}" }
|
44
|
+
end
|
45
|
+
|
38
46
|
@count = 0
|
39
47
|
@mutex = Mutex.new
|
40
48
|
end
|
@@ -59,7 +67,7 @@ class Fluent::FlowCounterSimpleOutput < Fluent::Output
|
|
59
67
|
def flush_emit(step)
|
60
68
|
count, @count = @count, 0
|
61
69
|
if count > 0
|
62
|
-
$log.info
|
70
|
+
$log.info @output_proc.call(count)
|
63
71
|
end
|
64
72
|
end
|
65
73
|
|
@@ -54,6 +54,19 @@ class FlowCounterSimpleOutputTest < Test::Unit::TestCase
|
|
54
54
|
assert( log.include?("count:3360"), log )
|
55
55
|
end
|
56
56
|
|
57
|
+
def test_comment
|
58
|
+
d1 = create_driver(CONFIG + %[comment foobar], 'test.tag1')
|
59
|
+
d1.run do
|
60
|
+
1.times do
|
61
|
+
d1.emit({'message'=> 'a' * 100})
|
62
|
+
d1.emit({'message'=> 'b' * 100})
|
63
|
+
d1.emit({'message'=> 'c' * 100})
|
64
|
+
end
|
65
|
+
end
|
66
|
+
log = capture_log { d1.instance.flush_emit(60) }
|
67
|
+
assert( log.include?("comment:foobar"), log )
|
68
|
+
end
|
69
|
+
|
57
70
|
private
|
58
71
|
|
59
72
|
def capture_log
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-flowcounter-simple
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
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: 2014-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|