Update
The result looks fine but perhaps the code can be improved.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations,decorations.markings,decorations.text}
\begin{document}
\pgfkeys{/pgf/decoration/.cd,
distance/.initial=10pt
}
\pgfdeclaredecoration{add dim}{final}{
\state{final}{%
\pgfmathsetmacro{\dist}{5pt*\pgfkeysvalueof{/pgf/decoration/distance}/abs(\pgfkeysvalueof{/pgf/decoration/distance})}
\pgfpathmoveto{\pgfpoint{0pt}{0pt}}
\pgfpathlineto{\pgfpoint{0pt}{2*\dist}}
\pgfpathmoveto{\pgfpoint{\pgfdecoratedpathlength}{0pt}}
\pgfpathlineto{\pgfpoint{(\pgfdecoratedpathlength}{2*\dist}}
\pgfsetarrowsstart{latex}
\pgfsetarrowsend{latex}
\pgfpathmoveto{\pgfpoint{0pt}{\dist}}
\pgfpathlineto{\pgfpoint{\pgfdecoratedpathlength}{\dist}}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{0pt}{0pt}}
\pgfpathlineto{\pgfpoint{\pgfdecoratedpathlength}{0pt}}
}}
\tikzset{dim/.style args={#1,#2}{decoration={add dim,distance=#2},
decorate,
postaction={decorate,decoration={text along path,
raise=#2,
text align={align=center},
text={#1}}}}}
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (4,2);
\coordinate (C) at (8,-2);
\draw[dim={5 cm,10pt}] (A) -- (B);
\draw[dim={7 cm,-15pt}] (B) -- (C);
\draw[fill=gray] (A) circle(2pt);
\draw[fill=gray] (B) circle(2pt);
\draw[fill=gray] (C) circle(2pt);
\end{tikzpicture}
\end{document}

Update : possible with edge
\draw (A) edge [dim={5 cm,10pt}] (B)
edge[dim={7 cm,-15pt}] (C)
(B)edge[dim={4 cm,+10pt}] (C);

dimoption might be possible, but having adimpath command is not possible (as long you don't rewrite TikZ internal path parser). – Martin Scharrer♦ Dec 11 '11 at 12:59|-|type of arrows. See this question "Line segments with text in the middle in TikZ" and answers for different solutions. – percusse Dec 11 '11 at 17:19