How does this theorem on continued fractions relate to the Riemann-Stieltjes integral? I'm going to include two precursor sections here to introduce all of the content referenced in my actual question (if you're familiar with both continued fractions and the Riemann-Stieltjes integral, scroll down to the Question section).
Precursors
1. Continued Fractions

A continued fraction is a nested fraction of the form
$$
\alpha = a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \cfrac{1}{a_3 + \ddots}}}
$$
For conciseness, we typically write simply $\alpha = [a_0;a_1,a_2,\ldots]$ (provided the continued fraction corresponding to $\alpha$ is infinite, which is only the case if $\alpha$ is irrational), and, for the sake of the measure-theoretic concerns associated with continued fractions, we also typically confine $\alpha$ to $(0,1)$, so that $a_0 = 0$. Moreover, we will, in the case of this question, at least, restrict the terms $a_1$, $a_2$, and so on, to $\mathbb{N}$ (as an aside, these terms are known as the partial quotients of $\alpha$).

2. The Riemann-Stieltjes Integral

Given an interval $[a, b]\subset\mathbb{R}$, we call $\mathcal{P}$ a partition of $[a,b]$ into $n\in\mathbb{N}$ intervals if $\mathcal{P} = \lbrace x_0, x_1, \ldots, x_n\rbrace$ is such that $x_0 = a$, $x_n = b$, and $x_{i - 1}<x_i$, $\forall i\in\mathbb{N}$ satisfying $i\leq n$. We denote the set of all partitions of $[a,b]$ using $\mathcal{P}([a, b])$. Now, given a function $f:[a, b]\to\mathbb{R}$, we define the Riemann integral of $f$ over $[a, b]\subset\mathbb{R}$ as
$$
\int_a^bf(x)~dx = \inf_{\mathcal{P}\in\mathcal{P}([a, b])}\mathcal{U}(f, \mathcal{P}) = \sup_{\mathcal{P}\in\mathcal{P}([a, b])}\mathcal{L}(f, \mathcal{P})
$$
where
$$
\mathcal{U}(f, \mathcal{P}) = \sum_{i = 1}^n(x_i - x_{i - 1})\sup_{x\in[x_{i - 1},x_i]}f(x)~~~\mathrm{and}~~~\mathcal{L}(f, \mathcal{P}) = \sum_{i = 1}^n(x_i - x_{i - 1})\inf_{x\in[x_{i - 1},x_i]}f(x)
$$
provided these supremums/infimums exist (which is not always the case, since we can construct non-integrable functions). On the other hand, the Riemann-Stieltjes function is not defined in terms of sums of the form
$$
\sum_{i = 1}^n(x_{i} - x_{i - 1})f(c_i)
$$
for some $c_i\in[x_{i - 1},x_i]$, but rather Riemann-Stieltjes integrals, for a function $g:\mathbb{R}\to\mathbb{R}$ called an integrator, are defined in terms of sums of the form
$$
\sum_{i = 1}^n(g(x_i) - g(x_{i - 1}))f(c_i)
$$
for some $c_i\in[x_{i - 1}, x_i]$.

Question
We have the following theorem

Suppose that, for some $f:\mathbb{N}\to\lbrace x\in\mathbb{R}:x>0\rbrace$, $\exists C,\delta>0$ such that $f(r)<Cr^{1/2 + \delta}$, $\forall r\in\mathbb{N}$. Then, for almost all $\alpha = [0;a_1, a_2,\ldots]\in(0, 1)$
$$
\lim_{N\to\infty}\frac{1}{N}\sum_{k = 1}^Nf(a_k) = \sum_{r = 1}^{\infty}\frac{f(r)}{\ln 2}\ln\bigg{(}1 + \frac{1}{r(r + 2)}\bigg{)}
$$

Now, the question, finally, is: is there any connection between this result and the notion of the Riemann-Stieltjes integral? The closest I could come to any reasonable interpretation of the above result in terms of Riemann-Stieltjes integrals is that you can rewrite the logarithmic terms on the RHS of the above equation in the form
$$
\frac{1}{\ln 2}\ln\bigg{(}\frac{r(r + 2) + 1}{r(r + 2)}\bigg{)} = \frac{\ln(r(r + 2) + 1) - \ln(r(r + 2))}{\ln 2} = \frac{\ln(r^2 + 2r + 1)}{\ln 2} - \frac{\ln(r^2 + 2r)}{\ln 2}
$$
which would lead me to believe that, on the RHS, at least, we have an obvious integrator function, namely
$$
g(x) = \frac{\ln x}{\ln 2}
$$
Now, given the form of the inputs to the integrator function, we know also that we are integrating over the region
$$
I = \bigcup_{r = 1}^{\infty}[r^2 + 2r, r^2 + 2r + 1]
$$
meaning this is an improper integral. Finally, we require the argument of $f$ to be confined to $[r^2 + 2r, r^2 + 2r + 1]$, $\forall r\in\mathbb{N}$. In the original statement of the equation in question, this is clearly not the case, but we can simply suppose that $f$ is composed with a function, say $\varphi:\mathbb{R}\to\mathbb{N}$, which satisfies $\varphi:c_r\mapsto r$, $\forall c_r\in[r^2 + 2r, r^2 + 2r + 1]$, $\forall r\in\mathbb{N}$. With all of this in mind, we might therefore be tempted to believe that the RHS of the given equation is in some way related to the Riemann-Stieltjes integral
$$
\int_{I}(f\circ\varphi)(x)~d\frac{\ln x}{\ln 2} = \sum_{r = 1}^{\infty}\int_{r^2 + 2r}^{r^2 + 2r + 1}(f\circ\varphi)(x)~d\frac{\ln x}{\ln 2}
$$
Although, given my very limited experience with the Riemann-Stieltjes integral, I really have no clue whether I'm on the right track here. Any pointers in a more productive direction here would be greatly appreciated.
 A: Let $\lfloor z \rfloor$ be the integral and $\{z\}$ be the fractional part of $z$, and suppose that for $\alpha = [0;a_1,a_2,\ldots]$ and nonnegative integers $j$ you define $\alpha_{(j)}:=[0;a_{j+1},a_{j+2},\ldots]$.  Then $\alpha_{(j)}$ is gotten from $\alpha$ by $j$ applications of the map $\phi: z \mapsto \{z^{-1}\}$, and $g_0(z):=(\log \, (z+1))/\log 2$ is an integrator function which is invariant for $\phi$ in the sense that
$$\int_0^1 h(z)\,  dg_0(z)=\int_0^1 h(\phi(z)) \, dg_0(z)$$
for all continuous functions $h$ on $[0,1]$; also,
$\int_0^1 dg_0(z) = 1$.   Because of this, it's possible to use ergodic theory to prove (On the ergodic theorems (II) (Ergodic theory of continued fractions),
C. Ryll-Nardzewski, Studia Mathematica 12 (1951), 74-79, Theorem 3) that, provided that $h$ is a function on $[0,1]$ such that $\int_0^1 h(z)\, dg_0(z)$ exists, then for almost all $\alpha$ in $[0,1]$,
\begin{eqnarray*}
\lim_{N\to\infty}\frac{1}{N}\sum_{0\le k\le N-1} h(\phi(\phi(\cdots(\alpha)\cdots)))
&=&\int_0^1 h(z) \,dg_0(z),
\\
\qquad \qquad \hbox{where there are $k$ applications of $\phi$;}
\end{eqnarray*}
the left-hand side of this can be rewritten as
$$
\lim_{N\to\infty}\frac{1}{N}\sum_{0\le k\le N-1} h(\alpha_{(k)}).
$$
In fact, if $h$ is nonnegative, it's enough to assume that
the integral exists (or is infinite) as a Riemann-Stieltjes integral which is improper at 0, 1, or both.
The result you want now follows if you set $h(z):=f(\lfloor z^{-1} \rfloor)$, since $\lfloor \alpha_{(k)}^{-1} \rfloor = a_{k+1}$ and,
allowing the integral to be improper at 0,
\begin{eqnarray*}
\int_0^1 f(\lfloor z^{-1} \rfloor) \,dg_0(z)&=&
\sum_{n\ge 1} \int_{1/(n+1)}^{1/n} f(n) \,dg_0(z)\\
&=& \sum_{n\ge 1} f(n)\left(g_0(\frac 1 n)-g_0(\frac 1 {n+1})\right)\\
&=& \sum_{n\ge 1} \frac{f(n)}{\log 2}\left(\log(1 + \frac 1 n)-\log(1+\frac 1 {n+1})\right)\\
&=& \sum_{n\ge 1} \frac{f(n)}{\log 2}\log \frac {(n+1)^2}{n(n+2)}\\
&=& \sum_{n\ge 1} \frac{f(n)}{\log 2}\log \left(1 + \frac {1}{n(n+2)}\right).
\end{eqnarray*}
If $f$ is nonnegative it's not necessary to have a growth condition on $f$.
If you like, you can write this as an improper Riemann-Stieltjes integral of $f$ by using the integrator function
$$g_1(z):=1-\frac1 {\log 2} \log\left(1+\frac 1 {\lfloor z \rfloor + 1}\right).$$
