comparison OrthancServer/Sources/ServerContext.cpp @ 5431:4be5f117aa0d

metrics
author Alain Mazy <am@osimis.io>
date Tue, 21 Nov 2023 10:32:42 +0100
parents 111e21b4f8bc
children 6f2b11bfee8d
comparison
equal deleted inserted replaced
5430:b83192e7ad10 5431:4be5f117aa0d
326 } 326 }
327 } 327 }
328 } 328 }
329 329
330 330
331 void ServerContext::PublishDicomCacheMetrics() 331 void ServerContext::PublishCacheMetrics()
332 { 332 {
333 metricsRegistry_->SetFloatValue("orthanc_dicom_cache_size", 333 metricsRegistry_->SetFloatValue("orthanc_dicom_cache_size_mb",
334 static_cast<float>(dicomCache_.GetCurrentSize()) / static_cast<float>(1024 * 1024)); 334 static_cast<float>(dicomCache_.GetCurrentSize()) / static_cast<float>(1024 * 1024));
335 metricsRegistry_->SetIntegerValue("orthanc_dicom_cache_count", dicomCache_.GetNumberOfItems()); 335 metricsRegistry_->SetIntegerValue("orthanc_dicom_cache_count", dicomCache_.GetNumberOfItems());
336
337 metricsRegistry_->SetFloatValue("orthanc_storage_cache_size_mb",
338 static_cast<float>(storageCache_.GetCurrentSize()) / static_cast<float>(1024 * 1024));
339 metricsRegistry_->SetIntegerValue("orthanc_storage_cache_count", storageCache_.GetNumberOfItems());
336 } 340 }
337 341
338 342
339 ServerContext::ServerContext(IDatabaseWrapper& database, 343 ServerContext::ServerContext(IDatabaseWrapper& database,
340 IStorageArea& area, 344 IStorageArea& area,
666 } 670 }
667 671
668 // Remove the file from the DicomCache (useful if 672 // Remove the file from the DicomCache (useful if
669 // "OverwriteInstances" is set to "true") 673 // "OverwriteInstances" is set to "true")
670 dicomCache_.Invalidate(resultPublicId); 674 dicomCache_.Invalidate(resultPublicId);
671 PublishDicomCacheMetrics();
672 675
673 // TODO Should we use "gzip" instead? 676 // TODO Should we use "gzip" instead?
674 CompressionType compression = (compressionEnabled_ ? CompressionType_ZlibWithSize : CompressionType_None); 677 CompressionType compression = (compressionEnabled_ ? CompressionType_ZlibWithSize : CompressionType_None);
675 678
676 FileInfo dicomInfo = accessor.Write(dicom.GetBufferData(), dicom.GetBufferSize(), 679 FileInfo dicomInfo = accessor.Write(dicom.GetBufferData(), dicom.GetBufferSize(),
1326 if (dicom_.get() != NULL) 1329 if (dicom_.get() != NULL)
1327 { 1330 {
1328 try 1331 try
1329 { 1332 {
1330 context_.dicomCache_.Acquire(instancePublicId_, dicom_.release(), dicomSize_); 1333 context_.dicomCache_.Acquire(instancePublicId_, dicom_.release(), dicomSize_);
1331 context_.PublishDicomCacheMetrics();
1332 } 1334 }
1333 catch (OrthancException&) 1335 catch (OrthancException&)
1334 { 1336 {
1335 } 1337 }
1336 } 1338 }
1404 { 1406 {
1405 if (expectedType == ResourceType_Instance) 1407 if (expectedType == ResourceType_Instance)
1406 { 1408 {
1407 // remove the file from the DicomCache 1409 // remove the file from the DicomCache
1408 dicomCache_.Invalidate(uuid); 1410 dicomCache_.Invalidate(uuid);
1409 PublishDicomCacheMetrics();
1410 } 1411 }
1411 1412
1412 return index_.DeleteResource(remainingAncestor, uuid, expectedType); 1413 return index_.DeleteResource(remainingAncestor, uuid, expectedType);
1413 } 1414 }
1414 1415
1417 { 1418 {
1418 if (change.GetResourceType() == ResourceType_Instance && 1419 if (change.GetResourceType() == ResourceType_Instance &&
1419 change.GetChangeType() == ChangeType_Deleted) 1420 change.GetChangeType() == ChangeType_Deleted)
1420 { 1421 {
1421 dicomCache_.Invalidate(change.GetPublicId()); 1422 dicomCache_.Invalidate(change.GetPublicId());
1422 PublishDicomCacheMetrics();
1423 } 1423 }
1424 1424
1425 pendingChanges_.Enqueue(change.Clone()); 1425 pendingChanges_.Enqueue(change.Clone());
1426 } 1426 }
1427 1427