fluent-plugin-querycombiner 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/fluent-plugin-querycombiner.gemspec +1 -1
- data/lib/fluent/plugin/out_query_combiner.rb +9 -1
- data/test/plugin/test_out_query_combiner.rb +54 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7abce3623ce7f91ee8b41140d8a44a2e0d86621
|
4
|
+
data.tar.gz: 4ff7b64144bab38c734abcc8c9562419f21730fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 174b614a77bb2599908f609829474149b92b0cf9eef7fde24f85da6d4321e102dc9df476f5385d6c082592db98e8889f3965913d291d9c4af3b2afa39e2d7a19
|
7
|
+
data.tar.gz: 1ed7b35fdc71f39798fe51235c318ab9438d9e780f4dbb316ce448c93825f74f187aa02ff9bd8443f0528c86961dac6deb191148e3408def37b0a81deae6e2d5
|
data/README.md
CHANGED
@@ -235,8 +235,13 @@ The inactive expire time in seconds. By default it's **1800** (30 minutes).
|
|
235
235
|
### buffer_size
|
236
236
|
The max queries to store in redis. By default it's **1000**.
|
237
237
|
|
238
|
+
### continuous_dump
|
239
|
+
If you set this variable **true**, your pre-combined queries will not remove even after combined by `<dump>` block. Your pre-combined queries will remove only after their expire times set by `query_ttl`. Also your pre-combined queries will be prolonged if dumped.
|
240
|
+
|
241
|
+
By default it's **false**.
|
242
|
+
|
238
243
|
### remove_interval
|
239
|
-
The interval time to delete expired or overflowed queries which configured by `query_ttl` and `buffer_size`. By default it's 10 [sec].
|
244
|
+
The interval time to delete expired or overflowed queries which configured by `query_ttl` and `buffer_size`. By default it's `10` [sec].
|
240
245
|
|
241
246
|
### redis_key_prefix
|
242
247
|
|
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = "fluent-plugin-querycombiner"
|
6
|
-
spec.version = "0.0.
|
6
|
+
spec.version = "0.0.3"
|
7
7
|
spec.authors = ["Takahiro Kamatani"]
|
8
8
|
spec.email = ["buhii314@gmail.com"]
|
9
9
|
spec.description = %q{Fluent plugin to combine multiple queries.}
|
@@ -13,6 +13,7 @@ module Fluent
|
|
13
13
|
config_param :query_identify, :string, :default => 'session-id'
|
14
14
|
config_param :query_ttl, :integer, :default => 1800
|
15
15
|
config_param :buffer_size, :integer, :default => 1000
|
16
|
+
config_param :continuous_dump, :bool, :default => false
|
16
17
|
|
17
18
|
config_param :time_format, :string, :default => '$time'
|
18
19
|
|
@@ -229,7 +230,14 @@ module Fluent
|
|
229
230
|
Fluent::Engine.emit @tag, Fluent::Engine.now, combined_record
|
230
231
|
|
231
232
|
# remove qid
|
232
|
-
|
233
|
+
if not @continuous_dump
|
234
|
+
do_release(qid)
|
235
|
+
else
|
236
|
+
# continuous_dump will prolong qid's TTL.
|
237
|
+
tryOnRedis 'zadd', @redis_key_prefix, time, qid
|
238
|
+
tryOnRedis 'expire', @redis_key_prefix + qid, @query_ttl
|
239
|
+
end
|
240
|
+
|
233
241
|
end
|
234
242
|
end
|
235
243
|
|
@@ -31,6 +31,19 @@ class QueryCombinerOutputTest < Test::Unit::TestCase
|
|
31
31
|
@redis.quit
|
32
32
|
end
|
33
33
|
|
34
|
+
def tryOnRedis(method, *args)
|
35
|
+
tries = 0
|
36
|
+
begin
|
37
|
+
@redis.send(method, *args) if @redis.respond_to? method
|
38
|
+
rescue Redis::CommandError => e
|
39
|
+
tries += 1
|
40
|
+
# retry 3 times
|
41
|
+
retry if tries <= @redis_retry
|
42
|
+
$log.warn %Q[redis command retry failed : #{method}(#{args.join(', ')})]
|
43
|
+
raise e.message
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
34
47
|
def create_driver(conf, tag='test')
|
35
48
|
Fluent::Test::BufferedOutputTestDriver.new(Fluent::QueryCombinerOutput, tag).configure(conf)
|
36
49
|
end
|
@@ -410,12 +423,52 @@ class QueryCombinerOutputTest < Test::Unit::TestCase
|
|
410
423
|
|
411
424
|
end
|
412
425
|
|
426
|
+
def test_query_ttl
|
427
|
+
|
428
|
+
end
|
429
|
+
|
413
430
|
def test_buffer_size
|
414
431
|
|
415
432
|
end
|
416
433
|
|
417
|
-
def
|
434
|
+
def test_continuous_dump
|
435
|
+
d = create_driver %[
|
436
|
+
redis_key_prefix test_query_combiner:
|
437
|
+
|
438
|
+
query_identify event_id
|
439
|
+
query_ttl 5 # time to live[sec]
|
440
|
+
buffer_size 1000 # queries
|
441
|
+
continuous_dump true
|
442
|
+
remove_interval 5
|
443
|
+
|
444
|
+
<catch>
|
445
|
+
condition status == 'event-start'
|
446
|
+
</catch>
|
447
|
+
|
448
|
+
<dump>
|
449
|
+
condition status == 'event-finish'
|
450
|
+
</dump>
|
451
|
+
|
452
|
+
<release>
|
453
|
+
condition status == 'event-error'
|
454
|
+
</release>
|
455
|
+
]
|
456
|
+
assert_equal false, (tryOnRedis 'exists', "test_query_combiner:id000")
|
457
|
+
|
458
|
+
d.emit({"event_id"=>"id000", "status"=>"event-start", "key_init"=>"init"}, Time.now.to_f)
|
459
|
+
d.emit({"event_id"=>"id000", "status"=>"event-finish"}, Time.now.to_f)
|
460
|
+
d.emit({"event_id"=>"id000", "status"=>"event-finish", "key_fin1"=>"fin1"}, Time.now.to_f)
|
461
|
+
d.emit({"event_id"=>"id000", "status"=>"event-finish", "key_fin2"=>"fin2"}, Time.now.to_f)
|
462
|
+
d.run
|
463
|
+
|
464
|
+
assert_equal d.emits.length, 3
|
465
|
+
assert_equal d.emits[0][2], {"event_id"=>"id000", "status"=>"event-finish", "key_init"=>"init"}
|
466
|
+
assert_equal d.emits[1][2], {"event_id"=>"id000", "status"=>"event-finish", "key_init"=>"init", "key_fin1"=>"fin1"}
|
467
|
+
assert_equal d.emits[2][2], {"event_id"=>"id000", "status"=>"event-finish", "key_init"=>"init", "key_fin2"=>"fin2"}
|
418
468
|
|
469
|
+
assert_equal true, (tryOnRedis 'exists', "test_query_combiner:id000")
|
470
|
+
sleep 6
|
471
|
+
assert_equal false, (tryOnRedis 'exists', "test_query_combiner:id000")
|
419
472
|
end
|
420
473
|
|
421
474
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-querycombiner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takahiro Kamatani
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|