Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[20334] Report internal DdsRouter information with the DdsPipe's Monitor module #431

Merged
merged 17 commits into from
Mar 19, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <ddspipe_core/configuration/DdsPipeConfiguration.hpp>
#include <ddspipe_core/configuration/DdsPipeLogConfiguration.hpp>
#include <ddspipe_core/configuration/IConfiguration.hpp>
#include <ddspipe_core/configuration/MonitorConfiguration.hpp>
#include <ddspipe_core/types/dds/TopicQoS.hpp>

#include <ddsrouter_core/library/library_dll.h>
Expand Down Expand Up @@ -74,6 +75,9 @@ struct SpecsConfiguration : public ddspipe::core::IConfiguration

//! Configuration of the DDS Pipe's Log consumers.
ddspipe::core::DdsPipeLogConfiguration log_configuration;

//! Configuration of the DDS Pipe's Monitor.
ddspipe::core::MonitorConfiguration monitor_configuration{};
};

} /* namespace core */
Expand Down
8 changes: 8 additions & 0 deletions ddsrouter_yaml/src/cpp/YamlReader_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <ddspipe_yaml/YamlReader.hpp>

#include <ddspipe_core/configuration/DdsPipeConfiguration.hpp>
#include <ddspipe_core/configuration/MonitorConfiguration.hpp>
#include <ddsrouter_core/configuration/DdsRouterConfiguration.hpp>

#include <ddsrouter_yaml/YamlReaderConfiguration.hpp>
Expand Down Expand Up @@ -85,6 +86,13 @@ void YamlReader::fill(
object.log_configuration = YamlReader::get<ddspipe::core::DdsPipeLogConfiguration>(yml, LOG_CONFIGURATION_TAG,
version);
}

/////
// Get optional monitor tag
if (YamlReader::is_tag_present(yml, MONITOR_TAG))
{
object.monitor_configuration = YamlReader::get<core::MonitorConfiguration>(yml, MONITOR_TAG, version);
}
}

template <>
Expand Down
7 changes: 6 additions & 1 deletion docs/rst/notes/forthcoming_version.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
Forthcoming Version
###################

This release will include the following **Configuration features**:
The next release will include the following **Features**:

* Publish the :ref:`Logs <router_specs_logging>`.
* :ref:`Monitor <user_manual_configuration_specs_monitor>`.

The next release will include the following **Configuration features**:

* New configuration option ``logging`` to configure the :ref:`Logs <router_specs_logging>`.
63 changes: 63 additions & 0 deletions docs/rst/user_manual/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,62 @@ The type of the logs published is defined as follows:
publish-type: false
stdout: true

.. _user_manual_configuration_specs_monitor:

Monitor
-------

``specs`` supports a ``monitor`` **optional** tag to publish internal data from the |ddsrouter|.
The monitor publishes (and logs) the *DDS Router's* internal data on a ``domain``, under a ``topic-name``, once every ``period`` (in milliseconds).
juanlofer-eprosima marked this conversation as resolved.
Show resolved Hide resolved
If the monitor is not enabled, the |ddsrouter| will not collect or publish any data.

.. note::

The data published is relative to each period.
The |ddsrouter| will reset its tracked data after publishing it.


In particular, the |ddsrouter| will track the number of messages lost, received, and the frequency of each topic.
The type of the data published is defined as follows:

**MonitoringTopics.idl**

.. code-block:: idl

struct DdsTopicData
{
string participant_id;
unsigned long msgs_lost;
unsigned long msgs_received;
double msg_rx_rate;
juanlofer-eprosima marked this conversation as resolved.
Show resolved Hide resolved
};

struct DdsTopic
{
string name;
string type_name;
boolean type_discovered;
boolean type_mismatch;
boolean qos_mismatch;
sequence<DdsTopicData> data;
};

struct MonitoringTopics
{
sequence<DdsTopic> topics;
};

**Example of usage**

.. code-block:: yaml

monitor:
topics:
enable: true
period: 1000
domain: 10
topic-name: "DdsRouterTopicData"

Participant Configuration
=========================

Expand Down Expand Up @@ -948,6 +1004,13 @@ A complete example of all the configurations described on this page can be found
publish-type: false
stdout: true

monitor:
topics:
enable: true
period: 1000
domain: 10
topic-name: "DdsRouterTopicStatistics"

# XML configurations to load
xml:

Expand Down
12 changes: 11 additions & 1 deletion tools/ddsrouter_tool/src/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
#include <cpp_utils/utils.hpp>

#include <ddspipe_core/logging/DdsLogConsumer.hpp>

#include <ddspipe_core/monitoring/Monitor.hpp>
#include <ddspipe_core/monitoring/producers/TopicsMonitorProducer.hpp>
#include <ddspipe_participants/xml/XmlHandler.hpp>

#include <ddsrouter_core/configuration/DdsRouterConfiguration.hpp>
Expand Down Expand Up @@ -232,6 +233,15 @@ int main(
commandline_args.reload_time);
}

// Monitor
auto monitor_configuration = router_configuration.advanced_options.monitor_configuration;
ddspipe::core::Monitor monitor{monitor_configuration};

if (monitor_configuration.producers[ddspipe::core::TOPICS_MONITOR_PRODUCER_ID].enabled)
{
monitor.monitor_topics();
}

// Start Router
router.start();

Expand Down
Loading