Skip to content

Commit 48b7f0d

Browse files
committed
metrics
1 parent ec18b55 commit 48b7f0d

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

ucm/shared/metrics/cc/metrics.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ void Metrics::CreateStats(const std::string& name, std::string& type)
3535
} else {
3636
if (type == "COUNTER") {
3737
stats_type_[name] = MetricType::COUNTER;
38-
} else if (type == "GUAGE") {
39-
stats_type_[name] = MetricType::GUAGE;
38+
} else if (type == "GAUGE") {
39+
stats_type_[name] = MetricType::GAUGE;
4040
} else if (type == "HISTOGRAM") {
4141
stats_type_[name] = MetricType::HISTOGRAM;
4242
} else {
@@ -49,13 +49,13 @@ void Metrics::UpdateStats(const std::string& name, double value)
4949
{
5050
std::lock_guard<std::mutex> lock(mutex_);
5151
auto it = stats_type_.find(name);
52-
if (it == stats_map_.end() || !it->second) { return; }
52+
if (it == stats_type_.end()) { return; }
5353
switch (it->second)
5454
{
5555
case MetricType::COUNTER:
5656
counter_stats_[name] += value;
5757
break;
58-
case MetricType::GUAGE:
58+
case MetricType::GAUGE:
5959
gauge_stats_[name] = value;
6060
break;
6161
case MetricType::HISTOGRAM:

ucm/shared/metrics/cc/metrics.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ class Metrics {
5454
> GetAllStatsAndClear();
5555

5656
private:
57-
enum class MetricType { COUNTER, GUAGE, HISTOGRAM };
57+
enum class MetricType { COUNTER, GAUGE, HISTOGRAM };
5858

5959
std::mutex mutex_;
6060
std::unordered_map<std::string, double> counter_stats_;
6161
std::unordered_map<std::string, double> gauge_stats_;
6262
std::unordered_map<std::string, std::vector<double>> histogram_stats_;
63-
std::unordered_map<std::string, int> stats_type_;
63+
std::unordered_map<std::string, MetricType> stats_type_;
6464

6565
Metrics() = default;
6666
Metrics(const Metrics&) = delete;

ucm/shared/metrics/cpy/metrics.py.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ inline void UpdateStats(const std::string& name, double value) {
3636
Metrics::GetInstance().UpdateStats(name, value);
3737
}
3838

39-
inline auto GetAllStatsAndClear() {
39+
inline std::tuple<
40+
std::unordered_map<std::string, double>,
41+
std::unordered_map<std::string, double>,
42+
std::unordered_map<std::string, std::vector<double>>
43+
> GetAllStatsAndClear() {
4044
return Metrics::GetInstance().GetAllStatsAndClear();
4145
}
4246

@@ -49,7 +53,7 @@ void bind_monitor(py::module_& m)
4953

5054
} // namespace UC::Metrics
5155

52-
PYBIND11_MODULE(ucmmonitor, module)
56+
PYBIND11_MODULE(ucmmetrics, module)
5357
{
5458
module.attr("project") = UCM_PROJECT_NAME;
5559
module.attr("version") = UCM_PROJECT_VERSION;

0 commit comments

Comments
 (0)