This way to measure the total discontinuity of a function is based on the following definition from Spivak's "Calculus on Manifolds" (p. 12-13): Let $f:\mathbb{R}\to\mathbb{R}$ be bounded. Then define the oscillation of $f$ at $a\in\mathbb{R}$, $o(f,a)$, by $$o(f,a)=\lim_{\delta\to 0} M(f,a,\delta)-m(f,a,\delta),$$ where $M(f,a,\delta)$ and $m(f,a,\delta)$ are the max and min of $f$ on the open ball centered at $a$ of radius $\delta$, respectively (if we allow $f$ to be only bounded from below or from above, then we can extend the definition by allowing $o(f,a)$ to possibly be infinite. If $f$ is unbounded, it could be that the oscillation is not well defined, for example looking at $o(f,0)$ for a function $f=1/x$ on $\mathbb{R}\setminus \{0\}$).
This limit exists since $o(f,a)$ decreases as $\delta$ decreases, and the quantity in the limit is bounded below by zero. As Spivak notes, $o(f,a)$ is a way to measure how discontinuous a function is at a point. The above definition can easily be lifted to any bounded function $f:X\to Y$ for $X,Y\subset \mathbb{R}$ just by restricting everything to the subspace topology on $X$. Then one can show that $f$ is continuous at $x\in X$ if and only if $o(f,x)=0$ (with this in mind, one could also extend this definition to measure the level of continuity on an arbitrary metric space instead of just $\mathbb{R}$).
Now we make some additional observations about the oscillation $o(f,x)$. First, observe that $o(f,x)$ is upper-semicontinuous, and therefore Lebesgue measurable (see here for more references and additional properties of the oscillation of a function). Moreover, a standard result in a measure theory class is that $D_f$, the set of discontinuities of a function $f$, is a Lebesgue measurable set.
Therefore, if one wants to obtain a measure of how discontinuous a function is, the following seems like a natural candidate in light of the above exposition: $$MC(f):=\int_{D_f} o(f,x)\:d\lambda(x),$$ where the integral is with respect to the Lebesgue measure (we restrict the domain of integration to be $D_f$ so that the definition makes sense even when the more natural domain $X$ is non measurable. If $X$ were measurable the two choices would coincide). Per the previous paragraphs, $MC(f)$ is well defined for any bounded function $f:X\to Y$.
I believe this definition also has all of the properties that were asked for by Arbuja. Since $o(f,x)=0$ iff $f$ is continuous at $x$, and because $o(f,x)\geq 0$, $MC(f)=0$ if and only if $f$ is continuous almost everywhere. Moreover, a function like $1_\mathbb{Q}$ has $MC(1_\mathbb{Q})=\infty$, since $o(1_\mathbb{Q},x)=1$ for all $x\in\mathbb{R}$ and $1_\mathbb{Q}$ is nowhere continuous.
We can also run a quick computation to see that this definition is able to qualitatively distinguish between functions where one is arguably "more continuous" than the other. Let $c>0$ and consider the function $$f_c(x)=e^{-cx^2}1_\mathbb{Q}(x).$$ Then even though $f_c$ is nowhere continuous, we could think of it as being more continuous than $1_\mathbb{Q}$ because $f_c$ rapidly approaches zero as $|x|\to\infty$, and so as $|x|$ becomes large, the function gets "closer" to being continuous in a loose sense. One can compute that $$o(f_c,x)=e^{-cx^2},$$
and from there it's straightforward to see that $MC(f_c)$ is a positive number which decreases to zero as $c\to\infty$ and increases to infinity as $c\to 0$. Note as $c\to 0$, $f_c$ approaches $1_\mathbb{Q}$ pointwise, while as $c\to\infty$, $f_c$ approaches 0 pointwise, which is continuous.
One limitation of this definition is that it cannot distinguish between $1_\mathbb{Q}$ and, say, $1_\mathbb{Q}/100$ in the sense these both have an infinite $MC$ if the domain $X$ on which we consider them has a subset of infinite measure. However even qualitatively I would posit this is not too much of an issue, since these functions are both discontinuous in a qualitatively identical way (both are discontinuous everywhere with constant oscillation). If you still wanted to find some way to compare the level of discontinuity between functions $f$ and $g$, something like $$\lim_{x\to\infty}\frac{MC(f|_{X\cap[-x,x]})}{MC(g|_{X\cap[-x,x]})}$$ could be useful (e.g. this would say that in some sense $1_\mathbb{Q}$ is 100 times more discontinuous than $1_\mathbb{Q}$), but I have not thought too much about it.