Skip to content

Commit 0779ac9

Browse files
authored
Prefix definitions with O2_MONITORING (#123)
1 parent 3aa283c commit 0779ac9

File tree

7 files changed

+15
-16
lines changed

7 files changed

+15
-16
lines changed

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ endif()
126126
# Handle custom compile definitions
127127
target_compile_definitions(Monitoring
128128
PRIVATE
129-
$<$<BOOL:${APPLE}>:_OS_MAC>
130-
$<$<BOOL:${LINUX}>:_OS_LINUX>
131-
$<$<BOOL:${ApMon_FOUND}>:_WITH_APPMON>
129+
$<$<BOOL:${APPLE}>:O2_MONITORING_OS_MAC>
130+
$<$<BOOL:${LINUX}>:O2_MONITORING_OS_LINUX>
131+
$<$<BOOL:${ApMon_FOUND}>:O2_MONITORING_WITH_APPMON>
132132
)
133133

134134
# Use C++17

src/Monitoring.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void Monitoring::enableProcessMonitoring(const unsigned int interval) {
7474
mMonitorRunning = true;
7575
mMonitorThread = std::thread(&Monitoring::pushLoop, this);
7676
}
77-
#ifdef _OS_LINUX
77+
#ifdef O2_MONITORING_OS_LINUX
7878
MonLogger::Get() << "Process Monitor : Automatic updates enabled" << MonLogger::End();
7979
#else
8080
MonLogger::Get() << "!! Process Monitor : Limited metrics available" << MonLogger::End();
@@ -123,7 +123,7 @@ void Monitoring::pushLoop()
123123
while (mMonitorRunning) {
124124
if (mProcessMonitoringInterval != 0 && (loopCount % (mProcessMonitoringInterval*10)) == 0) {
125125
transmit(mProcessMonitor->getCpuAndContexts());
126-
#ifdef _OS_LINUX
126+
#ifdef O2_MONITORING_OS_LINUX
127127
transmit(mProcessMonitor->getMemoryUsage());
128128
#endif
129129
}

src/MonitoringFactory.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "Backends/Flume.h"
1515
#include "Backends/Noop.h"
1616

17-
#ifdef _WITH_APPMON
17+
#ifdef O2_MONITORING_WITH_APPMON
1818
#include "Backends/ApMonBackend.h"
1919
#endif
2020

@@ -65,7 +65,7 @@ std::unique_ptr<Backend> getInfluxDb(http::url uri) {
6565
throw std::runtime_error("InfluxDB transport protocol not supported");
6666
}
6767

68-
#ifdef _WITH_APPMON
68+
#ifdef O2_MONITORING_WITH_APPMON
6969
std::unique_ptr<Backend> getApMon(http::url uri) {
7070
return std::make_unique<backends::ApMonBackend>(uri.path);
7171
}

src/ProcessDetails.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include <unistd.h>
99

10-
#ifdef _OS_MAC
10+
#ifdef O2_MONITORING_OS_MAC
1111
#include <mach-o/dyld.h>
1212
#endif
1313

@@ -32,15 +32,15 @@ inline void ProcessDetails::generatePid()
3232
inline void ProcessDetails::generateProcessName()
3333
{
3434
char buff[255];
35-
#ifdef _OS_LINUX
35+
#ifdef O2_MONITORING_OS_LINUX
3636
ssize_t len = ::readlink("/proc/self/exe", buff, sizeof(buff)-1);
3737
if (len != -1) {
3838
buff[len] = '\0';
3939
mProcessName = std::string(buff);
4040
}
4141
#endif
4242

43-
#ifdef _OS_MAC
43+
#ifdef O2_MONITORING_OS_MAC
4444
uint32_t size = sizeof(buff);
4545
if (_NSGetExecutablePath(buff, &size) == 0) {
4646
mProcessName = std::string(buff);

src/ProcessMonitor.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ProcessMonitor::ProcessMonitor()
2323
mPid = static_cast<unsigned int>(::getpid());
2424
getrusage(RUSAGE_SELF, &mPreviousGetrUsage);
2525
mTimeLastRun = std::chrono::high_resolution_clock::now();
26-
#ifdef _OS_LINUX
26+
#ifdef O2_MONITORING_OS_LINUX
2727
setTotalMemory();
2828
#endif
2929
}

test/testMonitoring.cxx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ BOOST_AUTO_TEST_CASE(testPush)
5353

5454
BOOST_AUTO_TEST_CASE(testSymbols)
5555
{
56-
BOOST_WARN_MESSAGE(!BOOST_IS_DEFINED( _WITH_APPMON ), "ApMon Backend disabled");
57-
BOOST_WARN_MESSAGE(BOOST_IS_DEFINED( _OS_LINUX ), "Linux OS detected");
58-
BOOST_WARN_MESSAGE(BOOST_IS_DEFINED( _OS_WINDOWS ), "Windows OS detected");
59-
BOOST_WARN_MESSAGE(BOOST_IS_DEFINED( _OS_MAC ), "Mac OS detected");
56+
BOOST_WARN_MESSAGE(!BOOST_IS_DEFINED( O2_MONITORING_WITH_APPMON ), "ApMon Backend disabled");
57+
BOOST_WARN_MESSAGE(BOOST_IS_DEFINED( O2_MONITORING_OS_LINUX ), "Linux OS detected");
58+
BOOST_WARN_MESSAGE(BOOST_IS_DEFINED( O2_MONITORING_OS_MAC ), "Mac OS detected");
6059
}
6160

6261
} // namespace Test

test/testProcessMonitor.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ BOOST_AUTO_TEST_CASE(createProcessMonitor)
1313
{
1414
o2::monitoring::ProcessMonitor processMonitor;
1515
processMonitor.getCpuAndContexts();
16-
#ifdef _OS_LINUX
16+
#ifdef O2_MONITORING_OS_LINUX
1717
processMonitor.getMemoryUsage();
1818
#endif
1919
}

0 commit comments

Comments
 (0)