class Stackify::AgentBaseSender

Public Instance Methods

send_logs(msgs, attempts = 3) click to toggle source

send_logs() Function to put the msg in the Worker

# File lib/stackify/agent_base_sender.rb, line 8
def send_logs msgs, attempts = 3
  worker = Stackify::LogsSenderWorker.new('UnixSocketSender worker')
  task = send_logs_task attempts, msgs
  worker.async_perform ScheduleDelay.new, task
end

Private Instance Methods

gather_and_pack_data(msgs) click to toggle source
# File lib/stackify/agent_base_sender.rb, line 31
def gather_and_pack_data msgs
  details = Stackify::EnvDetails.instance.auth_info
  {
    'CDID' => details['DeviceID'],
    'CDAppID' => details['DeviceAppID'],
    'Logger' => 'Rails logger',
    'AppName' => details['AppName'],
    'AppNameID' => details['AppNameID'],
    'Env' => details['Env'],
    'EnvID' => details['EnvID'],
    'AppEnvID' => details['AppEnvID'],
    'ServerName' => details['DeviceName'],
    'Msgs' => msgs,
    'AppLoc' => details['AppLocation'],
    'Platform' => 'Ruby'
  }
end
properties() click to toggle source
# File lib/stackify/agent_base_sender.rb, line 16
def properties
  {
    success_condition: lambda { |result| result.try(:status) == 200 },
    limit: 1
  }.dup
end
send_logs_task(attempts = nil, msgs) click to toggle source
# File lib/stackify/agent_base_sender.rb, line 23
def send_logs_task attempts = nil, msgs
  properties[:attempts] = attempts if attempts
  Stackify::ScheduleTask.new properties do
    data = gather_and_pack_data(msgs).to_json
    send_request data
  end
end
send_request(log_group) click to toggle source
# File lib/stackify/agent_base_sender.rb, line 49
def send_request log_group
  raise NotImplementedError
end