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

szaszm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git


The following commit(s) were added to refs/heads/main by this push:
     new 8bd9c5d30 MINIFICPP-2571 Change C2 bulletin timestamp type
8bd9c5d30 is described below

commit 8bd9c5d30d3a856ece0b924feea0ec2e56e915e1
Author: Gabor Gyimesi <[email protected]>
AuthorDate: Wed Jun 4 15:19:04 2025 +0200

    MINIFICPP-2571 Change C2 bulletin timestamp type
    
    Closes #1970
    
    Signed-off-by: Marton Szasz <[email protected]>
---
 C2.md                                              | 4 ++--
 libminifi/src/core/state/nodes/FlowInformation.cpp | 2 +-
 libminifi/test/integration/C2MetricsTest.cpp       | 2 +-
 utils/include/utils/TimeUtil.h                     | 4 ----
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/C2.md b/C2.md
index 244e0e887..2b5a8b2cc 100644
--- a/C2.md
+++ b/C2.md
@@ -200,7 +200,7 @@ configuration produces the following JSON:
               "processorBulletins": [
                 {
                     "id": 1,
-                    "timestamp": "Mon Jan 27 12:10:47 UTC 2025",
+                    "timestamp": 1749037558068,
                     "level": "ERROR",
                     "category": "Log Message",
                     "message": "Error connecting to localhost:8776 due to 
Connection refused (2438e3c8-015a-1000-79ca-83af40ec1991)",
@@ -556,7 +556,7 @@ Contains information about the flow the agent is running, 
including the versione
     "processorBulletins": [
         {
             "id": 1,
-            "timestamp": "Mon Jan 27 12:10:47 UTC 2025",
+            "timestamp": 1749037558068,
             "level": "ERROR",
             "category": "Log Message",
             "message": "Error connecting to localhost:8776 due to Connection 
refused (2438e3c8-015a-1000-79ca-83af40ec1991)",
diff --git a/libminifi/src/core/state/nodes/FlowInformation.cpp 
b/libminifi/src/core/state/nodes/FlowInformation.cpp
index 56584156b..6fdb57f57 100644
--- a/libminifi/src/core/state/nodes/FlowInformation.cpp
+++ b/libminifi/src/core/state/nodes/FlowInformation.cpp
@@ -111,7 +111,7 @@ std::vector<SerializedResponseNode> 
FlowInformation::serialize() {
         .collapsible = false,
         .children = {
           {.name = "id", .value = bulletin.id},
-          {.name = "timestamp", .value = 
utils::timeutils::getNiFiDateTimeFormat(std::chrono::time_point_cast<std::chrono::seconds>(bulletin.timestamp))},
+          {.name = "timestamp", .value = 
gsl::narrow<int64_t>(std::chrono::duration_cast<std::chrono::milliseconds>(bulletin.timestamp.time_since_epoch()).count())},
           {.name = "level", .value = bulletin.level},
           {.name = "category", .value = bulletin.category},
           {.name = "message", .value = bulletin.message},
diff --git a/libminifi/test/integration/C2MetricsTest.cpp 
b/libminifi/test/integration/C2MetricsTest.cpp
index fb51805b4..7451e0c3b 100644
--- a/libminifi/test/integration/C2MetricsTest.cpp
+++ b/libminifi/test/integration/C2MetricsTest.cpp
@@ -169,7 +169,7 @@ class MetricsHandler: public HeartbeatHandler {
     return std::any_of(bulletins.begin(), bulletins.end(), [](const auto& 
bulletin) {
       std::string message = bulletin["message"].GetString();
       return bulletin["id"].GetInt() > 0 &&
-        !std::string{bulletin["timestamp"].GetString()}.empty() &&
+        bulletin["timestamp"].GetInt64() > 0 &&
         bulletin["level"].GetString() == std::string("ERROR") &&
         bulletin["category"].GetString() == std::string("Log Message") &&
         message.find("Error connecting to") != std::string::npos &&
diff --git a/utils/include/utils/TimeUtil.h b/utils/include/utils/TimeUtil.h
index b8766f42b..c9b1d4534 100644
--- a/utils/include/utils/TimeUtil.h
+++ b/utils/include/utils/TimeUtil.h
@@ -104,10 +104,6 @@ inline std::string 
getRFC2616Format(std::chrono::sys_seconds tp) {
   return date::format("%a, %d %b %Y %H:%M:%S %Z", tp);
 }
 
-inline std::string getNiFiDateTimeFormat(std::chrono::sys_seconds tp) {
-  return date::format("%a %b %d %H:%M:%S %Z %Y", tp);
-}
-
 inline date::sys_seconds to_sys_time(const std::tm& t) {
   using date::year;
   using date::month;

Reply via email to