Consider a constrained classical Lagrangian $ \mathcal{L}' = \mathcal{L}(q, \dot{q}) + \lambda f(q) $ where $ \lambda $ is the lagrange multiplier for the constraint. We can get a Hamiltonian for this system by the standard Legendre transform,
\begin{align} \mathcal{H}' = \dot{q} \frac{\partial}{\partial \dot{q}} \mathcal{L}' - \mathcal{L'} = \mathcal{H} - \lambda f(q) \end{align}
If I were trying to get the equations of motion, I would normally treat $ \lambda $ as a normal variable and get the equations of motion as usual.
Treating it like a normal variable, the microcanonical ensemble is,
\begin{align} \Omega(E) &= \int dq dp d\lambda~\delta \big( E - \mathcal{H} + \lambda f(q) \big) \end{align}
But if I inject the constain by hand into the microcanonical ensemble, I would expect an integral like, \begin{align} \Omega(E) &= \int dq dp~\delta \big( E - \mathcal{H} \big) ~\delta \big( f(q) \big) \end{align}
What is the connection? I assume the second integral is correct as it makes more sense to me, but how to I derive it? What about KKT type constrained dynamics like a ball falling onto a floor?