Skip to content

Commit 482a25f

Browse files
committed
Added version number to outer layer of pserver stats data object via a new stats payload. Updated docs accordingly.
Updated hpserver to include created_at and version entries into its stats data
1 parent 7e9347f commit 482a25f

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

app/hpserver.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ int main (int argc, char ** argv){
140140
stat_sender.add_payload(new PSstatSenderGlobalAnomalyStatsPayload(&global_func_stats[0]));
141141
stat_sender.add_payload(new PSstatSenderGlobalCounterStatsPayload(&global_counter_stats[0]));
142142
stat_sender.add_payload(new PSstatSenderGlobalAnomalyMetricsPayload(&global_anom_metrics[0]));
143+
stat_sender.add_payload(new PSstatSenderCreatedAtTimestampPayload); //add 'created_at' timestamp
144+
stat_sender.add_payload(new PSstatSenderVersionPayload); //add 'created_at' timestamp
143145
stat_sender.run_stat_sender(args.ws_addr, args.stat_outputdir);
144146

145147
//Start communicating with the AD instances

app/pserver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ int main (int argc, char ** argv){
205205
stat_sender.add_payload(new PSstatSenderGlobalCounterStatsCombinePayload(global_counter_stats));
206206
stat_sender.add_payload(new PSstatSenderGlobalAnomalyMetricsCombinePayload(global_anom_metrics));
207207
stat_sender.add_payload(new PSstatSenderCreatedAtTimestampPayload); //add 'created_at' timestamp
208+
stat_sender.add_payload(new PSstatSenderVersionPayload); //add 'created_at' timestamp
208209
stat_sender.run_stat_sender(args.ws_addr, args.stat_outputdir);
209210

210211
//Register a signal handler that prevents the application from exiting on SIGTERM; instead this signal will be handled by ZeroMQ and will cause the pserver to shutdown gracefully

include/chimbuko/pserver/PSstatSender.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ namespace chimbuko{
4646
void add_json(nlohmann::json &into) const override;
4747
};
4848

49+
/**
50+
* @brief A payload to insert a "version" entry into the record
51+
*/
52+
struct PSstatSenderVersionPayload: public PSstatSenderPayloadBase{
53+
/**
54+
* @brief Add the version number into the 'into'
55+
*/
56+
void add_json(nlohmann::json &into) const override;
57+
};
58+
4959

5060
/**
5161
* @brief A class that periodically sends aggregate statistics to the visualization module via curl using a background thread

src/pserver/PSstatSender.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ void PSstatSenderCreatedAtTimestampPayload::add_json(nlohmann::json &into) const
1111
std::chrono::system_clock::now().time_since_epoch() ).count();
1212
}
1313

14+
void PSstatSenderVersionPayload::add_json(nlohmann::json &into) const{
15+
into["version"] = 2;
16+
}
17+
1418
PSstatSender::PSstatSender(size_t send_freq)
1519
: m_stat_sender(nullptr), m_stop_sender(false), m_bad(false), m_send_freq(send_freq)
1620
{

0 commit comments

Comments
 (0)