Skip to content

Commit

Permalink
Added config object to monitoring initialization.
Browse files Browse the repository at this point in the history
  • Loading branch information
Peguen committed Aug 7, 2024
1 parent 2b2e4d7 commit e6d2096
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 26 deletions.
2 changes: 1 addition & 1 deletion ecal/core/src/ecal_globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ namespace eCAL
{
if (monitoring_instance == nullptr)
{
monitoring_instance = std::make_unique<CMonitoring>();
monitoring_instance = std::make_unique<CMonitoring>(eCAL::GetConfiguration().monitoring);
new_initialization = true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions ecal/core/src/monitoring/ecal_monitoring_def.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

namespace eCAL
{
CMonitoring::CMonitoring()
CMonitoring::CMonitoring(const Monitoring::Configuration& config_)
{
m_monitoring_impl = std::make_unique<CMonitoringImpl>();
m_monitoring_impl = std::make_unique<CMonitoringImpl>(config_);
}

CMonitoring::~CMonitoring()
Expand Down
3 changes: 2 additions & 1 deletion ecal/core/src/monitoring/ecal_monitoring_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#pragma once

#include <ecal/types/monitoring.h>
#include <ecal/config/monitoring.h>

#include <memory>
#include <string>
Expand All @@ -37,7 +38,7 @@ namespace eCAL
class CMonitoring
{
public:
CMonitoring();
CMonitoring(const Monitoring::Configuration& = {});
~CMonitoring();

void Start();
Expand Down
30 changes: 12 additions & 18 deletions ecal/core/src/monitoring/ecal_monitoring_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ namespace eCAL
////////////////////////////////////////
// Monitoring Implementation
////////////////////////////////////////
CMonitoringImpl::CMonitoringImpl() :
CMonitoringImpl::CMonitoringImpl(const Monitoring::Configuration& config_) :
m_init(false),
m_process_map (std::chrono::milliseconds(Config::GetMonitoringTimeoutMs())),
m_publisher_map (std::chrono::milliseconds(Config::GetMonitoringTimeoutMs())),
m_subscriber_map(std::chrono::milliseconds(Config::GetMonitoringTimeoutMs())),
m_server_map (std::chrono::milliseconds(Config::GetMonitoringTimeoutMs())),
m_clients_map (std::chrono::milliseconds(Config::GetMonitoringTimeoutMs()))
m_process_map (std::chrono::milliseconds(config_.timeout)),
m_publisher_map (std::chrono::milliseconds(config_.timeout)),
m_subscriber_map(std::chrono::milliseconds(config_.timeout)),
m_server_map (std::chrono::milliseconds(config_.timeout)),
m_clients_map (std::chrono::milliseconds(config_.timeout)),
m_config (config_)
{
}

Expand All @@ -58,15 +59,8 @@ namespace eCAL
// enable loopback to monitor process internal entities as well
eCAL::Util::EnableLoopback(true);

// get name of this host
m_host_name = Process::GetHostName();

// utilize registration receiver to enrich monitor information
g_registration_receiver()->SetCustomApplySampleCallback("monitoring", [this](const auto& sample_){this->ApplySample(sample_, tl_none);});

// setup blacklist and whitelist filter strings#
m_topic_filter_excl_s = Config::GetMonitoringFilterExcludeList();
m_topic_filter_incl_s = Config::GetMonitoringFilterIncludeList();
g_registration_receiver()->SetCustomApplySampleCallback("monitoring", [this](const auto& sample_){this->ApplySample(sample_, tl_none);});

// setup filtering on by default
SetFilterState(true);
Expand All @@ -83,12 +77,12 @@ namespace eCAL

void CMonitoringImpl::SetExclFilter(const std::string& filter_)
{
m_topic_filter_excl_s = filter_;
m_config.filter_excl = filter_;
}

void CMonitoringImpl::SetInclFilter(const std::string& filter_)
{
m_topic_filter_incl_s = filter_;
m_config.filter_incl = filter_;
}

void CMonitoringImpl::SetFilterState(bool state_)
Expand All @@ -98,13 +92,13 @@ namespace eCAL
// create excluding filter list
{
const std::lock_guard<std::mutex> lock(m_topic_filter_excl_mtx);
Tokenize(m_topic_filter_excl_s, m_topic_filter_excl, ",;", true);
Tokenize(m_config.filter_excl, m_topic_filter_excl, ",;", true);
}

// create including filter list
{
const std::lock_guard<std::mutex> lock(m_topic_filter_incl_mtx);
Tokenize(m_topic_filter_incl_s, m_topic_filter_incl, ",;", true);
Tokenize(m_config.filter_incl, m_topic_filter_incl, ",;", true);
}
}
else
Expand Down
8 changes: 4 additions & 4 deletions ecal/core/src/monitoring/ecal_monitoring_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#pragma once

#include <ecal/types/monitoring.h>
#include <ecal/config/monitoring.h>

#include "ecal_def.h"
#include "util/ecal_expmap.h"
Expand All @@ -47,7 +48,7 @@ namespace eCAL
class CMonitoringImpl
{
public:
CMonitoringImpl();
CMonitoringImpl(const Monitoring::Configuration& = {});
~CMonitoringImpl() = default;

void Create();
Expand Down Expand Up @@ -149,14 +150,13 @@ namespace eCAL
void Tokenize(const std::string& str, StrICaseSetT& tokens, const std::string& delimiters, bool trimEmpty);

bool m_init;
std::string m_host_name;

Monitoring::Configuration m_config;

std::mutex m_topic_filter_excl_mtx;
std::string m_topic_filter_excl_s;
StrICaseSetT m_topic_filter_excl;

std::mutex m_topic_filter_incl_mtx;
std::string m_topic_filter_incl_s;
StrICaseSetT m_topic_filter_incl;

// database
Expand Down

0 comments on commit e6d2096

Please sign in to comment.