class StackifyRubyAPM::Spies::StackifyLoggerSpy

@api private

Public Instance Methods

log_exception_task(level, ex) click to toggle source

set trans_id parameter on log exception to be passed unto MsgObject

# File lib/stackify_apm/spies/stackify_logger.rb, line 40
def log_exception_task(level, ex)
  return log_exception_task_without_apm(level, ex) unless StackifyRubyAPM.current_transaction

  begin
    trans_id = StackifyRubyAPM.agent.current_transaction.id
    log_uuid = SecureRandom.uuid

    # build span context
    ctx = Span::Context.new(
      CATEGORY: 'Stackify',
      SUBCATEGORY: 'Log',
      ID: log_uuid # matching the MsgObject id
    )
  rescue Exception => e
    StackifyRubyAPM.agent.error "[StackifyLoggerSpy] Error: creating span context."
    StackifyRubyAPM.agent.error "[StackifyLoggerSpy] #{e.inspect}"
    return log_exception_task_without_apm(level, ex)
  end

  # create log span
  StackifyRubyAPM.span(ex.message, 'stackify.log', context: ctx) do
    log_exception_task_without_apm(level, ex, trans_id, log_uuid)
  end
end
log_message_task(level, msg, call_trace) click to toggle source

set trans_id parameter on log message to be passed unto MsgObject

# File lib/stackify_apm/spies/stackify_logger.rb, line 14
def log_message_task(level, msg, call_trace)
  return log_message_task_without_apm(level, msg, call_trace) unless StackifyRubyAPM.current_transaction

  begin
    trans_id = StackifyRubyAPM.current_transaction.id
    log_uuid = SecureRandom.uuid

    # build span context
    ctx = Span::Context.new(
      CATEGORY: 'Stackify',
      SUBCATEGORY: 'Log',
      ID: log_uuid # matching the MsgObject id
    )
  rescue Exception => e
    StackifyRubyAPM.agent.error "[StackifyLoggerSpy] Error: creating span context."
    StackifyRubyAPM.agent.error "[StackifyLoggerSpy] #{e.inspect}"
    return log_message_task_without_apm(level, msg, call_trace)
  end

  # create log span
  StackifyRubyAPM.span(msg, 'stackify.log', context: ctx) do
    log_message_task_without_apm(level, msg, call_trace, trans_id, log_uuid)
  end
end