changeset 6966:c60dae105872

replaced orthanc_jobs_completed by orthanc_jobs_total_completed + siblings
author Alain Mazy <am@orthanc.team>
date Mon, 29 Jun 2026 16:00:46 +0200
parents 3948b93ed918
children 317326336ac6
files NEWS OrthancFramework/Sources/JobsEngine/JobsRegistry.cpp OrthancFramework/Sources/JobsEngine/JobsRegistry.h OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp OrthancServer/Sources/ServerContext.cpp
diffstat 5 files changed, 16 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Fri Jun 26 15:02:11 2026 +0200
+++ b/NEWS	Mon Jun 29 16:00:46 2026 +0200
@@ -36,6 +36,13 @@
 * Updated the naming structure of the zip downloaded from "/../../archive" routes.  Notably added
   SeriesNumber at the series level and now using " - " instead of " " to separate DICOM tags used
   in folder names.
+* In "/tools/metrics-prometheus":
+  - Removed "orthanc_jobs_completed", "orthanc_jobs_success" and "orthanc_jobs_failed" that were 
+    only considering the jobs currently stored in the JobsHistory and that were not suitable for
+    monitoring.  These metrics have been replaced by "orthanc_jobs_total_completed", 
+    "orthanc_jobs_total_success" and "orthanc_jobs_total_failed" that are now considering all the 
+    jobs that have run since Orthanc started.
+
 
 Plugin SDK
 ----------
--- a/OrthancFramework/Sources/JobsEngine/JobsRegistry.cpp	Fri Jun 26 15:02:11 2026 +0200
+++ b/OrthancFramework/Sources/JobsEngine/JobsRegistry.cpp	Mon Jun 29 16:00:46 2026 +0200
@@ -1639,17 +1639,13 @@
 
 
   void JobsRegistry::GetStatistics(unsigned int& pending,
-                                   unsigned int& running,
-                                   unsigned int& success,
-                                   unsigned int& failed)
+                                   unsigned int& running)
   {
     boost::mutex::scoped_lock lock(mutex_);
     CheckInvariants();
 
     pending = 0;
     running = 0;
-    success = 0;
-    failed = 0;
 
     for (JobsIndex::const_iterator it = jobsIndex_.begin();
          it != jobsIndex_.end(); ++it)
@@ -1669,11 +1665,8 @@
           break;
 
         case JobState_Success:
-          success ++;
-          break;
-
         case JobState_Failure:
-          failed ++;
+          // not counted since 1.12.11+
           break;
 
         default:
--- a/OrthancFramework/Sources/JobsEngine/JobsRegistry.h	Fri Jun 26 15:02:11 2026 +0200
+++ b/OrthancFramework/Sources/JobsEngine/JobsRegistry.h	Mon Jun 29 16:00:46 2026 +0200
@@ -196,9 +196,7 @@
     void ResetObserver();
 
     void GetStatistics(unsigned int& pending,
-                       unsigned int& running,
-                       unsigned int& success,
-                       unsigned int& errors);
+                       unsigned int& running);
 
     void GetLastModificationTime(boost::posix_time::ptime& modificationTime) const;
     
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp	Fri Jun 26 15:02:11 2026 +0200
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp	Mon Jun 29 16:00:46 2026 +0200
@@ -983,8 +983,8 @@
     context.GetIndex().GetGlobalStatistics(diskSize, uncompressedSize, countPatients, 
                                            countStudies, countSeries, countInstances);
 
-    unsigned int jobsPending, jobsRunning, jobsSuccess, jobsFailed;
-    context.GetJobsEngine().GetRegistry().GetStatistics(jobsPending, jobsRunning, jobsSuccess, jobsFailed);
+    unsigned int jobsPending, jobsRunning;
+    context.GetJobsEngine().GetRegistry().GetStatistics(jobsPending, jobsRunning);
 
     int64_t serverUpTime = context.GetServerUpTime();
     Json::Value lastChange;
@@ -999,9 +999,6 @@
     registry.SetIntegerValue("orthanc_count_instances", static_cast<int64_t>(countInstances));
     registry.SetIntegerValue("orthanc_jobs_pending", jobsPending);
     registry.SetIntegerValue("orthanc_jobs_running", jobsRunning);
-    registry.SetIntegerValue("orthanc_jobs_completed", jobsSuccess + jobsFailed);
-    registry.SetIntegerValue("orthanc_jobs_success", jobsSuccess);
-    registry.SetIntegerValue("orthanc_jobs_failed", jobsFailed);
     registry.SetIntegerValue("orthanc_up_time_s", serverUpTime);
     registry.SetIntegerValue("orthanc_last_change", lastChange["Last"].asInt64());
 
--- a/OrthancServer/Sources/ServerContext.cpp	Fri Jun 26 15:02:11 2026 +0200
+++ b/OrthancServer/Sources/ServerContext.cpp	Mon Jun 29 16:00:46 2026 +0200
@@ -266,6 +266,8 @@
 
   void ServerContext::SignalJobSuccess(const std::string& jobId)
   {
+    metricsRegistry_->IncrementIntegerValue("orthanc_jobs_total_completed", 1);
+    metricsRegistry_->IncrementIntegerValue("orthanc_jobs_total_success", 1);
     haveJobsChanged_ = true;
     pendingJobEvents_.Enqueue(new JobEvent(JobEventType_Success, jobId));
   }
@@ -273,6 +275,8 @@
   
   void ServerContext::SignalJobFailure(const std::string& jobId)
   {
+    metricsRegistry_->IncrementIntegerValue("orthanc_jobs_total_completed", 1);
+    metricsRegistry_->IncrementIntegerValue("orthanc_jobs_total_failed", 1);
     haveJobsChanged_ = true;
     pendingJobEvents_.Enqueue(new JobEvent(JobEventType_Failure, jobId));
   }