Traces in symmetric monoidal categories are well-known and have many applications; for instance, their functoriality directly implies the Lefschetz fixed point theorem. However, for some applications, such as generalizations of the Lefschetz theorem, one needs "noncommutative" traces, such as the Hattori-Stallings trace for modules over noncommutative rings. In this paper we study a generalization of the symmetric monoidal trace which applies to noncommutative situations; its context is a bicategory equipped with an extra structure called a "shadow." In particular, we prove its functoriality and 2-functoriality, which are essential to its applications in fixed-point theory. Throughout we make use of an appropriate "cylindrical" type of string diagram, which we justify formally in an appendix.