Skip to content

Commit

Permalink
Merge 17071f4 into de6d95c
Browse files Browse the repository at this point in the history
  • Loading branch information
sathiyan-sivathas committed Apr 11, 2019
2 parents de6d95c + 17071f4 commit 7b6985d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions core/include/prometheus/family.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,6 @@ template <typename T>
template <typename... Args>
T& Family<T>::Add(const std::map<std::string, std::string>& labels,
Args&&... args) {
#ifndef NDEBUG
for (auto& label_pair : labels) {
auto& label_name = label_pair.first;
assert(CheckLabelName(label_name));
}
#endif

auto hash = detail::hash_labels(labels);
std::lock_guard<std::mutex> lock{mutex_};
auto metrics_iter = metrics_.find(hash);
Expand All @@ -166,6 +159,13 @@ T& Family<T>::Add(const std::map<std::string, std::string>& labels,
#endif
return *metrics_iter->second;
} else {
#ifndef NDEBUG
for (auto& label_pair : labels) {
auto& label_name = label_pair.first;
assert(CheckLabelName(label_name));
}
#endif

auto metric =
metrics_.insert(std::make_pair(hash, detail::make_unique<T>(args...)));
assert(metric.second);
Expand Down

0 comments on commit 7b6985d

Please sign in to comment.