How to link a text object body to the edge length of another object?

I would like to create a tool to measure object length dynamically.
Something like a group of 2 objects:

  • 1 unique edge object
  • 1 text object (children of the previous)

How to link edge length to the text object body?