This paper studies a generalization of the Gerber-Shiu expected discounted penalty function [Gerber and Shiu (1998). On the time value of ruin. North American Actuarial Journal 2(1): 48–72] in the context of the perturbed compound Poisson insurance risk model, where the moments of the total discounted claims and the discounted small fluctuations (arising from the Brownian motion) until ruin are also included. In particular, the latter quantity is represented by a stochastic integral and has never been analyzed in the literature to the best of our knowledge. Recursive integro-differential equations satisfied by our generalized Gerber-Shiu function are derived, and these are transformed to defective renewal equations where the components are identified. Explicit solutions are given when the individual claim amounts are distributed as a combination of exponentials. Numerical illustrations are provided, including the computation of the covariance between discounted claims and discounted perturbation until ruin.