Class: Aws::ClientSideMonitoring::Publisher Private

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-sdk-core/client_side_monitoring/publisher.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Publisher

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Publisher.



13
14
15
16
17
# File 'lib/aws-sdk-core/client_side_monitoring/publisher.rb', line 13

def initialize(opts = {})
  @agent_host = opts[:agent_host] || "127.0.0.1"
  @agent_port = opts[:agent_port]
  @mutex = Mutex.new
end

Instance Attribute Details

#agent_hostObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



11
12
13
# File 'lib/aws-sdk-core/client_side_monitoring/publisher.rb', line 11

def agent_host
  @agent_host
end

#agent_portObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/aws-sdk-core/client_side_monitoring/publisher.rb', line 10

def agent_port
  @agent_port
end

Instance Method Details

#publish(request_metrics) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
34
35
36
# File 'lib/aws-sdk-core/client_side_monitoring/publisher.rb', line 31

def publish(request_metrics)
  send_datagram(request_metrics.api_call.to_json)
  request_metrics.api_call_attempts.each do |attempt|
    send_datagram(attempt.to_json)
  end
end

#send_datagram(msg) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/aws-sdk-core/client_side_monitoring/publisher.rb', line 38

def send_datagram(msg)
  if @agent_port
    socket = UDPSocket.new
    begin
      socket.connect(@agent_host, @agent_port)
      socket.send(msg, 0)
    rescue Errno::ECONNREFUSED
      # Drop on the floor
    end
  end
end