Metrics with directives

Follow up from Google groups. Added code to own module as is. Can be a bit more polished, but I don't know if its necessary for basic functionality.