Channel capacity gives us a tight upper bound on the rate at which error free communication can take place. The instantaneous channel capacity over AWGN (channel capacity per sample) is:
$$ C_s = \frac{1}{2} \log_{10} (1 + SNR) $$$$ C_s = \frac{1}{2} \log_{2} (1 + SNR) $$
and the channel capacity over AWGN (channel capacity per second) is:
$$ C = (\text{Number of Samples Per Second)} \times \text{(Capacity Per Sample)} $$
$$ \implies C = f_sC_s = \frac{f_s}{2} \log_{10} (1 + SNR) = B \log_{10} (1 + SNR) $$$$ \implies C = f_sC_s = \frac{f_s}{2} \log_{2} (1 + SNR) = B \log_{2} (1 + SNR) $$
If the noise is not AWGN and is additive but some other colour of noise then your SNR will be a function of the carrier frequency (i.e \$SNR(f_c)\$) but in wireless comms the additive noise that we are most concerned about in white noise.
The ergodic capacity is the average capacity, so it is the expected value of \$C\$, where \$C\$ is a function of the SNR (\$\gamma\$):
$$ C_{erg} = E[C(\gamma)] $$
and from probability we know that the expected value of a random variable \$X\$ with a probability density function \$p(x)\$ is
$$ E[X] = \int_{-\infty}^{\infty} x\hspace{1mm}p(x)\hspace{1mm} dx $$
so
$$ C_{erg} = \int_{-\infty}^{\infty} C(\gamma)\hspace{1mm}p(\gamma)\hspace{1mm} d\gamma $$
if the SNR is always greater than zero then we have
$$ C_{erg} = \int_{0}^{\infty} C(\gamma)\hspace{1mm}p(\gamma)\hspace{1mm} d\gamma $$
If you are instead given the SNR as a function of the sampling frequency (i.e \$\gamma (f_s)\$) then:
$$ C_{erg} = \int_{0}^{\infty} C(f_s)\hspace{1mm}p(f_s)\hspace{1mm} df_s $$
where
$$ C(f_s) = \frac{f_s}{2} \log_{10} (1 + \gamma(f_s)) $$$$ C(f_s) = \frac{f_s}{2} \log_{2} (1 + \gamma(f_s)) $$