# HG changeset patch # User Sebastien Jodogne # Date 1687713094 -7200 # Node ID d0752fd53aec6a3549811561b3205c451b6d6598 # Parent 84150c5227f8de56b317e21f23865233b2a82f97 added metrics "orthanc_storage_read_bytes" and "orthanc_storage_written_bytes" diff -r 84150c5227f8 -r d0752fd53aec NEWS --- a/NEWS Sun Jun 25 18:40:19 2023 +0200 +++ b/NEWS Sun Jun 25 19:11:34 2023 +0200 @@ -26,6 +26,7 @@ * When deleting a resource, its parents LastUpdate metadata are now updated * Reduced the memory usage when downloading archives when "ZipLoaderThreads" > 0 * Metrics are now stored as integers instead of floats to avoid precision loss in increments +* Added metrics "orthanc_storage_read_bytes" and "orthanc_storage_written_bytes" * Upgraded dependencies for static builds: - boost 1.82.0 diff -r 84150c5227f8 -r d0752fd53aec OrthancFramework/Sources/FileStorage/StorageAccessor.cpp --- a/OrthancFramework/Sources/FileStorage/StorageAccessor.cpp Sun Jun 25 18:40:19 2023 +0200 +++ b/OrthancFramework/Sources/FileStorage/StorageAccessor.cpp Sun Jun 25 19:11:34 2023 +0200 @@ -41,6 +41,8 @@ static const std::string METRICS_CREATE_DURATION = "orthanc_storage_create_duration_ms"; static const std::string METRICS_READ_DURATION = "orthanc_storage_read_duration_ms"; static const std::string METRICS_REMOVE_DURATION = "orthanc_storage_remove_duration_ms"; +static const std::string METRICS_READ_BYTES = "orthanc_storage_read_bytes"; +static const std::string METRICS_WRITTEN_BYTES = "orthanc_storage_written_bytes"; namespace Orthanc @@ -116,9 +118,15 @@ { case CompressionType_None: { - MetricsTimer timer(*this, METRICS_CREATE_DURATION); + { + MetricsTimer timer(*this, METRICS_CREATE_DURATION); + area_.Create(uuid, data, size, type); + } - area_.Create(uuid, data, size, type); + if (metrics_ != NULL) + { + metrics_->IncrementValue(METRICS_WRITTEN_BYTES, size); + } if (cache_ != NULL) { @@ -155,6 +163,11 @@ } } + if (metrics_ != NULL) + { + metrics_->IncrementValue(METRICS_WRITTEN_BYTES, compressed.size()); + } + if (cache_ != NULL) { cache_->Add(uuid, type, data, size); // always add uncompressed data to cache @@ -189,8 +202,18 @@ { case CompressionType_None: { - MetricsTimer timer(*this, METRICS_READ_DURATION); - std::unique_ptr buffer(area_.Read(info.GetUuid(), info.GetContentType())); + std::unique_ptr buffer; + + { + MetricsTimer timer(*this, METRICS_READ_DURATION); + buffer.reset(area_.Read(info.GetUuid(), info.GetContentType())); + } + + if (metrics_ != NULL) + { + metrics_->IncrementValue(METRICS_READ_BYTES, buffer->GetSize()); + } + buffer->MoveToString(content); break; @@ -207,6 +230,11 @@ compressed.reset(area_.Read(info.GetUuid(), info.GetContentType())); } + if (metrics_ != NULL) + { + metrics_->IncrementValue(METRICS_READ_BYTES, compressed->GetSize()); + } + zlib.Uncompress(content, compressed->GetData(), compressed->GetSize()); break; @@ -234,8 +262,18 @@ { if (cache_ == NULL || !cache_->Fetch(content, info.GetUuid(), info.GetContentType())) { - MetricsTimer timer(*this, METRICS_READ_DURATION); - std::unique_ptr buffer(area_.Read(info.GetUuid(), info.GetContentType())); + std::unique_ptr buffer; + + { + MetricsTimer timer(*this, METRICS_READ_DURATION); + buffer.reset(area_.Read(info.GetUuid(), info.GetContentType())); + } + + if (metrics_ != NULL) + { + metrics_->IncrementValue(METRICS_READ_BYTES, buffer->GetSize()); + } + buffer->MoveToString(content); } } @@ -269,9 +307,19 @@ { if (cache_ == NULL || !cache_->FetchStartRange(target, fileUuid, contentType, end)) { - MetricsTimer timer(*this, METRICS_READ_DURATION); - std::unique_ptr buffer(area_.ReadRange(fileUuid, contentType, 0, end)); - assert(buffer->GetSize() == end); + std::unique_ptr buffer; + + { + MetricsTimer timer(*this, METRICS_READ_DURATION); + buffer.reset(area_.ReadRange(fileUuid, contentType, 0, end)); + assert(buffer->GetSize() == end); + } + + if (metrics_ != NULL) + { + metrics_->IncrementValue(METRICS_READ_BYTES, buffer->GetSize()); + } + buffer->MoveToString(target); if (cache_ != NULL)