The feature of getting monitoring information about the events inside SObjectizer Environment was implemented long ago since version 5.5.4. The mechanism works on clock cycle: user is able to set the rate of receiving the monitoring information. For example, once in 250ms. This means that every 250ms SObjectizer will send message pack with current values to special mbox.
The minor defect was found out in this mechanism with time: for the series of processing monitoring information scenarios it was very desirable to know that the next cycle of data distribution started or finished. In version 5.5.18 this defect was fixed. New types of messages: distribution_started and distribution_finished were added to the so_5::stats::messages namespace. The message distribution_started is sent in the beginning of each cycle of monitoring information distribution. Actually it’s the first message being sent by stats_controller in the cycle begin. Then follow messages from data sources inside SObjectizer Environment. The cycle is closed by distribution_finished message. This is the last message and there will not be any more messages related to the closed cycle.
These two messages simplify the scenarios processing which require information about the moments of cycle begin/end. For example to update information on the charts or to fixate the transaction with new data in DB.
Below is the example of agent that initiates the distribution of monitoring information 3 times per second and then processes only messages with information about request queues length on worker threads running in SObjectizer Environment dispatchers (to filter the required messages the delivery_filters mechanism is used).
{
public :
a_stats_listener_t(
context_t ctx,
, m_logger(
std::move( logger ) )
{}
{
controller.mbox(),
return suffixes::work_thread_queue_size() == msg.m_suffix;
} );
controller.mbox(),
&a_stats_listener_t::evt_quantity )
.
event( controller.mbox(),
so_5::send< log_message >( m_logger, "--- DISTRIBUTION STARTED ---" );
} )
.
event( controller.mbox(),
so_5::send< log_message >( m_logger, "--- DISTRIBUTION FINISHED ---" );
} );
}
{
std::chrono::milliseconds( 330 ) );
}
private :
void evt_quantity(
{
std::ostringstream ss;
}
};
virtual void so_define_agent()
Hook on define agent for SObjectizer.
environment_t & so_environment() const noexcept
Access to the SObjectizer Environment which this agent is belong.
const state_t & so_default_state() const
Access to the agent's default state.
virtual void so_evt_start()
Hook on agent start inside SObjectizer.
void so_set_delivery_filter(const mbox_t &mbox, delivery_filter_unique_ptr_t filter)
Set a delivery filter.
stats::controller_t & stats_controller()
Access to controller of run-time monitoring.
const state_t & event(Args &&... args) const
Helper for subscription of event handler in this state.
virtual void turn_on()=0
Turn the monitoring on.
virtual std::chrono::steady_clock::duration set_distribution_period(std::chrono::steady_clock::duration period)=0
Set distribution period.
All stuff related to run-time monitoring and statistics.
Private part of message limit implementation.
void send(Target &&to, Args &&... args)
A utility function for creating and delivering a message or a signal.
Notification about finish of stats distribution.
Notification about start of new stats distribution.
A message with value of some quantity.
suffix_t m_suffix
Suffix of data_source name.
T m_value
Actual quantity value.
prefix_t m_prefix
Prefix of data_source name.