Skip to content

Commit 7e9347f

Browse files
committed
Added "created_at" timestamp to outer layer of pserver stats data object via a new stats payload. Updated docs accordingly.
1 parent d0058a3 commit 7e9347f

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

app/pserver.cpp

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

209210
//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
@@ -36,6 +36,16 @@ namespace chimbuko{
3636
};
3737

3838

39+
/**
40+
* @brief A payload to insert a "created_at" timestamp entry into the record
41+
*/
42+
struct PSstatSenderCreatedAtTimestampPayload: public PSstatSenderPayloadBase{
43+
/**
44+
* @brief Add the timestamp into the 'into'
45+
*/
46+
void add_json(nlohmann::json &into) const override;
47+
};
48+
3949

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

sphinx/source/io_schema/pserver_schema.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ The full parameter server data packet JSON object has the following schema:
3030
---------------------
3131

3232
| {
33+
| **'created_at'**: *UNIX timestamp given in milliseconds relative to epoch*
3334
| **'anomaly_stats'**: *Statistics of anomalies (object with schema given below). This field will not appear if no data has been received from the AD instances since the last send*
3435
| **'anomaly_metrics'** : *Statistics of anomaly metrics by pid/rid/fid (array of objects with schema below).*
3536
| **'counter_stats'**: *Statistics of counter values aggregated over all ranks (array). This field will not appear if no counters were ever collected*
@@ -52,7 +53,7 @@ The schema for the **'anomaly_stats'** object is as follows:
5253
---------------------
5354

5455
| {
55-
| **'created_at'**: *timestamp given in milliseconds relative to epoch*,
56+
| **'created_at'**: *UNIX timestamp given in milliseconds relative to epoch*,
5657
| **'anomaly'**: *Statistics on anomalies by process/rank (array)*
5758
| [
5859
| {

src/pserver/PSstatSender.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
using namespace chimbuko;
88

9+
void PSstatSenderCreatedAtTimestampPayload::add_json(nlohmann::json &into) const{
10+
into["created_at"] = std::chrono::duration_cast<std::chrono::milliseconds>(
11+
std::chrono::system_clock::now().time_since_epoch() ).count();
12+
}
913

1014
PSstatSender::PSstatSender(size_t send_freq)
1115
: m_stat_sender(nullptr), m_stop_sender(false), m_bad(false), m_send_freq(send_freq)

0 commit comments

Comments
 (0)