Mercurial > hg > orthanc
diff OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp @ 5493:b3ebe249ed5b pg-transactions
At startup, when using a database plugin, display the latency to access the DB
author | Alain Mazy <am@osimis.io> |
---|---|
date | Mon, 15 Jan 2024 18:25:08 +0100 |
parents | dceed5e3d6a9 |
children | 4dd50c4b985a |
line wrap: on
line diff
--- a/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp Wed Jan 10 15:26:10 2024 +0100 +++ b/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp Mon Jan 15 18:25:08 2024 +0100 @@ -1293,7 +1293,7 @@ serverIdentifier_(serverIdentifier), open_(false), databaseVersion_(0), - dbCapabilities_(false, false, false, false, false) // updated in Open() + dbCapabilities_(false, false, false, false, false, false) // updated in Open() { CLOG(INFO, PLUGINS) << "Identifier of this Orthanc server for the global properties " << "of the custom database: \"" << serverIdentifier << "\""; @@ -1368,6 +1368,7 @@ dbCapabilities_.hasLabelsSupport_ = systemInfo.supports_labels(); dbCapabilities_.hasAtomicIncrementGlobalProperty_ = systemInfo.supports_increment_global_property(); dbCapabilities_.hasUpdateAndGetStatistics_ = systemInfo.has_update_and_get_statistics(); + dbCapabilities_.hasMeasureLatency_ = systemInfo.has_measure_latency(); } open_ = true; @@ -1466,6 +1467,30 @@ } + uint64_t OrthancPluginDatabaseV4::MeasureLatency() + { + if (!open_) + { + throw OrthancException(ErrorCode_BadSequenceOfCalls); + } + else + { + try + { + DatabasePluginMessages::DatabaseRequest request; + DatabasePluginMessages::DatabaseResponse response; + + ExecuteDatabase(response, *this, DatabasePluginMessages::OPERATION_MEASURE_LATENCY, request); + return response.measure_latency().latency_us(); + + } + catch (OrthancException& e) + { + throw; + } + } + } + const IDatabaseWrapper::Capabilities& OrthancPluginDatabaseV4::GetDatabaseCapabilities() const { if (!open_)