  The Boltzmann distribution of an ideal gas is determined by the Hamiltonian
function generating single particle dynamics. Systems with higher complexity
often exhibit topological constraints, which are independent of the Hamiltonian
and may affect the shape of the distribution function as well. Here, we study a
further source of heterogeneity, the curvature of spacetime arising from the
general theory of relativity. The present construction relies on three
assumptions: first, the statistical ensemble is made of particles obeying
geodesic equations, which define the phase space of the system. Next, the
metric coefficients are time-symmetric, implying that, if thermodynamic
equilibrium is achieved, all physical observables are independent of coordinate
time. Finally, ergodicity is enforced with respect to proper time, so that
ambiguity in the choice of a time variable for the statistical ensemble is
removed. Under these hypothesis, we derive the distribution function of
thermodynamic equilibrium, and verify that it reduces to the Boltzmann
distribution in the classical limit. We further show that spacetime curvature
affects physical observables, even far from the source of the metric. Two
examples are analyzed: an ideal gas in Schwarzschild spacetime and a charged
gas in Kerr-Newman spacetime. In the Schwarzschild case, conservation of
macroscopic constraints, such as angular momentum, combined with relativistic
distortion of the distribution function can produce configurations with
decreasing density and growing azimuthal rotation velocity far from the event
horizon of the central mass. In the Kerr-Newman case, it is found that kinetic
energy associated with azimuthal rotations is an increasing function of the
radial coordinate, and it eventually approaches a constant value corresponding
to classical equipartition, even though spatial particle density decreases.
