// Copyright 2017 Google Inc. All Rights Reserved. // // This file contains implementations for the BaseCounterMetric, the base class // for CounterMetric. #include "counter_metric.h" namespace wvcdm { namespace metrics { void BaseCounterMetric::Increment(const std::string& field_names_values, int64_t value) { AutoLock lock(internal_lock_); if (value_map_.find(field_names_values) == value_map_.end()) { value_map_[field_names_values] = value; } else { value_map_[field_names_values] = value_map_[field_names_values] + value; } } void BaseCounterMetric::Serialize(MetricSerializer* serializer) { AutoLock lock(internal_lock_); for (std::map::iterator it = value_map_.begin(); it != value_map_.end(); it++) { serializer->SetInt64(metric_name_ + "/count" + it->first, it->second); } } } // namespace metrics } // namespace wvcdm