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



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

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

Instance Attribute Details

#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.



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

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.



21
22
23
24
25
26
# File 'lib/aws-sdk-core/client_side_monitoring/publisher.rb', line 21

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.



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

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