To a morphism of sets $f\colon E\to B$ with finite fibers, one may assign a function $$|f^{-1}|\colon B\to{\mathbb N}$$ sending an element $b\in B$ to the cardinality of the fiber $f^{-1}(b)$.

To a proper morphism of manifolds imbedded in Euclidean space $f\colon E\to B$ one may assign a function $$|f^{-1}|\colon B\to{\mathbb R}$$ by sending an element $b\in B$ to the volume of the fiber $f^{-1}(b)$. ... Or we could assign the dimension of the fiber (valuing in ${\mathbb N}$), or we could assign the number of points in the fiber (valuing in ${\mathbb N}\cup${$\infty$}).

If $M$ is a commutative monoid (thought of as a set with addition operation), let $Set_{/M}$ denote the category of sets equipped with a map to $M$. Then to a morphism $f\colon E\to B$ in $Set{/M}$, where $f$ has finite fibers, one may assign a function $$|f^{-1}|\colon B\to M$$ sending an element $b\in B$ to the sum of the elements in the fiber. ... Or we could use a possibly non-commutative monoid $M$ but replace Sets-over-$M$ with Sequences-over-$M$.

To a discrete op-fibration of categories $f\colon E\to B$ one can assign a functor $$|f^{-1}|\colon B\to Set$$ sending $b$ to its fiber.

Question: What do all these have in common? More specifically, where can I find some category-theoretic way to understand situations of this type? The "type" here seems to be something like: a "finite type" morphism in a concrete category with "valuation" can be converted into a "valuation" on the base.

One might call it "integration along the fiber" or "gysin" or "sheaf-to-function correspondence." What is the generalized setup? What is the notion of "valuation" or "measure" supposed to be?