TITLE: Bundle-to-function correspondence
QUESTION [9 upvotes]: 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?

REPLY [5 votes]: This answer comes by private correspondence from Mathieu Anel.  I record it here, with some minor clean-up, because it's exactly what I was looking for. --David Spivak

Here are some thoughts about what I've understood of your question.
We suppose that $f:E\to B$ is a (kind of) fibration.
If there exists a moduli object $M$ for fibrations, $f$ is classified by a function $[f]:B\to M$ (I've changed your notation).
Now I assume you want the map $f\mapsto [f]$ compatible with addition and products of fibers like $[f\times_Bg]=[f][g]$.
Remark : $M$ has a monoidal (or even a rig) structure iff the fibrations have a monoidal (or rig) structure. 
for example, discrete and Grothendieck fibrations are stable by disjoint sums and pull-backs and their moduli objects ($Sets$ and $Cat$) are rigs. 
other example, the direct sum and tensor product of vector bundles. 
in each case $f\mapsto [f]$ is always compatible with the operations (it's tautological).
Now compose with any rig morphism $g:M\to R$ where $R$ is any rig (e.g. a ring) and $g[f]$ is a "measure."  And, $[f]$ is the "universal measure."
Examples:

$M$ = moduli of (finite) sets $M\to {\mathbb N}$ = cardinality
$M$ = moduli for (finite dimensional) vector bundles $M\to {\mathbb N}$ = dimension (this one is compatible only with tensor product)
$M$ = moduli of compact riemannian manifolds $M\to {\mathbb R}$ = volume
K-theory : $M$ is anything that is a rig, and $g:M\to \Pi_0(M)^+$ (where $^+$ is the additive group completion)
$M$ = moduli for l-adic sheaves, $M\to R$ = trace of the frobenius operator