def get_metadata(self, key, counter_id):
        """
        Return the metadata for the metric identified by `counter_id` for the given instance key.
        If the key is not in the cache, raises a KeyError.
        If there's no metric with the given counter_id, raises a MetadataNotFoundError.
        """
        with self._lock:
            metadata = self._metadata[key]
            try:
                return metadata[counter_id]
            except KeyError:
                raise MetadataNotFoundError("No metadata for counter id '{}' found in the cache.".format(counter_id))
Return the metadata for the metric identified by `counter_id` for the given instance key.
        If the key is not in the cache, raises a KeyError.
        If there's no metric with the given counter_id, raises a MetadataNotFoundError.