fluent-plugin-datadog 0.13.0 → 0.14.0

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: c796cd3bf58664302c3522ede3ed1518c268a1a557cd00244ceef41dcb97b8a7
4
- data.tar.gz: 00c4cd64362d94ba967c9239f15cfa830f7e8533345f379433709630754ae2cf
3
+ metadata.gz: 8907f2de3502bd5d7e4ee138dba441f1d5d0197537b8a9b246d46038f12fa045
4
+ data.tar.gz: '09e4e69d440b126a68f54bc535c2c2bba8ab1b199e70e306fd0e08ae9fbc5a37'
5
5
  SHA512:
6
- metadata.gz: 58ba2c958571d7756c8cbc18c610a324195a2c0f96e1cc4c62c79dee8438e8f6f16df2f77c50169f84d541e6db39530e47ccd67d8c43b9f2e8c590b5d6c0c360
7
- data.tar.gz: a92d2e8972aa49c15609cefcc5b70c75cf8f6a674734935c4795b7d393d3e5e63c669ae3d2503714ad94860e15dd81851009d250e16ed56d9d3c901b44d8372b
6
+ metadata.gz: f895096ecb110d7d9a269e882f02c5ba844a4b6593163dcfd82f81f570eb4a3979ffa2f0fedf398f02d22445651005fe6cd9b98172fa91e1ef49b5f55d8c9d11
7
+ data.tar.gz: ac780383e151377090900d904dc855a161c2c6abaff43bf7ac7b27140fecb1ee461e0cd4bdbcdbc39c9cdf28d569eede8a30634094e7516f0b60d899246846a8
data/.gitignore CHANGED
@@ -40,5 +40,4 @@ foo/
40
40
  *.iml
41
41
  .idea/
42
42
 
43
- fluent/
44
43
  Gemfile.lock
@@ -7,16 +7,18 @@
7
7
  lib = File.expand_path('../lib', __FILE__)
8
8
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
9
9
 
10
+ require "fluent/plugin/version.rb"
11
+
10
12
  Gem::Specification.new do |spec|
11
13
  spec.name = "fluent-plugin-datadog"
12
- spec.version = "0.13.0"
14
+ spec.version = DatadogFluentPlugin::VERSION
13
15
  spec.authors = ["Datadog Solutions Team"]
14
16
  spec.email = ["support@datadoghq.com"]
15
17
  spec.summary = "Datadog output plugin for Fluent event collector"
16
18
  spec.homepage = "http://datadoghq.com"
17
19
  spec.license = "Apache-2.0"
18
20
 
19
- spec.files = [".gitignore", "Gemfile", "LICENSE", "README.md", "Rakefile", "fluent-plugin-datadog.gemspec", "lib/fluent/plugin/out_datadog.rb"]
21
+ spec.files = [".gitignore", "Gemfile", "LICENSE", "README.md", "Rakefile", "fluent-plugin-datadog.gemspec", "lib/fluent/plugin/version.rb", "lib/fluent/plugin/out_datadog.rb"]
20
22
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
23
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
24
  spec.require_paths = ["lib"]
@@ -28,5 +30,5 @@ Gem::Specification.new do |spec|
28
30
  spec.add_development_dependency "test-unit", '~> 3.1'
29
31
  spec.add_development_dependency "rake", "~> 12.0"
30
32
  spec.add_development_dependency "yajl-ruby", "~> 1.2"
31
- spec.add_development_dependency 'webmock', "~> 3.5.0"
33
+ spec.add_development_dependency 'webmock', "~> 3.6.0"
32
34
  end
@@ -9,6 +9,8 @@ require "yajl"
9
9
  require "zlib"
10
10
  require "fluent/plugin/output"
11
11
 
12
+ require_relative "version"
13
+
12
14
  class Fluent::DatadogOutput < Fluent::Plugin::Output
13
15
  class RetryableError < StandardError;
14
16
  end
@@ -50,6 +52,7 @@ class Fluent::DatadogOutput < Fluent::Plugin::Output
50
52
  config_param :compression_level, :integer, :default => 6
51
53
  config_param :no_ssl_validation, :bool, :default => false
52
54
  config_param :http_proxy, :string, :default => nil
55
+ config_param :force_v1_routes, :bool, :default => false
53
56
 
54
57
  # Format settings
55
58
  config_param :use_json, :bool, :default => true
@@ -89,7 +92,7 @@ class Fluent::DatadogOutput < Fluent::Plugin::Output
89
92
 
90
93
  def start
91
94
  super
92
- @client = new_client(log, @api_key, @use_http, @use_ssl, @no_ssl_validation, @host, @ssl_port, @port, @http_proxy, @use_compression)
95
+ @client = new_client(log, @api_key, @use_http, @use_ssl, @no_ssl_validation, @host, @ssl_port, @port, @http_proxy, @use_compression, @force_v1_routes)
93
96
  end
94
97
 
95
98
  def shutdown
@@ -261,9 +264,9 @@ class Fluent::DatadogOutput < Fluent::Plugin::Output
261
264
  end
262
265
 
263
266
  # Build a new transport client
264
- def new_client(logger, api_key, use_http, use_ssl, no_ssl_validation, host, ssl_port, port, http_proxy, use_compression)
267
+ def new_client(logger, api_key, use_http, use_ssl, no_ssl_validation, host, ssl_port, port, http_proxy, use_compression, force_v1_routes)
265
268
  if use_http
266
- DatadogHTTPClient.new logger, use_ssl, no_ssl_validation, host, ssl_port, port, http_proxy, use_compression, api_key
269
+ DatadogHTTPClient.new logger, use_ssl, no_ssl_validation, host, ssl_port, port, http_proxy, use_compression, api_key, force_v1_routes
267
270
  else
268
271
  DatadogTCPClient.new logger, use_ssl, no_ssl_validation, host, ssl_port, port
269
272
  end
@@ -301,20 +304,29 @@ class Fluent::DatadogOutput < Fluent::Plugin::Output
301
304
  require 'net/http'
302
305
  require 'net/http/persistent'
303
306
 
304
- def initialize(logger, use_ssl, no_ssl_validation, host, ssl_port, port, http_proxy, use_compression, api_key)
307
+ def initialize(logger, use_ssl, no_ssl_validation, host, ssl_port, port, http_proxy, use_compression, api_key, force_v1_routes = false)
305
308
  @logger = logger
306
309
  protocol = use_ssl ? "https" : "http"
307
310
  port = use_ssl ? ssl_port : port
308
- @uri = URI("#{protocol}://#{host}:#{port.to_s}/v1/input/#{api_key}")
311
+ if force_v1_routes
312
+ @uri = URI("#{protocol}://#{host}:#{port.to_s}/v1/input/#{api_key}")
313
+ else
314
+ @uri = URI("#{protocol}://#{host}:#{port.to_s}/api/v2/logs")
315
+ end
309
316
  proxy_uri = :ENV
310
317
  if http_proxy
311
318
  proxy_uri = URI.parse(http_proxy)
312
319
  elsif ENV['HTTP_PROXY'] || ENV['http_proxy']
313
320
  logger.info("Using HTTP proxy defined in `HTTP_PROXY`/`http_proxy` env vars")
314
321
  end
315
- logger.info("Starting HTTP connection to #{protocol}://#{host}:#{port.to_s} with compression " + (use_compression ? "enabled" : "disabled"))
322
+ logger.info("Starting HTTP connection to #{protocol}://#{host}:#{port.to_s} with compression " + (use_compression ? "enabled" : "disabled") + (force_v1_routes ? " using v1 routes" : " using v2 routes"))
316
323
  @client = Net::HTTP::Persistent.new name: "fluent-plugin-datadog-logcollector", proxy: proxy_uri
317
324
  @client.verify_mode = OpenSSL::SSL::VERIFY_NONE if no_ssl_validation
325
+ unless force_v1_routes
326
+ @client.override_headers["DD-API-KEY"] = api_key
327
+ @client.override_headers["DD-EVP-ORIGIN"] = "fluent"
328
+ @client.override_headers["DD-EVP-ORIGIN-VERSION"] = DatadogFluentPlugin::VERSION
329
+ end
318
330
  @client.override_headers["Content-Type"] = "application/json"
319
331
  if use_compression
320
332
  @client.override_headers["Content-Encoding"] = "gzip"
@@ -330,7 +342,8 @@ class Fluent::DatadogOutput < Fluent::Plugin::Output
330
342
  request.body = payload
331
343
  response = @client.request @uri, request
332
344
  res_code = response.code.to_i
333
- if res_code >= 500
345
+ # on a backend error or on an http 429, retry with backoff
346
+ if res_code >= 500 || res_code == 429
334
347
  raise RetryableError.new "Unable to send payload: #{res_code} #{response.message}"
335
348
  end
336
349
  if res_code >= 400
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DatadogFluentPlugin
4
+ VERSION = '0.14.0'
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-datadog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Datadog Solutions Team
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-22 00:00:00.000000000 Z
11
+ date: 2021-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -106,15 +106,15 @@ dependencies:
106
106
  requirements:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: 3.5.0
109
+ version: 3.6.0
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
- version: 3.5.0
117
- description:
116
+ version: 3.6.0
117
+ description:
118
118
  email:
119
119
  - support@datadoghq.com
120
120
  executables: []
@@ -128,11 +128,12 @@ files:
128
128
  - Rakefile
129
129
  - fluent-plugin-datadog.gemspec
130
130
  - lib/fluent/plugin/out_datadog.rb
131
+ - lib/fluent/plugin/version.rb
131
132
  homepage: http://datadoghq.com
132
133
  licenses:
133
134
  - Apache-2.0
134
135
  metadata: {}
135
- post_install_message:
136
+ post_install_message:
136
137
  rdoc_options: []
137
138
  require_paths:
138
139
  - lib
@@ -147,8 +148,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
148
  - !ruby/object:Gem::Version
148
149
  version: '0'
149
150
  requirements: []
150
- rubygems_version: 3.0.3
151
- signing_key:
151
+ rubyforge_project:
152
+ rubygems_version: 2.7.10
153
+ signing_key:
152
154
  specification_version: 4
153
155
  summary: Datadog output plugin for Fluent event collector
154
156
  test_files: []