By taking into account the random arrival and departure of primary signals, spectrum sensing is formulated to a hypothesis testing problem with null hypothesis H0: primary signals are absent or present but departing within a sensing interval (secondary users are allowed to access the spectrum), and alternative hypothesis H1: primary signals are present and not departing within a sensing interval (secondary users are not allowed to access the spectrum). The above-mentioned binary hypothesis testing involves two mutually exclusive random variables (i.e., the departure and arrival time instants of primary signals). To tackle these random variables, we develop an average log-LRT (aveLLR) based energy detector (ED) by using the Bayesian criterion. The theoretical performance of the aveLLR-based ED is analyzed and numerical simulations are provided to demonstrate its superior performance. It is interesting that when the ratio of the length of sensing intervals to the holding time of channel states is small, the proposed aveLLR-based ED is approximately reduced to the conventional ED (C-ED). It was commonly believed that high primary user traffic would degrade the performance of C-ED severely, as C-ED does not consider the random arrival and departure of primary signals. However, we reveal that the ratio plays a key role, and when the ratio is small, the impact of the primary user traffic on the C-ED is marginal.