fluent-plugin-time-sampling 0.1.1 → 0.1.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: 145704aa65c1245200718d754dbea24378f8dfe4
4
- data.tar.gz: a7996a3de0b496bcd2478f97d43294ec36ae586d
3
+ metadata.gz: 0e27fd7c88ad8400f4aecf81704ca0135b077fa8
4
+ data.tar.gz: 1d1abcdce48e0c6502654a2be6518f64377e6946
5
5
  SHA512:
6
- metadata.gz: 572092b8d47eb567810d86638921e9cf4455e4d7edc0c5e29e320c5fc923686a72409bdae3365be764e310be08ed7c949c92605200af2ce29815e72a9f7488c1
7
- data.tar.gz: b8550d42301a3ed1ee563892a17c75d92132499bd7bd2a0b49761cd2048444dc65f0e1a8f62372e2499801c9e7b66bff72d7bcf9b6fbe62c18ed6eeaefc5b4ef
6
+ metadata.gz: 8ad3bc857f5bc464d055a4d17d23107f1061ef95802ccbcc00eb7590aaf16bcf77cc11ca1dee13b41ba6611e7315e205322ba7dc370cbadea337ae2793a81ef4
7
+ data.tar.gz: f26d6a494bfa861b1bb95683b6e36ebd2ce2526edfc4d563f7a37808838ee51f34f4b6d2fd30792d7455c0623d87edf5ad9c52b71efc8fddcb68423812fa8d9e
data/README.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # fluent-plugin-time-sampling
2
2
 
3
+ ## Requirements
4
+
5
+ | fluent-plugin-time-sampling | fluentd |
6
+ |-----------------------------|------------|
7
+ | >= 1.0.0 | >= v0.14.0 |
8
+ | < 1.0.0 | < v0.14.0 |
9
+
3
10
  ## Installation
4
11
  ```
5
12
  gem install fluent-plugin-time-sampling
@@ -18,15 +25,17 @@ Example:
18
25
 
19
26
  Assume following input in 10 seconds:
20
27
  ```
21
- sample.tag { "hostname": "host1", "sample_key1": "foo", "sample_key2": "aaa" }
22
- sample.tag { "hostname": "host1", "sample_key1": "foo", "sample_key2": "bbb" }
23
- sample.tag { "hostname": "host2", "sample_key1": "bar", "sample_key2": "ccc" }
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" }
24
32
  ```
25
33
 
26
34
  then output is below:
27
35
  ```
28
- sample.tag { "hostname": "host1", "sample_key2": "aaa" }
29
- sample.tag { "hostname": "host2", "sample_key2": "ccc" }
36
+ test.tag { "hostname": "host1", "sample_key2": "aaa" }
37
+ test.tag { "hostname": "host2", "sample_key2": "ccc" }
38
+ test.tag { "hostname": "host2", "sample_key2": "ddd" }
30
39
  ```
31
40
 
32
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 = "0.1.1"
7
+ gem.version = "0.1.2"
8
8
  gem.authors = ["Yuki Kuwabara"]
9
9
  gem.email = ["eramuk@gmail.com"]
10
- gem.summary = "filtering record at prescribed intervals"
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"]
@@ -15,10 +15,9 @@ module Fluent
15
15
  def configure(conf)
16
16
  super
17
17
  @cache = {}
18
- @cache_period = @interval * 2
18
+ @cache_clear_lasttime = Time.now
19
+ @cache_clear_interval = @interval * 2
19
20
  @interval = -1 if @interval.zero?
20
- @unused_cache_clear_interval = 300
21
- @unused_cache_clear_time = Time.now
22
21
  end
23
22
 
24
23
  def start
@@ -49,9 +48,9 @@ module Fluent
49
48
  record.dup : record.select { |k, v| @keep_keys.include?(k) }
50
49
  end
51
50
 
52
- if Time.now > @unused_cache_clear_time + @unused_cache_clear_interval
53
- clear_unused_cache
54
- @unused_cache_clear_time = Time.now
51
+ if Time.now > @cache_clear_lasttime + @cache_clear_interval
52
+ clear_cache
53
+ @cache_clear_lasttime = Time.now
55
54
  end
56
55
 
57
56
  new_record ||= nil
@@ -70,9 +69,9 @@ module Fluent
70
69
  end
71
70
  end
72
71
 
73
- def clear_unused_cache
72
+ def clear_cache
74
73
  @cache.each_key do |key|
75
- expired = Time.now > @cache[key][:time] + @cache_period
74
+ expired = Time.now > @cache[key][:time]
76
75
  @cache.delete(key) if expired
77
76
  end
78
77
  end
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: 0.1.1
4
+ version: 0.1.2
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-08-21 00:00:00.000000000 Z
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: filtering record at prescribed intervals
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: []
@@ -87,10 +87,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  version: '0'
88
88
  requirements: []
89
89
  rubyforge_project:
90
- rubygems_version: 2.6.14
90
+ rubygems_version: 2.2.5
91
91
  signing_key:
92
92
  specification_version: 4
93
- summary: filtering record at prescribed intervals
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