The function $1/x$ on $\mathbb{R}$ (defined arbitrarily at $0$) is measurable but it is not Lebesgue integrable. In general, a function is Lebesgue integrable if and only if both the positive part and the negative part of the function has finite Lebesgue integral, which is not true for $1/x$.
There is a subtle difference in defining Lebesgue integrals in Real analysis textbooks:
I) The approach of Royden & Fitzpatrick (in “Real analysis” 4th ed), Stein & Shakarchi (in “Real Analysis: Measure Theory, Integration, And Hilbert Spaces”)
Firstly, it defines Lebesgue integrability and Lebesgue integral for a bounded function (not necessarily measurable) on a domain of finite measure. A bounded function needs to be Lebesgue integrable first (the upper and the lower Lebesgue integral agree), then the integral can be defined to be this common value. The authors’ motivation is try to define “Lebesgue integrability” like “Rieman integrability”: upper integral equals lower integral.
However, unfortunately, the upper and lower Lebesgue integrals don’t agree for an arbitrary Lebesgue integrable function, so when the authors move to functions in general (not necessarily bounded), they still have to go back to the requirement "measurable". This sudden appearance of "measurability" is not natural.
(Note that the upper/lower Darboux sum in the definition of Rieman integrability can be viewed as step functions, which are a special case of simple functions. So “upper/lower Rieman (Darboux) integral” is a special case of “upper/lower Lebesgue integral”)
II) The approach of Folland (in “Real Analysis: Modern Techniques and Their Applications”), Bruckner & Thomsom (in “Real analysis”), Carothers (in “Real analysis”), etc.
The construction requires a function to be measurable, and defines the Lebesgue integral to be the upper Lebesgue integral, and when the integral is finite the function is said to be Lebesgue integrable.
This approach doesn’t immediately show how Lebesgue integral convers Rieman integral, so later on, the author proves that in the case a function is bounded and the domain of integration is of finite measure: the upper Lebesgue integral equals to the lower Lebesgue integral, which means Lebesgue integral is reduced to Rieman integral.
Best Answer
There is no functions that are undefined at some point, that is, if $f(x):=\frac1{g(x)}$ and $g(x)=0$ for some $x$ then $f$ is not well-defined. However if you change the values of $f$ to something else, say zero, when $g$ is zero, then this new function is well-defined.
In Lebesgue integration theory we usually consider, instead of individual functions, equivalent classes of measurable functions. A class of measurable functions is a set of functions such the set of points where any two functions of this class are different is a set of zero measure, that is, if $\mathcal{L}_0(\mathbb{R})$ represent the set of Lebesgue measurable functions from $\mathbb{R}$ to $\mathbb{C}$, then for any $f\in \mathcal{L}_0(\mathbb{R})$ it equivalence class is defined by
$$ [f]:=\{h\in \mathcal{L}_0(\mathbb{R}): f(x)=h(x) \text{ almost everywhere }\} $$
Almost everywhere means that the set $\{x\in \mathbb{R}: f(x)\neq h(x)\}$ have zero measure. In this sense if $g$ is a measurable function and the set $\{x\in \mathbb{R}: g(x)=0\}$ have measure zero, then in the equivalent class of $g$, namely $[g]$, there is some function $g_1$ such that $g_1(x)=1$ whenever $g(x)=0$, therefore the equivalent class of $\frac1{g_1}$ is well-defined. So, in your example, we can consider $f$ as a representative of the class $\left[\frac1{g_1}\right]$.