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.
440 441 442 443 444 445 446 |
# File 'lib/fluent/plugin/out_datadog.rb', line 440 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
476 477 478 |
# File 'lib/fluent/plugin/out_datadog.rb', line 476 def close @socket.close rescue nil end |
#connect ⇒ Object
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 |
# File 'lib/fluent/plugin/out_datadog.rb', line 448 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
465 466 467 468 469 470 471 472 473 474 |
# File 'lib/fluent/plugin/out_datadog.rb', line 465 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 |