fluent-plugin-derive 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 +4 -4
- data/.travis.yml +2 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile.fluentd.lt.0.10.43 +8 -0
- data/Rakefile +7 -0
- data/fluent-plugin-derive.gemspec +1 -1
- data/lib/fluent/plugin/out_derive.rb +8 -3
- data/spec/out_derive_spec.rb +36 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40df6241c18260283efffec5f0f93c244c34a40b
|
4
|
+
data.tar.gz: 5915919018654ad6c36a6bb55ec333f63165ac93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24921c68f917045f314586080a70a35703e313b132ec4f1d610680c531674845fefc260b4b13c69648ca33b27d2eff6a1abac60e54b8819e6a577d94c2f5c4f2
|
7
|
+
data.tar.gz: c99527ac6b9b5479e4f5a6d2cf252473439135390110757aa495934e0da1b029c108bfdad16be77442b890f8282a9776b242942d87f96512d7df7adaa6041412
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
data/Rakefile
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "fluent-plugin-derive"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.2"
|
8
8
|
spec.authors = ["Nobuhiro Nikushi"]
|
9
9
|
spec.email = ["deneb.ge@gmail.com"]
|
10
10
|
spec.description = spec.summary
|
@@ -1,4 +1,9 @@
|
|
1
1
|
class Fluent::DeriveOutput < Fluent::Output
|
2
|
+
# Define `log` method for v0.10.42 or earlier
|
3
|
+
unless method_defined?(:log)
|
4
|
+
define_method("log") { $log }
|
5
|
+
end
|
6
|
+
|
2
7
|
Fluent::Plugin.register_output('derive', self)
|
3
8
|
|
4
9
|
KEY_MAX_NUM = 20
|
@@ -115,8 +120,8 @@ class Fluent::DeriveOutput < Fluent::Output
|
|
115
120
|
|
116
121
|
chain.next
|
117
122
|
rescue => e
|
118
|
-
|
119
|
-
|
123
|
+
log.warn e.message
|
124
|
+
log.warn e.backtrace.join(', ')
|
120
125
|
end
|
121
126
|
|
122
127
|
# @return [Array] time, value
|
@@ -147,7 +152,7 @@ class Fluent::DeriveOutput < Fluent::Output
|
|
147
152
|
|
148
153
|
def calc_rate(tag, key, cur_value, prev_value, cur_time, prev_time, adjustment = nil)
|
149
154
|
if cur_time - prev_time <= 0
|
150
|
-
|
155
|
+
log.warn "Could not calculate the rate. multiple input less than one second or minus delta of seconds on tag=#{tag}, key=#{key}"
|
151
156
|
return nil
|
152
157
|
end
|
153
158
|
rate = (cur_value - prev_value)/(cur_time - prev_time)
|
data/spec/out_derive_spec.rb
CHANGED
@@ -284,6 +284,42 @@ describe Fluent::DeriveOutput do
|
|
284
284
|
|
285
285
|
|
286
286
|
end
|
287
|
+
end
|
288
|
+
|
289
|
+
describe 'test log' do
|
290
|
+
let(:log) { driver.instance.log }
|
291
|
+
let(:base_config) { %[
|
292
|
+
tag rate
|
293
|
+
key1 foo
|
294
|
+
] }
|
295
|
+
|
296
|
+
def capture_log(log)
|
297
|
+
tmp = log.instance_variable_get(:@out)
|
298
|
+
out = StringIO.new
|
299
|
+
log.instance_variable_set(:@out, out)
|
300
|
+
yield log
|
301
|
+
return out.string
|
302
|
+
ensure
|
303
|
+
# Set back original instance to @out
|
304
|
+
log.instance_variable_set(:@out, tmp)
|
305
|
+
end
|
306
|
+
|
307
|
+
if Fluent::VERSION >= "0.10.43"
|
308
|
+
context "log_level info" do
|
309
|
+
let(:config) { base_config + %[log_level info] }
|
310
|
+
|
311
|
+
it "should not contain debug level" do
|
312
|
+
capture_log(log) {|log| log.debug "foobar" }.should == ""
|
313
|
+
end
|
314
|
+
end
|
315
|
+
end
|
287
316
|
|
317
|
+
context "log" do
|
318
|
+
let(:config) { base_config }
|
319
|
+
it "should work" do
|
320
|
+
capture_log(log) {|log| log.info "foobar" }.should include("foobar")
|
321
|
+
end
|
322
|
+
end
|
288
323
|
end
|
324
|
+
|
289
325
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-derive
|
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
|
- Nobuhiro Nikushi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -62,7 +62,9 @@ files:
|
|
62
62
|
- .gitignore
|
63
63
|
- .rspec
|
64
64
|
- .travis.yml
|
65
|
+
- CHANGELOG.md
|
65
66
|
- Gemfile
|
67
|
+
- Gemfile.fluentd.lt.0.10.43
|
66
68
|
- LICENSE.txt
|
67
69
|
- README.md
|
68
70
|
- Rakefile
|
@@ -91,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
93
|
version: '0'
|
92
94
|
requirements: []
|
93
95
|
rubyforge_project:
|
94
|
-
rubygems_version: 2.
|
96
|
+
rubygems_version: 2.0.14
|
95
97
|
signing_key:
|
96
98
|
specification_version: 4
|
97
99
|
summary: fluentd plugin to derive rate
|