Skip to content

Commit 69b4916

Browse files
committed
moved from uint64_t to int64_t
1 parent 3d433ac commit 69b4916

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

include/Monitoring/Metric.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,16 @@ class Metric
4343
Metric(double value, const std::string& name, std::chrono::time_point<std::chrono::system_clock> timestamp = Metric::getCurrentTimestamp());
4444

4545
/// Initialize class variables
46-
/// \param value metric value (uint64_t)
46+
/// \param value metric value (int64_t)
4747
/// \param name metric name
4848
/// \param timestamp metric timestamp in milliseconds
49-
Metric(uint64_t value, const std::string& name, std::chrono::time_point<std::chrono::system_clock> timestamp = Metric::getCurrentTimestamp());
49+
Metric(int64_t value, const std::string& name, std::chrono::time_point<std::chrono::system_clock> timestamp = Metric::getCurrentTimestamp());
50+
51+
/// Initialize class variables, required by derived metrics logic
52+
/// \param value metric value (boost variant)
53+
/// \param name metric name
54+
/// \param timestamp metric timestamp in milliseconds
55+
Metric(boost::variant< int, std::string, double, int64_t >, const std::string& name, std::chrono::time_point<std::chrono::system_clock> timestamp = Metric::getCurrentTimestamp());
5056

5157
/// Default destructor
5258
~Metric() = default;
@@ -61,7 +67,7 @@ class Metric
6167

6268
/// Value getter
6369
/// \return metric value
64-
boost::variant< int, std::string, double, uint64_t > getValue() const;
70+
boost::variant< int, std::string, double, int64_t > getValue() const;
6571

6672
/// Value type getter
6773
/// \return type of value stores inside metric : 0 - int, 1 - std::string, 2 - double
@@ -87,7 +93,7 @@ class Metric
8793

8894
private:
8995
/// Metric value
90-
boost::variant< int, std::string, double, uint64_t > mValue;
96+
boost::variant< int, std::string, double, int64_t > mValue;
9197

9298
/// Metric name
9399
std::string mName;

src/Collector.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,17 +181,17 @@ void Collector::sendTimed(T value, std::string name, std::chrono::time_point<std
181181
template void Collector::send(int, std::string);
182182
template void Collector::send(double, std::string);
183183
template void Collector::send(std::string, std::string);
184-
template void Collector::send(uint64_t, std::string);
184+
template void Collector::send(int64_t, std::string);
185185

186186
template void Collector::sendTagged(int, std::string, std::vector<Tag>&& tags);
187187
template void Collector::sendTagged(double, std::string, std::vector<Tag>&& tags);
188188
template void Collector::sendTagged(std::string, std::string, std::vector<Tag>&& tags);
189-
template void Collector::sendTagged(uint64_t, std::string, std::vector<Tag>&& tags);
189+
template void Collector::sendTagged(int64_t, std::string, std::vector<Tag>&& tags);
190190

191191
template void Collector::sendTimed(int, std::string, std::chrono::time_point<std::chrono::system_clock>& timestamp);
192192
template void Collector::sendTimed(double, std::string, std::chrono::time_point<std::chrono::system_clock>& timestamp);
193193
template void Collector::sendTimed(std::string, std::string, std::chrono::time_point<std::chrono::system_clock>& timestamp);
194-
template void Collector::sendTimed(uint64_t, std::string, std::chrono::time_point<std::chrono::system_clock>& timestamp);
194+
template void Collector::sendTimed(int64_t, std::string, std::chrono::time_point<std::chrono::system_clock>& timestamp);
195195

196196
} // namespace Monitoring
197197
} // namespace AliceO2

src/DerivedMetrics.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66
#include "Monitoring/DerivedMetrics.h"
77
#include "Exceptions/MonitoringInternalException.h"
88
#include <boost/lexical_cast.hpp>
9+
#include <boost/variant/variant.hpp>
10+
#include <boost/variant/apply_visitor.hpp>
911
#include <chrono>
1012
#include <iostream>
1113
#include <map>
1214
#include <memory>
1315
#include <string>
1416
#include <vector>
1517
#include "MonLogger.h"
18+
#include "VariantVisitorRate.h"
1619

1720
namespace AliceO2
1821
{

src/ProcessMonitor.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ std::vector<Metric> ProcessMonitor::getNetworkUsage()
3939
auto position = line.find(":");
4040
auto secondPosition = line.find(":", position + 1);
4141
metrics.emplace_back(Metric{
42-
static_cast<uint64_t>(std::stoull(line.substr(position + 1, secondPosition - position - 1))),
42+
static_cast<int64_t>(std::stoll(line.substr(position + 1, secondPosition - position - 1))),
4343
"bytesReceived"}.addTags({{"if", line.substr(0, position)}})
4444
);
4545
metrics.emplace_back(Metric{
46-
static_cast<uint64_t>(std::stoull(line.substr(secondPosition + 1, line.size()))),
46+
static_cast<int64_t>(std::stoll(line.substr(secondPosition + 1, line.size()))),
4747
"bytesTransmitted"}.addTags({{"if", line.substr(0, position)}})
4848
);
4949
}

test/testMetric.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ BOOST_AUTO_TEST_CASE(retrieveString)
5050

5151
BOOST_AUTO_TEST_CASE(retrieveUnsignedLongLong)
5252
{
53-
uint64_t value = 10000000000000LL;
53+
int64_t value = 10000000000000LL;
5454
std::string name("metric name");
5555
AliceO2::Monitoring::Metric metricInstance(value, name );
5656

57-
BOOST_CHECK_EQUAL(boost::get<uint64_t>(metricInstance.getValue()), 10000000000000LL);
57+
BOOST_CHECK_EQUAL(boost::get<int64_t>(metricInstance.getValue()), 10000000000000LL);
5858
BOOST_CHECK_EQUAL(metricInstance.getType(), 3);
5959
}
6060

0 commit comments

Comments
 (0)