As part of fixing this, I would like to propose two small API changes in org.apache.hadoop.metrics:
 Currently, to remove metrics records from the metrics library's internal table you have to iterate over them one by one, since removal requires the record name and all of its tags (name/value pairs). I propose to generalize this so that you can specify the name and a subset of the tags - saving the client code the burden of having to remember all the tag/values that it has used. This doesn't change any API signatures, but it changes the meaning of MetricsRecord.remove().
 Also, as a convenience, I propose to add a method MetricsRecord.removeTag(String tagName). This method would be added to the MetricsRecordImpl class in the spi package also. This enables the use pattern:
On module initialization:
create a metrics record named foo
set long-lived tag (e.g. job id)
set short-lived tags (e.g. counter name)
set metric values
And finally, on cleanup:
remove the short-lived tags
call MetricsRecord.remove to clean up all the metric data created
Both of these should be binary compatible changes for people using the public package o.a.h.metrics.