// If this is the last metric with this name, remove the type as well.
if (!((it != metrics.begin() && prev(it)->first.name == name) ||
// If this is the last metric with this name, remove the type as well.
if (!((it != metrics.begin() && prev(it)->first.name == name) ||
lock_guard<mutex> lock(mu);
auto type_it = types.cbegin();
for (const auto &key_and_metric : metrics) {
lock_guard<mutex> lock(mu);
auto type_it = types.cbegin();
for (const auto &key_and_metric : metrics) {
// It's the first time we print out any metric with this name,
// so add the type header.
if (type_it->second == TYPE_GAUGE) {
// It's the first time we print out any metric with this name,
// so add the type header.
if (type_it->second == TYPE_GAUGE) {