fluent-plugin-time-sampling 1.0.2 → 1.0.3
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: 48c74109450def1620ed77ffd0a3f61eccce9c6e
|
4
|
+
data.tar.gz: 2a7af22aedaccd4f0301c23a05622867fd47ce8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f9d3d34e5fb1f2e09cfe2dc315da236f0b46fad216eda6794b19ff3c78092d8558fd705ed7b06146c62156215cdbf05ca686c9f6ce30c66e459bfe34e5f8340
|
7
|
+
data.tar.gz: ec895b440c3cdafe843f273eb1214253e978120878d403c10a82ee92e5075c117fdbacf2536c1235bcbab62fd528b475063fa2f5b8381229e7d96f2817fcf8a4
|
data/README.md
CHANGED
@@ -25,15 +25,17 @@ Example:
|
|
25
25
|
|
26
26
|
Assume following input in 10 seconds:
|
27
27
|
```
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
test.tag { "hostname": "host1", "sample_key1": "foo", "sample_key2": "aaa" }
|
29
|
+
test.tag { "hostname": "host1", "sample_key1": "foo", "sample_key2": "bbb" }
|
30
|
+
test.tag { "hostname": "host2", "sample_key1": "bar", "sample_key2": "ccc" }
|
31
|
+
test.tag { "hostname": "host2", "sample_key1": "baz", "sample_key2": "ddd" }
|
31
32
|
```
|
32
33
|
|
33
34
|
then output is below:
|
34
35
|
```
|
35
|
-
|
36
|
-
|
36
|
+
test.tag { "hostname": "host1", "sample_key2": "aaa" }
|
37
|
+
test.tag { "hostname": "host2", "sample_key2": "ccc" }
|
38
|
+
test.tag { "hostname": "host2", "sample_key2": "ddd" }
|
37
39
|
```
|
38
40
|
|
39
41
|
## Configuration
|
@@ -4,10 +4,10 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = "fluent-plugin-time-sampling"
|
7
|
-
gem.version = "1.0.
|
7
|
+
gem.version = "1.0.3"
|
8
8
|
gem.authors = ["Yuki Kuwabara"]
|
9
9
|
gem.email = ["eramuk@gmail.com"]
|
10
|
-
gem.summary = "
|
10
|
+
gem.summary = "Fluentd filter plugin to sampling from tag and keys at time interval"
|
11
11
|
gem.description = gem.summary
|
12
12
|
gem.homepage = "https://github.com/eramuk/fluent-plugin-time-sampling"
|
13
13
|
gem.licenses = ["MIT"]
|
@@ -12,10 +12,9 @@ module Fluent::Plugin
|
|
12
12
|
def configure(conf)
|
13
13
|
super
|
14
14
|
@cache = {}
|
15
|
-
@
|
15
|
+
@cache_clear_lasttime = Time.now
|
16
|
+
@cache_clear_interval = @interval * 2
|
16
17
|
@interval = -1 if @interval.zero?
|
17
|
-
@old_cache_clear_interval = 300
|
18
|
-
@old_cache_clear_time = Time.now
|
19
18
|
end
|
20
19
|
|
21
20
|
def start
|
@@ -46,9 +45,9 @@ module Fluent::Plugin
|
|
46
45
|
record.dup : record.select { |k, v| @keep_keys.include?(k) }
|
47
46
|
end
|
48
47
|
|
49
|
-
if Time.now > @
|
50
|
-
|
51
|
-
@
|
48
|
+
if Time.now > @cache_clear_lasttime + @cache_clear_interval
|
49
|
+
clear_cache
|
50
|
+
@cache_clear_lasttime = Time.now
|
52
51
|
end
|
53
52
|
|
54
53
|
new_record ||= nil
|
@@ -67,9 +66,9 @@ module Fluent::Plugin
|
|
67
66
|
end
|
68
67
|
end
|
69
68
|
|
70
|
-
def
|
69
|
+
def clear_cache
|
71
70
|
@cache.each_key do |key|
|
72
|
-
expired = Time.now > @cache[key][:time]
|
71
|
+
expired = Time.now > @cache[key][:time]
|
73
72
|
@cache.delete(key) if expired
|
74
73
|
end
|
75
74
|
end
|
@@ -10,7 +10,7 @@ class TimeSamplingFilterTest < Test::Unit::TestCase
|
|
10
10
|
keep_keys sample_key2
|
11
11
|
}
|
12
12
|
|
13
|
-
def create_driver(conf = CONFIG
|
13
|
+
def create_driver(conf = CONFIG)
|
14
14
|
Fluent::Test::Driver::Filter.new(Fluent::Plugin::TimeSamplingFilter).configure(conf)
|
15
15
|
end
|
16
16
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-time-sampling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuki Kuwabara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
description:
|
55
|
+
description: Fluentd filter plugin to sampling from tag and keys at time interval
|
56
56
|
email:
|
57
57
|
- eramuk@gmail.com
|
58
58
|
executables: []
|
@@ -90,7 +90,7 @@ rubyforge_project:
|
|
90
90
|
rubygems_version: 2.6.14
|
91
91
|
signing_key:
|
92
92
|
specification_version: 4
|
93
|
-
summary:
|
93
|
+
summary: Fluentd filter plugin to sampling from tag and keys at time interval
|
94
94
|
test_files:
|
95
95
|
- test/helper.rb
|
96
96
|
- test/plugin/test_filter_time_sampling.rb
|