fluent-plugin-elasticsearch 2.11.7 → 2.11.8

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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a8adf956e53ac370bbabdb66572a3a61cfe3d27220532ff773ee7cffe53c600
4
- data.tar.gz: 57d22aa95d06ca181f0f55a7c2f0be4b19f5050bb01e4cb9bf2df17c7a2c710e
3
+ metadata.gz: 7a1df6327a4af9049ed3fb5bbb10a153a79a183d1309996f00abcc20d8410108
4
+ data.tar.gz: 8129c3a35a66eca22611fdaaebe36bb9f4122ff06f3b51e1ae29675125894c88
5
5
  SHA512:
6
- metadata.gz: 596ba2952540acad16e8c49b60992382c0947c0d834375016560cd29b3d2ae7f29d18fd98006e2bda3dc3c9038d45dcf565084af6161c9abbbdb1d19f7e9ec48
7
- data.tar.gz: 903f77f656774e464e0f230f7d18669374965d1a8391307f91a3470df92213a0c545211c9da4ea18a5c40e08d3af04d756c9582e4d36ee5ac61e4e5053ba70ce
6
+ metadata.gz: 1e1c2f01409ca7f181e75c88c6b1f32d289259504a5cda50e3d99429e952b8364c2957e10aa77e2dc8f8b3c2cf7d832efe5bc88493e6537a1160b39ba1c2d833
7
+ data.tar.gz: baf563a878fa159061e8232a5b9916b205aa6b9d00b2a5f67d0eb1c306decab30fd7a302e8da5478eb3200c62cf4de52ccf888b7fdda75d5c3bb688a1160de93
data/History.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  ### [Unreleased]
4
4
 
5
+ ### 2.11.8
6
+ - Serialize requests with Oj (#464)
7
+
5
8
  ### 2.11.7
6
9
  - Add mechanism to detect ES and its client version mismatch (#463)
7
10
 
data/README.md CHANGED
@@ -59,6 +59,7 @@ Current maintainers: @cosmo0920
59
59
  + [content_type](#content_type)
60
60
  + [include_index_in_url](#include_index_in_url)
61
61
  + [http_backend](#http_backend)
62
+ + [prefer_oj_serializer](#prefer_oj_serializer)
62
63
  + [Client/host certificate options](#clienthost-certificate-options)
63
64
  + [Proxy Support](#proxy-support)
64
65
  + [Buffer options](#buffer-options)
@@ -661,6 +662,18 @@ Default value is `excon` which is default http_backend of elasticsearch plugin.
661
662
  http_backend typhoeus
662
663
  ```
663
664
 
665
+ ### prefer_oj_serializer
666
+
667
+ With default beavior, Elasticsearch client uses `Yajl` as JSON encoder/decoder.
668
+ `Oj` is the alternative high performance JSON encoder/decoder.
669
+ When this parameter sets as `true`, Elasticsearch client uses `Oj` as JSON encoder/decoder.
670
+
671
+ Default value is `false`.
672
+
673
+ ```
674
+ prefer_oj_serializer true
675
+ ```
676
+
664
677
  ### Client/host certificate options
665
678
 
666
679
  Need to verify Elasticsearch's certificate? You can use the following parameter to specify a CA instead of using an environment variable.
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'fluent-plugin-elasticsearch'
6
- s.version = '2.11.7'
6
+ s.version = '2.11.8'
7
7
  s.authors = ['diogo', 'pitr']
8
8
  s.email = ['pitr.vern@gmail.com', 'me@diogoterror.com']
9
9
  s.description = %q{Elasticsearch output plugin for Fluent event collector}
@@ -0,0 +1,22 @@
1
+ require 'oj'
2
+
3
+ module Fluent::Plugin
4
+ module Serializer
5
+
6
+ class Oj
7
+ include Elasticsearch::Transport::Transport::Serializer::Base
8
+
9
+ # De-serialize a Hash from JSON string
10
+ #
11
+ def load(string, options={})
12
+ ::Oj.load(string, options)
13
+ end
14
+
15
+ # Serialize a Hash to JSON string
16
+ #
17
+ def dump(object, options={})
18
+ ::Oj.dump(object, options)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -15,6 +15,10 @@ require 'fluent/error'
15
15
  require_relative 'elasticsearch_constants'
16
16
  require_relative 'elasticsearch_error_handler'
17
17
  require_relative 'elasticsearch_index_template'
18
+ begin
19
+ require_relative 'oj_serializer'
20
+ rescue LoadError
21
+ end
18
22
 
19
23
  module Fluent::Plugin
20
24
  class ElasticsearchOutput < Output
@@ -114,6 +118,7 @@ EOC
114
118
  config_param :include_index_in_url, :bool, :default => false
115
119
  config_param :http_backend, :enum, list: [:excon, :typhoeus], :default => :excon
116
120
  config_param :validate_client_version, :bool, :default => false
121
+ config_param :prefer_oj_serializer, :bool, :default => false
117
122
 
118
123
  config_section :buffer do
119
124
  config_set_default :@type, DEFAULT_BUFFER_TYPE
@@ -175,9 +180,14 @@ EOC
175
180
 
176
181
  @meta_config_map = create_meta_config_map
177
182
 
183
+ @serializer_class = nil
178
184
  begin
179
185
  require 'oj'
180
186
  @dump_proc = Oj.method(:dump)
187
+ if @prefer_oj_serializer
188
+ @serializer_class = Fluent::Plugin::Serializer::Oj
189
+ Elasticsearch::API.settings[:serializer] = Fluent::Plugin::Serializer::Oj
190
+ end
181
191
  rescue LoadError
182
192
  @dump_proc = Yajl.method(:dump)
183
193
  end
@@ -322,6 +332,7 @@ EOC
322
332
  password: @password
323
333
  },
324
334
  sniffer_class: @sniffer_class,
335
+ serializer_class: @serializer_class,
325
336
  }), &adapter_conf)
326
337
  es = Elasticsearch::Client.new transport: transport
327
338
 
@@ -212,6 +212,7 @@ class ElasticsearchOutput < Test::Unit::TestCase
212
212
  assert_equal :"application/json", instance.content_type
213
213
  assert_equal "fluentd", default_type_name
214
214
  assert_equal :excon, instance.http_backend
215
+ assert_false instance.prefer_oj_serializer
215
216
  end
216
217
 
217
218
  test 'configure Content-Type' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.7
4
+ version: 2.11.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - diogo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-09-01 00:00:00.000000000 Z
12
+ date: 2018-09-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
@@ -149,6 +149,7 @@ files:
149
149
  - lib/fluent/plugin/elasticsearch_index_template.rb
150
150
  - lib/fluent/plugin/elasticsearch_simple_sniffer.rb
151
151
  - lib/fluent/plugin/filter_elasticsearch_genid.rb
152
+ - lib/fluent/plugin/oj_serializer.rb
152
153
  - lib/fluent/plugin/out_elasticsearch.rb
153
154
  - lib/fluent/plugin/out_elasticsearch_dynamic.rb
154
155
  - test/helper.rb