This is an automated email from the ASF dual-hosted git repository.

eze pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 3c4c5fc59 Add `current_time_epoch_ms` stat to be appended before the 
server version. This allows computation of stats externally based on the cache 
time frame. This can help alleviate issues with sliding windows between various 
stats programs that generate discrepencies (#9567)
3c4c5fc59 is described below

commit 3c4c5fc59cc0318b17899450cc7bb7a021245288
Author: Evan Zelkowitz <[email protected]>
AuthorDate: Thu Mar 30 13:21:27 2023 -0600

    Add `current_time_epoch_ms` stat to be appended before the server version. 
This allows computation of stats externally based on the cache time frame. This 
can help alleviate issues with sliding windows between various stats programs 
that generate discrepencies (#9567)
---
 plugins/stats_over_http/stats_over_http.cc | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/plugins/stats_over_http/stats_over_http.cc 
b/plugins/stats_over_http/stats_over_http.cc
index 4a36c1525..7a86a3242 100644
--- a/plugins/stats_over_http/stats_over_http.cc
+++ b/plugins/stats_over_http/stats_over_http.cc
@@ -51,6 +51,8 @@
 #include <brotli/encode.h>
 #endif
 
+#include "tscore/ink_hrtime.h"
+
 #define PLUGIN_NAME     "stats_over_http"
 #define FREE_TMOUT      300000
 #define STR_BUFFER_SIZE 1024
@@ -411,12 +413,13 @@ json_out_stats(stats_state *my_state)
 {
   const char *version;
   APPEND("{ \"global\": {\n");
-
   TSRecordDump((TSRecordType)(TS_RECORDTYPE_PLUGIN | TS_RECORDTYPE_NODE | 
TS_RECORDTYPE_PROCESS), json_out_stat, my_state);
   version = TSTrafficServerVersionGet();
+  APPEND_STAT_JSON_NUMERIC("current_time_epoch_ms", "%" PRIu64, 
ink_hrtime_to_msec(ink_get_hrtime_internal()));
   APPEND("\"server\": \"");
   APPEND(version);
   APPEND("\"\n");
+
   APPEND("  }\n}\n");
 }
 
@@ -491,6 +494,7 @@ csv_out_stats(stats_state *my_state)
 {
   TSRecordDump((TSRecordType)(TS_RECORDTYPE_PLUGIN | TS_RECORDTYPE_NODE | 
TS_RECORDTYPE_PROCESS), csv_out_stat, my_state);
   const char *version = TSTrafficServerVersionGet();
+  APPEND_STAT_CSV_NUMERIC("current_time_epoch_ms", "%" PRIu64, 
ink_hrtime_to_msec(ink_get_hrtime_internal()));
   APPEND_STAT_CSV("version", "%s", version);
 }
 

Reply via email to