fluent-plugin-metricsense 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +7 -7
- data/VERSION +1 -1
- data/fluent-plugin-metricsense.gemspec +2 -1
- data/lib/fluent/plugin/out_metricsense.rb +26 -22
- data/test/plugin/test_out_metricsense.rb +56 -0
- metadata +22 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86baf51deb386cc4708139e311f0564a70d6232c
|
4
|
+
data.tar.gz: 83c96af6a0b6f4b3bf27742a3e7659dfa499c43d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24e59e73c77cb9a2a953edbafd7c4f5a56b25bef749a00e1ca8e152edf29d39f60ac2c7ad4d8cf22afffe27570fe70f496d6c47554214c58525c64bc47f72817
|
7
|
+
data.tar.gz: f899dea67543ffe32bee27f3e72b75585579100da78dfbece9bc5bc990ec59f33e7cb7d6b2f51a482f990b808d6da5ff2237d8dcae32a959fdd0ceec0157942a
|
data/Rakefile
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'bundler'
|
2
2
|
Bundler::GemHelper.install_tasks
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
require 'rake/testtask'
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |test|
|
7
|
+
test.libs << 'lib' << 'test'
|
8
|
+
test.test_files = FileList['test/plugin/*.rb']
|
9
|
+
test.verbose = true
|
10
|
+
end
|
11
11
|
|
12
12
|
#task :coverage do |t|
|
13
13
|
# ENV['SIMPLE_COV'] = '1'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.2
|
@@ -20,5 +20,6 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.add_dependency "dogapi"
|
21
21
|
s.add_development_dependency "rake", ">= 0.8.7"
|
22
22
|
s.add_development_dependency 'bundler', ['>= 1.0.0']
|
23
|
-
s.add_development_dependency "
|
23
|
+
s.add_development_dependency "test-unit", ">= 3.1.1"
|
24
|
+
s.add_development_dependency "simplecov", ">= 0.10.0"
|
24
25
|
end
|
@@ -262,30 +262,34 @@ module Fluent
|
|
262
262
|
|
263
263
|
# select sum(value) from chunk group by tag, time/60, seg_val, seg_key
|
264
264
|
chunk.msgpack_each {|tag,time,value,segments,update_mode|
|
265
|
-
|
265
|
+
begin
|
266
|
+
time = time / @aggregate_interval * @aggregate_interval
|
267
|
+
|
268
|
+
case update_mode
|
269
|
+
when UpdateMode::ADD
|
270
|
+
updater = AddUpdater
|
271
|
+
when UpdateMode::MAX
|
272
|
+
updater = MaxUpdater
|
273
|
+
when UpdateMode::AVERAGE # AVERAGE uses MaxUpdater and calculate average on server-side aggregation
|
274
|
+
updater = AverageUpdater
|
275
|
+
when UpdateMode::COUNT
|
276
|
+
updater = CountUpdater
|
277
|
+
else # default is AddUpdater
|
278
|
+
updater = AddUpdater
|
279
|
+
end
|
266
280
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
281
|
+
# simple values
|
282
|
+
ak = AggregationKey.new(tag, time, nil, nil)
|
283
|
+
(simple_counters[ak] ||= updater.new).add(value)
|
284
|
+
|
285
|
+
# segmented values
|
286
|
+
segments.each_pair {|seg_key,seg_val|
|
287
|
+
ak = AggregationKey.new(tag, time, seg_val, seg_key)
|
288
|
+
(segmented_counters[ak] ||= updater.new).add(value)
|
289
|
+
}
|
290
|
+
rescue StandardError => e
|
291
|
+
log.warn("ignoring broken chunk: #{e.inspect} - " + [tag, time, value, segments, update_mode].inspect)
|
278
292
|
end
|
279
|
-
|
280
|
-
# simple values
|
281
|
-
ak = AggregationKey.new(tag, time, nil, nil)
|
282
|
-
(simple_counters[ak] ||= updater.new).add(value)
|
283
|
-
|
284
|
-
# segmented values
|
285
|
-
segments.each_pair {|seg_key,seg_val|
|
286
|
-
ak = AggregationKey.new(tag, time, seg_val, seg_key)
|
287
|
-
(segmented_counters[ak] ||= updater.new).add(value)
|
288
|
-
}
|
289
293
|
}
|
290
294
|
|
291
295
|
counters = segmented_counters
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'fluent/test'
|
2
|
+
require 'fluent/plugin/out_metricsense'
|
3
|
+
|
4
|
+
class MetricsenseOutputTest < Test::Unit::TestCase
|
5
|
+
class TestBackend < Fluent::MetricSenseOutput::Backend
|
6
|
+
Fluent::MetricSenseOutput.register_backend('test', self)
|
7
|
+
|
8
|
+
@@data = []
|
9
|
+
|
10
|
+
def self.data
|
11
|
+
@@data
|
12
|
+
end
|
13
|
+
|
14
|
+
def write(data)
|
15
|
+
@@data << data
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
CONFIG = %Q[
|
20
|
+
backend test
|
21
|
+
]
|
22
|
+
|
23
|
+
def setup
|
24
|
+
Fluent::Test.setup
|
25
|
+
end
|
26
|
+
|
27
|
+
def create_driver(conf)
|
28
|
+
Fluent::Test::BufferedOutputTestDriver.new(Fluent::MetricSenseOutput.new).configure(conf)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_emit
|
32
|
+
now = Time.now.to_i
|
33
|
+
d = create_driver(CONFIG)
|
34
|
+
data = {'value' => 1, 'user_id' => 23456, 'path' => '/auth/login'}
|
35
|
+
d.emit(data, now)
|
36
|
+
d.run
|
37
|
+
|
38
|
+
t = now / 60 * 60
|
39
|
+
TestBackend.data.each do |written|
|
40
|
+
assert_equal ['test', t, 1, 'user_id', 23456, 0], written.shift
|
41
|
+
assert_equal ['test', t, 1, 'path', "/auth/login", 0], written.shift
|
42
|
+
assert_equal ['test', t, 1, nil, nil, 0], written.shift
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# server restart can cause broken buffer and broken chunk.
|
47
|
+
# out_metricsense ignore the chunk with warning log
|
48
|
+
def test_skip_broken_chunk
|
49
|
+
d = create_driver(CONFIG)
|
50
|
+
data = {'value' => 1, 'user_id' => 23456, 'path' => '/auth/login'}
|
51
|
+
d.emit(data, data)
|
52
|
+
d.run
|
53
|
+
|
54
|
+
assert_equal [], TestBackend.data.first
|
55
|
+
end
|
56
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-metricsense
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -66,20 +66,34 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.0.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: test-unit
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.1.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.1.1
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: simplecov
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - ">="
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
89
|
+
version: 0.10.0
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
96
|
+
version: 0.10.0
|
83
97
|
description: MetricSense - application metrics aggregation plugin for Fluentd
|
84
98
|
email: sf@treasure-data.com
|
85
99
|
executables: []
|
@@ -98,6 +112,7 @@ files:
|
|
98
112
|
- lib/fluent/plugin/backends/rdb_tsdb_backend.rb
|
99
113
|
- lib/fluent/plugin/backends/stdout_backend.rb
|
100
114
|
- lib/fluent/plugin/out_metricsense.rb
|
115
|
+
- test/plugin/test_out_metricsense.rb
|
101
116
|
homepage: https://github.com/treasure-data/fluent-plugin-metricsense
|
102
117
|
licenses:
|
103
118
|
- Apache-2.0
|
@@ -118,8 +133,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
133
|
version: '0'
|
119
134
|
requirements: []
|
120
135
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.
|
136
|
+
rubygems_version: 2.6.8
|
122
137
|
signing_key:
|
123
138
|
specification_version: 4
|
124
139
|
summary: MetricSense - application metrics aggregation plugin for Fluentd
|
125
|
-
test_files:
|
140
|
+
test_files:
|
141
|
+
- test/plugin/test_out_metricsense.rb
|