Jamie adds: Traditionally, the devices which record dialed phone numbers are called pen registers, and trap-and-trace devices. The ECPA provided some legal privacy protection. It was controversial when Section 214 of the Patriot Act amended 50 USC 1842 to allow the FBI to record this information with minimal oversight. The Department of Justice has been required for some time to report to Congress the number of pen registers and trap-and-traces, though in recent years [PDF, see question 10] it declared that information classified.
If anyone has information about how the NSA, as opposed to the FBI, has been involved in domestic phone number collection, please post links in the discussion.
In related news, the National Security Agency has closed down an inquiry into the so-called "Terrorist Surveillance Program," a separate program from this one, by refusing to grant security clearance to the lawyers in the Department of Justice. The NSA and the DoJ are both established under the executive.