Class: Fluent::Plugin::AzureLogsIngestion::Client
- Inherits:
-
Object
- Object
- Fluent::Plugin::AzureLogsIngestion::Client
- Defined in:
- lib/fluent/plugin/azure_logs_ingestion/client.rb
Instance Method Summary collapse
-
#initialize(endpoint:, dcr_immutable_id:, stream_name:, logger:) ⇒ Client
constructor
A new instance of Client.
- #send_payload(payload:, bearer_token:) ⇒ Object
Constructor Details
#initialize(endpoint:, dcr_immutable_id:, stream_name:, logger:) ⇒ Client
Returns a new instance of Client.
14 15 16 17 18 19 |
# File 'lib/fluent/plugin/azure_logs_ingestion/client.rb', line 14 def initialize(endpoint:, dcr_immutable_id:, stream_name:, logger:) @endpoint = endpoint @dcr_immutable_id = dcr_immutable_id @stream_name = stream_name @log = logger end |
Instance Method Details
#send_payload(payload:, bearer_token:) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fluent/plugin/azure_logs_ingestion/client.rb', line 21 def send_payload(payload:, bearer_token:) uri = build_uri @log.debug('sending logs ingestion request', uri: uri.to_s, content_length: payload.content_length, content_encoding: payload.content_encoding) request = Net::HTTP::Post.new(uri) request['Authorization'] = "Bearer #{bearer_token}" request['Content-Type'] = 'application/json' request['Content-Encoding'] = payload.content_encoding if payload.content_encoding request['x-ms-client-request-id'] = SecureRandom.uuid request.body_stream = payload.io request.content_length = payload.content_length response = perform_request(uri, request) handle_response(response) true rescue Timeout::Error, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ECONNRESET, EOFError, SocketError, IOError, SystemCallError => error raise "logs ingestion request failed: #{error.}" ensure payload.io.rewind if payload&.io end |