changeset 99:87a558cf280e

more metrics
author Alain Mazy <am@orthanc.team>
date Thu, 11 Dec 2025 17:09:22 +0100
parents 32a8ecbf7cf1
children 81ea9225d5ab 0fb772187f84
files Framework/PushMode/ActivePushTransactions.cpp Framework/PushMode/ActivePushTransactions.h NEWS Plugin/Plugin.cpp
diffstat 4 files changed, 64 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/PushMode/ActivePushTransactions.cpp	Thu Dec 11 15:35:04 2025 +0100
+++ b/Framework/PushMode/ActivePushTransactions.cpp	Thu Dec 11 17:09:22 2025 +0100
@@ -35,7 +35,7 @@
     DownloadArea                 area_;
     std::vector<TransferBucket>  buckets_;
     BucketCompression            compression_;
-
+    Orthanc::Toolbox::ElapsedTimer lifeSpanTimer_;
   public:
     Transaction(const std::vector<DicomInstanceInfo>& instances,
                 const std::vector<TransferBucket>& buckets,
@@ -74,6 +74,11 @@
     {
       area_.WriteBucket(GetBucket(bucketIndex), data, size, compression_);
     }
+
+    uint64_t GetLifespanMs()
+    {
+      return lifeSpanTimer_.GetElapsedMilliseconds();
+    }
   };
     
 
@@ -91,7 +96,14 @@
     assert(found->second != NULL);
     if (commit)
     {
+      Orthanc::Toolbox::ElapsedTimer timer;
+
+      totalReceivedBytesCount_ += found->second->GetDownloadArea().GetTotalSize();
+      totalTimeSpentInReceptionMs_ += found->second->GetLifespanMs();  // don't take the commit phase into account !
+
       found->second->GetDownloadArea().Commit();
+      
+      totalTimeSpentInCommitMs_ += timer.GetElapsedMilliseconds();
     }
 
     delete found->second;
--- a/Framework/PushMode/ActivePushTransactions.h	Thu Dec 11 15:35:04 2025 +0100
+++ b/Framework/PushMode/ActivePushTransactions.h	Thu Dec 11 17:09:22 2025 +0100
@@ -44,6 +44,9 @@
     size_t        createdTransactionsCount_;
     size_t        committedTransactionsCount_;
     size_t        abortedTransactionsCount_;
+    uint64_t      totalReceivedBytesCount_;
+    uint64_t      totalTimeSpentInReceptionMs_;
+    uint64_t      totalTimeSpentInCommitMs_;
 
     void FinalizeTransaction(const std::string& transactionUuid,
                              bool commit);
@@ -53,7 +56,10 @@
       maxSize_(maxSize),
       createdTransactionsCount_(0),
       committedTransactionsCount_(0),
-      abortedTransactionsCount_(0)
+      abortedTransactionsCount_(0),
+      totalReceivedBytesCount_(0),
+      totalTimeSpentInReceptionMs_(0),
+      totalTimeSpentInCommitMs_(0)
     {
     }
 
@@ -96,5 +102,21 @@
     {
       return abortedTransactionsCount_;
     }
+
+    uint64_t GetTotalReceivedBytesCount() const
+    {
+      return totalReceivedBytesCount_;
+    }
+
+    uint64_t GetTotalTimeSpentInReceptionMs() const
+    {
+      return totalTimeSpentInReceptionMs_;
+    }
+
+    uint64_t GetTotalTimeSpentInCommitMs() const
+    {
+      return totalTimeSpentInCommitMs_;
+    }
+
   };
 }
--- a/NEWS	Thu Dec 11 15:35:04 2025 +0100
+++ b/NEWS	Thu Dec 11 17:09:22 2025 +0100
@@ -6,13 +6,16 @@
   only if the storage is a distributed network storage (e.g object storage plugin).
   A value of 1 means reading and writing are performed in sequence (default behaviour).
 * new metrics:
-  - orthanc_transfers_used_cache_size_mb
+  - orthanc_transfers_used_cache_size
   - orthanc_transfers_cache_hit_count
   - orthanc_transfers_cache_miss_count
-  - orthanc_transfers_available_push_transactions_count
-  - orthanc_transfers_created_push_transfers_count
-  - orthanc_transfers_committed_push_transfers_count
-  - orthanc_transfers_aborted_push_transfers_count
+  - orthanc_transfers_available_push_count
+  - orthanc_transfers_created_push_count
+  - orthanc_transfers_committed_push_count
+  - orthanc_transfers_aborted_push_count
+  - orthanc_transfers_push_total_received_bytes_count
+  - orthanc_transfers_push_total_time_spent_in_reception_ms (from the creation of the push transfer till before the commit)
+  - orthanc_transfers_push_total_time_spent_in_commit_ms
 
 
 Version 1.6 (2025-10-07)
--- a/Plugin/Plugin.cpp	Thu Dec 11 15:35:04 2025 +0100
+++ b/Plugin/Plugin.cpp	Thu Dec 11 17:09:22 2025 +0100
@@ -503,8 +503,8 @@
   OrthancPlugins::PluginContext& context = OrthancPlugins::PluginContext::GetInstance();
 
   OrthancPluginSetMetricsIntegerValue(OrthancPlugins::GetGlobalContext(), 
-                                      "orthanc_transfers_used_cache_size_mb", 
-                                      static_cast<int64_t>(context.GetCache().GetMemorySize() / (1024 * 1024)),
+                                      "orthanc_transfers_used_cache_size", 
+                                      static_cast<int64_t>(context.GetCache().GetMemorySize()),
                                       OrthancPluginMetricsType_Default);
 
   OrthancPluginSetMetricsIntegerValue(OrthancPlugins::GetGlobalContext(), 
@@ -518,25 +518,39 @@
                                       OrthancPluginMetricsType_Default);
 
   OrthancPluginSetMetricsIntegerValue(OrthancPlugins::GetGlobalContext(), 
-                                      "orthanc_transfers_available_push_transactions_count", 
+                                      "orthanc_transfers_available_push_count", 
                                       static_cast<int64_t>(context.GetActivePushTransactions().GetAvailablePushTransactions()),
                                       OrthancPluginMetricsType_Default);
 
   OrthancPluginSetMetricsIntegerValue(OrthancPlugins::GetGlobalContext(), 
-                                      "orthanc_transfers_created_push_transfers_count", 
+                                      "orthanc_transfers_created_push_count", 
                                       static_cast<int64_t>(context.GetActivePushTransactions().GetCreatedTransactionsCount()),
                                       OrthancPluginMetricsType_Default);
 
   OrthancPluginSetMetricsIntegerValue(OrthancPlugins::GetGlobalContext(), 
-                                      "orthanc_transfers_committed_push_transfers_count", 
+                                      "orthanc_transfers_committed_push_count", 
                                       static_cast<int64_t>(context.GetActivePushTransactions().GetCommittedTransactionsCount()),
                                       OrthancPluginMetricsType_Default);
 
   OrthancPluginSetMetricsIntegerValue(OrthancPlugins::GetGlobalContext(), 
-                                      "orthanc_transfers_aborted_push_transfers_count", 
+                                      "orthanc_transfers_aborted_push_count", 
                                       static_cast<int64_t>(context.GetActivePushTransactions().GetAbortedTransactionsCount()),
                                       OrthancPluginMetricsType_Default);
 
+  OrthancPluginSetMetricsIntegerValue(OrthancPlugins::GetGlobalContext(), 
+                                      "orthanc_transfers_push_total_received_bytes_count", 
+                                      static_cast<int64_t>(context.GetActivePushTransactions().GetTotalReceivedBytesCount()),
+                                      OrthancPluginMetricsType_Default);
+
+  OrthancPluginSetMetricsIntegerValue(OrthancPlugins::GetGlobalContext(), 
+                                      "orthanc_transfers_push_total_time_spent_in_reception_ms", 
+                                      static_cast<int64_t>(context.GetActivePushTransactions().GetTotalTimeSpentInReceptionMs()),
+                                      OrthancPluginMetricsType_Default);
+
+  OrthancPluginSetMetricsIntegerValue(OrthancPlugins::GetGlobalContext(), 
+                                      "orthanc_transfers_push_total_time_spent_in_commit_ms", 
+                                      static_cast<int64_t>(context.GetActivePushTransactions().GetTotalTimeSpentInCommitMs()),
+                                      OrthancPluginMetricsType_Default);
 
 }