Convert trace counting to use modern arel methods