Implementation and tests of query metric tags function (#2)