This is an automated email from the ASF dual-hosted git repository.
amc 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 4a688fe785 Standardization: Use chrono instead of core for
stats_over_http (#9614)
4a688fe785 is described below
commit 4a688fe785eef33b7bb036cd2103e298b599c870
Author: Alan M. Carroll <[email protected]>
AuthorDate: Sun Apr 16 01:18:59 2023 -0500
Standardization: Use chrono instead of core for stats_over_http (#9614)
---
plugins/stats_over_http/stats_over_http.cc | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/plugins/stats_over_http/stats_over_http.cc
b/plugins/stats_over_http/stats_over_http.cc
index 7a86a32423..7836581c33 100644
--- a/plugins/stats_over_http/stats_over_http.cc
+++ b/plugins/stats_over_http/stats_over_http.cc
@@ -40,6 +40,8 @@
#include <arpa/inet.h>
#include <zlib.h>
#include <fstream>
+#include <chrono>
+
#include <ts/remap.h>
#include "swoc/swoc_ip.h"
@@ -51,8 +53,6 @@
#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
@@ -180,6 +180,15 @@ init_br(stats_state *my_state)
}
#endif
+namespace
+{
+inline uint64_t
+ms_since_epoch()
+{
+ return
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
+}
+} // namespace
+
encoding_format
init_gzip(stats_state *my_state, int mode)
{
@@ -415,7 +424,7 @@ json_out_stats(stats_state *my_state)
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_STAT_JSON_NUMERIC("current_time_epoch_ms", "%" PRIu64,
ms_since_epoch());
APPEND("\"server\": \"");
APPEND(version);
APPEND("\"\n");
@@ -494,7 +503,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_NUMERIC("current_time_epoch_ms", "%" PRIu64,
ms_since_epoch());
APPEND_STAT_CSV("version", "%s", version);
}