fluent-plugin-throttle 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +13 -15
- data/README.md +1 -1
- data/fluent-plugin-throttle.gemspec +1 -1
- data/lib/fluent/plugin/filter_throttle.rb +14 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42672474afdd0860dfd06b5dfa7547c1e3b6365f1a995bd288b5928d54afdcaa
|
4
|
+
data.tar.gz: 78cb604160da44a19eee7473e56590af7d7076042b143bc3138b8198b35c8f97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fe4f1c8d5c250ab8e4945086460227040ed87357ad8565ba484710a405d7f1a14461c1db2bd16f921945916e69e035c2d92c01b5fe91e57eacb9644a4d05349
|
7
|
+
data.tar.gz: 10d3b4572029fc79cbfb09cf223e82d2af69f3c1239165a6690d97a1ee512a27f27b05e945db195ca4c8f924b2e0aa2688f4e670364145f789f9f8aeefebf3dc
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fluent-plugin-throttle (0.0.
|
4
|
+
fluent-plugin-throttle (0.0.5)
|
5
5
|
fluentd (~> 1.1)
|
6
6
|
|
7
7
|
GEM
|
@@ -15,19 +15,18 @@ GEM
|
|
15
15
|
thor (>= 0.14.0)
|
16
16
|
byebug (10.0.2)
|
17
17
|
coderay (1.1.2)
|
18
|
-
|
18
|
+
concurrent-ruby (1.1.6)
|
19
|
+
cool.io (1.6.0)
|
19
20
|
crack (0.4.3)
|
20
21
|
safe_yaml (~> 1.0.0)
|
21
|
-
|
22
|
-
fluentd (1.2.3)
|
22
|
+
fluentd (1.11.1)
|
23
23
|
cool.io (>= 1.4.5, < 2.0.0)
|
24
|
-
dig_rb (~> 1.0.0)
|
25
24
|
http_parser.rb (>= 0.5.1, < 0.7.0)
|
26
|
-
msgpack (>=
|
25
|
+
msgpack (>= 1.3.1, < 2.0.0)
|
27
26
|
serverengine (>= 2.0.4, < 3.0.0)
|
28
27
|
sigdump (~> 0.2.2)
|
29
28
|
strptime (>= 0.2.2, < 1.0.0)
|
30
|
-
tzinfo (
|
29
|
+
tzinfo (>= 1.0, < 3.0)
|
31
30
|
tzinfo-data (~> 1.0)
|
32
31
|
yajl-ruby (~> 1.0)
|
33
32
|
hashdiff (0.3.7)
|
@@ -39,7 +38,7 @@ GEM
|
|
39
38
|
minitest (5.11.3)
|
40
39
|
mocha (1.6.0)
|
41
40
|
metaclass (~> 0.0.1)
|
42
|
-
msgpack (1.
|
41
|
+
msgpack (1.3.3)
|
43
42
|
power_assert (1.1.3)
|
44
43
|
pry (0.11.3)
|
45
44
|
coderay (~> 1.1.0)
|
@@ -50,18 +49,17 @@ GEM
|
|
50
49
|
public_suffix (3.0.2)
|
51
50
|
rake (12.3.1)
|
52
51
|
safe_yaml (1.0.4)
|
53
|
-
serverengine (2.
|
52
|
+
serverengine (2.2.1)
|
54
53
|
sigdump (~> 0.2.2)
|
55
54
|
sigdump (0.2.4)
|
56
55
|
single_cov (1.1.0)
|
57
|
-
strptime (0.2.
|
56
|
+
strptime (0.2.4)
|
58
57
|
test-unit (3.2.8)
|
59
58
|
power_assert
|
60
59
|
thor (0.20.0)
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
tzinfo-data (1.2018.5)
|
60
|
+
tzinfo (2.0.2)
|
61
|
+
concurrent-ruby (~> 1.0)
|
62
|
+
tzinfo-data (1.2020.1)
|
65
63
|
tzinfo (>= 1.0.0)
|
66
64
|
webmock (3.4.2)
|
67
65
|
addressable (>= 2.3.6)
|
@@ -86,4 +84,4 @@ DEPENDENCIES
|
|
86
84
|
webmock (~> 3.3)
|
87
85
|
|
88
86
|
BUNDLED WITH
|
89
|
-
1.
|
87
|
+
1.17.2
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/rubrikinc/fluent-plugin-throttle/blob/master/LICENSE)
|
4
4
|
|
5
|
-
A sentry
|
5
|
+
A sentry plugin to throttle logs. Logs are grouped by a configurable key. When
|
6
6
|
a group exceeds a configuration rate, logs are dropped for this group.
|
7
7
|
|
8
8
|
## Installation
|
@@ -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-throttle"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.5"
|
8
8
|
spec.authors = ["François-Xavier Bourlet"]
|
9
9
|
spec.email = ["fx.bourlet@rubrik.com"]
|
10
10
|
spec.summary = %q{Fluentd filter for throttling logs based on a configurable key.}
|
@@ -51,6 +51,8 @@ module Fluent::Plugin
|
|
51
51
|
raise "group_bucket_period_s must be > 0" \
|
52
52
|
unless @group_bucket_period_s > 0
|
53
53
|
|
54
|
+
@group_gc_timeout_s = 2 * @group_bucket_period_s
|
55
|
+
|
54
56
|
raise "group_bucket_limit must be > 0" \
|
55
57
|
unless @group_bucket_limit > 0
|
56
58
|
|
@@ -83,17 +85,26 @@ module Fluent::Plugin
|
|
83
85
|
now = Time.now
|
84
86
|
rate_limit_exceeded = @group_drop_logs ? nil : record # return nil on rate_limit_exceeded to drop the record
|
85
87
|
group = extract_group(record)
|
86
|
-
|
87
|
-
|
88
|
+
|
89
|
+
# Ruby hashes are ordered by insertion.
|
90
|
+
# Deleting and inserting moves the item to the end of the hash (most recently used)
|
91
|
+
counter = @counters[group] = @counters.delete(group) || Group.new(0, now, 0, 0, now, nil)
|
88
92
|
|
93
|
+
counter.rate_count += 1
|
89
94
|
since_last_rate_reset = now - counter.rate_last_reset
|
90
95
|
if since_last_rate_reset >= 1
|
91
|
-
# compute and store rate/s at most every
|
96
|
+
# compute and store rate/s at most every second
|
92
97
|
counter.aprox_rate = (counter.rate_count / since_last_rate_reset).round()
|
93
98
|
counter.rate_count = 0
|
94
99
|
counter.rate_last_reset = now
|
95
100
|
end
|
96
101
|
|
102
|
+
# try to evict the least recently used group
|
103
|
+
lru_group, lru_counter = @counters.first
|
104
|
+
if !lru_group.nil? && now - lru_counter.rate_last_reset > @group_gc_timeout_s
|
105
|
+
@counters.delete(lru_group)
|
106
|
+
end
|
107
|
+
|
97
108
|
if (now.to_i / @group_bucket_period_s) \
|
98
109
|
> (counter.bucket_last_reset.to_i / @group_bucket_period_s)
|
99
110
|
# next time period reached.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-throttle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- François-Xavier Bourlet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|