I was looking at proofs of Jensen's inequality and noticed that they usually assume that for a convex function $g$ and a random variable $X$, the expression $\mathbb{E}(g(X))$ is well defined, which implies that $g(X)$ is a random variable.
I was thinking whether it was possible that all real-valued functions of random variables are random variables themselves, which is why the proofs skip the step of proving that $g(X)$ is a random variable.
But then I thought if $A$ is a Borel set, then $(g \circ X)^{-1}(A) = X^{-1}(g^{-1}(A)) $ may not itself be $\mathcal{F}$-measurable if $g^{-1}(A)$ is not Borel. But it is true if convex functions $g:\mathbb{R} \to \mathbb{R}$ are $\mathcal{B}$-measurable.
Is it true that all convex functions are $\mathcal{B}$-measurable, then? I know the sub-level sets of a convex function are convex, so if we can show that a convex set is Borel, that would work too. And is there a counterexample of a real-valued function of a random variable that isn't a random variable?