Abstract : In this paper, we solve explicitly the optimal stopping problem with random discounting and an additive functional as cost of observations for a regular linear diffusion. We also extend the results to the class of one-sided regular Feller processes. This generalizes the result of Beibel and Lerche [Statist. Sinica 7 (1997) 93-108] and [Teor. Veroyatn. Primen. 45 (2000) 657-669] and Irles and Paulsen [Sequential Anal. 23 (2004) 297-316]. Our approach relies on a combination of techniques borrowed from potential theory and stochastic calculus. We illustrate our results by detailing some new examples ranging from linear diffusions to Markov processes of the spectrally negative type.