The invention discloses a method and a device used in program tracking and an electronic device, as well as a traffic control method and device and the electronic device. The method used in the program tracking comprises the steps of receiving a calling request which is sent by a calling party and is corresponding to a special program; according to the calling request, and generating a tracking identifier; and executing each level of subprogram included in the special program, generating tracking data of the subprogram for at least one subprogram after the subprogram is executed, and storing corresponding records of the tracking identifier and the tracking data of the subprogram. By adopting the method provided by the invention, a non-OSGi (Open Service Gateway initiative) application program, when tracking and recording a function operating condition of the OSGi subprogram, can separate a tracking processing logic and a service processing logic of the subprogram, and the transformation at a source code level on each subprogram is prevented; and thus, the effect of not affecting the robustness and the reliability of non-OSGi application program service processing is achieved.