Betatron x-ray emission in laser-plasma accelerators is a promising compact source that may be an alternative to conventional x-ray sources, based on large scale machines. In addition to its potential as a source, precise measurements of betatron emission can reveal crucial information about relativistic laser-plasma interaction. We show that the emission length and the position of the x-ray emission can be obtained by placing an aperture mask close to the source, and by measuring the beam profile of the betatron x-ray radiation far from the aperture mask. The position of the x-ray emission gives information on plasma wave breaking and hence on the laser non-linear propagation. Moreover, the measurement of the longitudinal extension helps one to determine whether the acceleration is limited by pump depletion or dephasing effects. In the case of multiple injections, it is used to retrieve unambiguously the position in the plasma of each injection. This technique is also used to study how, in a capillary discharge, the variations of the delay between the discharge and the laser pulse affect the interaction. The study reveals that, for a delay appropriate for laser guiding, the x-ray emission only occurs in the second half of the capillary: no electrons are injected and accelerated in the first half.