def continue_transaction(txn_id, group_name, category = :requests, union_station_key = nil)
if !@server_address
return Log.new
elsif !txn_id || txn_id.empty?
raise ArgumentError, "Transaction ID may not be empty"
end
Lock.new(@mutex).synchronize do |lock|
if current_time < @next_reconnect_time
return Log.new
end
Lock.new(@connection.mutex).synchronize do |connection_lock|
if !@connection.connected?
begin
connect
connection_lock.reset(@connection.mutex)
rescue SystemCallError, IOError
@connection.disconnect
DebugLogging.warn("Cannot connect to the logging agent at #{@server_address}; " +
"retrying in #{@reconnect_timeout} second(s).")
@next_reconnect_time = current_time + @reconnect_timeout
return Log.new
rescue Exception => e
@connection.disconnect
raise e
end
end
begin
@connection.channel.write("openTransaction",
txn_id, group_name, "", category,
AnalyticsLogger.timestamp_string,
union_station_key,
true)
return Log.new(@connection, txn_id)
rescue SystemCallError, IOError
@connection.disconnect
DebugLogging.warn("The logging agent at #{@server_address}" <<
" closed the connection; will reconnect in " <<
"#{@reconnect_timeout} second(s).")
@next_reconnect_time = current_time + @reconnect_timeout
return Log.new
rescue Exception => e
@connection.disconnect
raise e
end
end
end
end