Class: Fluent::DatadogOutput::DatadogTCPClient
- Inherits:
-
DatadogClient
- Object
- DatadogClient
- Fluent::DatadogOutput::DatadogTCPClient
- Defined in:
- lib/fluent/plugin/out_datadog.rb
Overview
TCP Datadog client
Instance Method Summary collapse
- #close ⇒ Object
- #connect ⇒ Object
-
#initialize(logger, use_ssl, no_ssl_validation, host, ssl_port, port) ⇒ DatadogTCPClient
constructor
A new instance of DatadogTCPClient.
- #send(payload) ⇒ Object
Methods inherited from DatadogClient
Constructor Details
#initialize(logger, use_ssl, no_ssl_validation, host, ssl_port, port) ⇒ DatadogTCPClient
Returns a new instance of DatadogTCPClient.
369 370 371 372 373 374 375 |
# File 'lib/fluent/plugin/out_datadog.rb', line 369 def initialize(logger, use_ssl, no_ssl_validation, host, ssl_port, port) @logger = logger @use_ssl = use_ssl @no_ssl_validation = no_ssl_validation @host = host @port = use_ssl ? ssl_port : port end |
Instance Method Details
#close ⇒ Object
405 406 407 |
# File 'lib/fluent/plugin/out_datadog.rb', line 405 def close @socket.close rescue nil end |
#connect ⇒ Object
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
# File 'lib/fluent/plugin/out_datadog.rb', line 377 def connect if @use_ssl @logger.info("Starting SSL connection #{@host} #{@port}") socket = TCPSocket.new @host, @port ssl_context = OpenSSL::SSL::SSLContext.new if @no_ssl_validation ssl_context.set_params({:verify_mode => OpenSSL::SSL::VERIFY_NONE}) end ssl_context = OpenSSL::SSL::SSLSocket.new socket, ssl_context ssl_context.connect ssl_context else @logger.info("Starting plaintext connection #{@host} #{@port}") TCPSocket.new @host, @port end end |
#send(payload) ⇒ Object
394 395 396 397 398 399 400 401 402 403 |
# File 'lib/fluent/plugin/out_datadog.rb', line 394 def send(payload) begin @socket ||= connect @socket.puts(payload) rescue => e @socket.close rescue nil @socket = nil raise RetryableError.new "Unable to send payload: #{e.}." end end |