fluent-plugin-mackerel 0.0.8 → 0.0.9

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTNiZDMwMGM1MGFhOTdiZGE2NjNkNDJmNjAxMDg1MmIyZDllMTc4Yw==
4
+ YjIwZThjMzJiNmNjNjE1ZGU1MWM3YWQwYzJmZjVkYmMzY2Y5MzdkNw==
5
5
  data.tar.gz: !binary |-
6
- Y2Y3MmIwYmIwNzFjMDZhZDhjMTdlZjcyMDBmODI3ZDcyMDQxNDIzYw==
6
+ MjgxN2FjOGIwZWZjMmRjMWNkZDQ0MzJkMzc0N2U3ZGZhZjI3OTAzNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDFhODQ4ZjI5NGFiYTQ0YzZmZWM4YTI0NTkyYTYyZjRhZDkwMmI5NTZiNzYx
10
- ZDVlMDkwODNiMjViMTI2N2UxYzE4NDVhMmJhMzFmZmRhNmMwYTRmYzVlMzRj
11
- YjFkNDZjYmM4MGIxOWVhY2MyMTg2MmVhNmUzNzM0ZjE3YzliZTU=
9
+ ODAzNWZiYjc4MzU4ODM2NDJhZWY5M2M5MGU3MDU5Yzc3NGNiNmYyMzcyYzNj
10
+ N2FjZmY3NWYwZGIwZTMyYmQ4OTg1NGFmYWU2YzE1NzAxODYzMTJjNDI4MzM4
11
+ ZDlkNzBkNjc3NGZlYWIyZDVkMzQyZjIwMTk3N2U2NDQyZjlmYzI=
12
12
  data.tar.gz: !binary |-
13
- NDNkOTdiYTFmZmMyZTYzMWU0OTc4Zjk2Y2FiNGMyZjEzMTdhOTRkZTg4MjE1
14
- OWI1OWRkY2Q4ZWM4NGIyNjI3OWE4NjVmYWFjYmYzODA0NWIxMGQ3MGM3M2Q0
15
- Nzg3ZGMzYjIzODI2NTQzODdlZjk4MmViZmFjMTAyNTc0ODlkODE=
13
+ NjA1NzE2MmVlY2YyZmFmYzU4NmJhMGJkZTNiYjE3MjU2NDk3ZmJiZDBlOGI4
14
+ MmQzMDg3ZTBiOGRjNjI1ZDljMzY2YjFjZWFlNDAxNDVlNWVhOTdmMTNjODZj
15
+ NTU5YWI2YThlZTg2YTExZjVkNDY2ZWY1YTU2YzZhNDc0MGIwMzU=
data/README.md CHANGED
@@ -90,6 +90,13 @@ You can also send ["service" metric](http://help-ja.mackerel.io/entry/spec/api/v
90
90
  ```
91
91
  `flush_interval` is not allowed to be set less than 60 secs not to send API requests more than once in a minute.
92
92
 
93
+ This plugin overwrites the default value of `buffer_queue_limit` and `buffer_chunk_limit` as follows.
94
+
95
+ * buffer_queue_limit to 4096
96
+ * buffer_chunk_limit to 100K
97
+
98
+ Without any special reasons to change, you should leave them as they are.
99
+
93
100
  Since version 0.0.4, metrics_prefix was removed and you should use metrics_name instead.
94
101
 
95
102
  ### MackerelHostidTagOutput
@@ -158,7 +165,7 @@ For debugging purpose, you can change Mackerel endpoint by `origin` parameter li
158
165
 
159
166
  ## References
160
167
 
161
- * [Send service and host metric to Mackerel by using fluentd (Japanese, Official Document)](http://help-ja.mackerel.io/entry/advanced/fluentd)
168
+ * [Posting Service Metrics with fluentd](http://help.mackerel.io/entry/advanced/fluentd)
162
169
  * [How to use fluent-plugin-mackerel (Japanese)](http://qiita.com/tksmd/items/1212331a5a18afe520df)
163
170
 
164
171
  ## Copyright
@@ -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-mackerel"
7
- spec.version = "0.0.8"
7
+ spec.version = "0.0.9"
8
8
  spec.authors = ["tksmd","hatz48"]
9
9
  spec.email = ["someda@isenshi.com"]
10
10
  spec.description = %q{fluent plugin to send metrics to mackerel.io}
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler", "~> 1.3"
23
23
  spec.add_development_dependency "rake"
24
24
  spec.add_development_dependency "rr", ">= 1.0.0"
25
+ spec.add_development_dependency "test-unit"
25
26
  spec.add_runtime_dependency "fluentd"
26
27
 
27
28
  spec.required_ruby_version = '>= 1.9.3'
@@ -13,6 +13,10 @@ module Fluent
13
13
  config_param :out_key_pattern, :string, :default => nil
14
14
  config_param :origin, :string, :default => nil
15
15
 
16
+ MAX_BUFFER_CHUNK_LIMIT = 100 * 1024
17
+ config_set_default :buffer_chunk_limit, MAX_BUFFER_CHUNK_LIMIT
18
+ config_set_default :buffer_queue_limit, 4096
19
+
16
20
  attr_reader :mackerel
17
21
 
18
22
  # Define `log` method for v0.10.42 or earlier
@@ -118,23 +122,23 @@ module Fluent
118
122
  end
119
123
  end
120
124
 
125
+ send(metrics) unless metrics.empty?
126
+ metrics.clear
127
+ end
128
+
129
+ def send(metrics)
121
130
  begin
122
- while true
123
- partial = metrics.slice!(0, 100)
124
- if partial.empty?
125
- break
126
- end
127
- if @hostid
128
- @mackerel.post_metrics(partial)
129
- else
130
- @mackerel.post_service_metrics(@service, partial)
131
- end
131
+ if @hostid
132
+ @mackerel.post_metrics(metrics)
133
+ else
134
+ @mackerel.post_service_metrics(@service, metrics)
132
135
  end
133
136
  rescue => e
134
137
  log.error("out_mackerel:", :error_class => e.class, :error => e.message)
138
+ raise e
135
139
  end
136
- metrics.clear
137
140
  end
141
+
138
142
  end
139
143
 
140
144
  end
@@ -69,6 +69,21 @@ class MackerelOutputTest < Test::Unit::TestCase
69
69
  out_keys val1,val2
70
70
  ]
71
71
 
72
+ CONFIG_BUFFER_LIMIT_DEFAULT = %[
73
+ type mackerel
74
+ service xyz
75
+ api_key 123456
76
+ out_keys val1,val2,val3
77
+ ]
78
+
79
+ CONFIG_BUFFER_LIMIT_IGNORE = %[
80
+ type mackerel
81
+ service xyz
82
+ api_key 123456
83
+ out_keys val1,val2,val3
84
+ buffer_chunk_limit 1k
85
+ ]
86
+
72
87
  def create_driver(conf = CONFIG, tag='test')
73
88
  Fluent::Test::BufferedOutputTestDriver.new(Fluent::MackerelOutput, tag).configure(conf)
74
89
  end
@@ -107,6 +122,13 @@ class MackerelOutputTest < Test::Unit::TestCase
107
122
  d = create_driver(CONFIG_OUT_KEY_PATTERN)
108
123
  assert_match d.instance.instance_variable_get(:@out_key_pattern), "val1"
109
124
  assert_no_match d.instance.instance_variable_get(:@out_key_pattern), "foo"
125
+
126
+ d = create_driver(CONFIG_BUFFER_LIMIT_DEFAULT)
127
+ assert_equal d.instance.instance_variable_get(:@buffer_chunk_limit), Fluent::MackerelOutput::MAX_BUFFER_CHUNK_LIMIT
128
+ assert_equal d.instance.instance_variable_get(:@buffer_queue_limit), 4096
129
+
130
+ d = create_driver(CONFIG_BUFFER_LIMIT_IGNORE)
131
+ assert_equal d.instance.instance_variable_get(:@buffer_chunk_limit), Fluent::MackerelOutput::MAX_BUFFER_CHUNK_LIMIT
110
132
  end
111
133
 
112
134
  def test_write
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-mackerel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - tksmd
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-29 00:00:00.000000000 Z
12
+ date: 2015-01-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mackerel-client
@@ -67,6 +67,20 @@ dependencies:
67
67
  - - ! '>='
68
68
  - !ruby/object:Gem::Version
69
69
  version: 1.0.0
70
+ - !ruby/object:Gem::Dependency
71
+ name: test-unit
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
70
84
  - !ruby/object:Gem::Dependency
71
85
  name: fluentd
72
86
  requirement: !ruby/object:Gem::Requirement