Deciding whether $f$ is Lebesgue integrable Background: I'm learning Lebesgue's theory of integration. We have set up the outer measure, then defined the Lebesgue measure using Carthedory's criterion, then showed operations under which the set of Lebesgue measurable sets is stable (e.g. complements and countable union). We have defined measurable functions and now set up Lebesgue's integral using simple functions. We have just proved MCT.
Question: I'm having trouble deciding when a function $f$ is Lebesgue integrable over an interval. The definition of $f$ being integrable we follow is that (i) $f$ is measurable and (ii) $\int f^+, \int f^- <\infty$, where $f^+:=\max(f,0)$ and $f^-:=\max(-f,0)$.
How would I say whether this function is integrable? Let $f$ be defined on $\mathbb{R}$ as $x$ if $x$ is rational, and $0$ if $x$ is irrational.
So far, I've rewritten $f$ as $f(x)=x\chi_{\mathbb{Q}}(x)$. Then $f$ is measurable since $g(x)=x$ is measurable and $\mathbb{Q}$ is a measurable set, so its characteristic function is measurable, and then note that $f$ is a product of measurable functions, hence measurable.
I'm not sure how to show $\int f^+, \int f^- <\infty$ because I don't know how to integrate over $\mathbb{Q}$. Any ideas?

Let's show that $\int f^+ \, d\lambda < \infty$.
Any non-negative measurable function $f \colon X \to \mathbb R^+$ is the pointwise limit of a monotonic increasing sequence of non-negative simple functions $(f_n)$. In particular, let us define
\begin{align*}
I_{n,k} &= \left[\frac{k-1}{2^n},\frac{k}{2^n}\right) \text{ for } k=1,2,\ldots,2^{2n}\\
I_{n,2^{2n}+1} &= [2^n,\infty)\\
A_{n,k} &= f^{-1}(I_{n,k}) \text{ for } k=1,2,\ldots,2^{2n}+1\\
f_n &= \sum_{k=1}^{2^{2n}+1}\frac{k-1}{2^n}{\mathbf 1}_{A_{n,k}}
\end{align*}
Since $f_n \uparrow f^+$, by monotone convergence, $\int f_n \, d\lambda \uparrow \int f^+ \, d\lambda$. Furthermore,
\begin{align*}
\int f_n \, d\lambda = \sum_{k=1}^{2^{2n}+1}\frac{k-1}{2^n} \, \lambda(A_{n,k})
\end{align*}
Since $A_{n, k} = \mathbb Q \cap I_{n, k}$, we infer that $\lambda(A_{n, k}) = 0$, whence $\int f_n \, d\lambda = 0$. This implies, finally, that
\begin{align*}
\int f^+ \, d\lambda = 0
\end{align*}
