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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ebe8e81e18307cb99946d1440e937b23426a7fa3
4
- data.tar.gz: f8ea8e769f2b91ee8d8f738f19698c88d4f5803c
3
+ metadata.gz: 86baf51deb386cc4708139e311f0564a70d6232c
4
+ data.tar.gz: 83c96af6a0b6f4b3bf27742a3e7659dfa499c43d
5
5
  SHA512:
6
- metadata.gz: ef1fdac5be54fce8d388345123e65639801901898f47561b0026d2f6f1a514280bac5073601b5819c918e04dee0ccd01db4a0536c2ee87ca58334125774640b4
7
- data.tar.gz: d73a48b3091533eae618bde06f3cb9166e781854c9e06853953daeddcca64d5fb58966bba09f74c7919de84790ba83adbfb4377bdf83940c9f8f47e18f924d08
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
- #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
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
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 "simplecov", ">= 0.5.4"
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
- time = time / @aggregate_interval * @aggregate_interval
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
- case update_mode
268
- when UpdateMode::ADD
269
- updater = AddUpdater
270
- when UpdateMode::MAX
271
- updater = MaxUpdater
272
- when UpdateMode::AVERAGE # AVERAGE uses MaxUpdater and calculate average on server-side aggregation
273
- updater = AverageUpdater
274
- when UpdateMode::COUNT
275
- updater = CountUpdater
276
- else # default is AddUpdater
277
- updater = AddUpdater
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.1
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: 2016-09-06 00:00:00.000000000 Z
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.5.4
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.5.4
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.5.1
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