Mercurial > hg > orthanc
diff OrthancServer/Plugins/Engine/OrthancPlugins.cpp @ 5326:fbe857e942cd
store metrics as integers instead of floats to avoid precision loss in increments
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sun, 25 Jun 2023 18:28:49 +0200 |
parents | f2e1ad71e49c |
children | 84150c5227f8 |
line wrap: on
line diff
--- a/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Sun Jun 25 17:49:34 2023 +0200 +++ b/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Sun Jun 25 18:28:49 2023 +0200 @@ -5280,24 +5280,23 @@ const _OrthancPluginSetMetricsValue& p = *reinterpret_cast<const _OrthancPluginSetMetricsValue*>(parameters); - MetricsType type; - switch (p.type) - { - case OrthancPluginMetricsType_Default: - type = MetricsType_Default; - break; - - case OrthancPluginMetricsType_Timer: - type = MetricsType_MaxOver10Seconds; - break; - - default: - throw OrthancException(ErrorCode_ParameterOutOfRange); - } - { PImpl::ServerContextLock lock(*pimpl_); - lock.GetContext().GetMetricsRegistry().SetValue(p.name, p.value, type); + lock.GetContext().GetMetricsRegistry().SetValue(p.name, boost::math::llround(p.value), + Plugins::Convert(p.type)); + } + + return true; + } + + case _OrthancPluginService_SetMetricsIntegerValue: + { + const _OrthancPluginSetMetricsIntegerValue& p = + *reinterpret_cast<const _OrthancPluginSetMetricsIntegerValue*>(parameters); + + { + PImpl::ServerContextLock lock(*pimpl_); + lock.GetContext().GetMetricsRegistry().SetValue(p.name, p.value, Plugins::Convert(p.type)); } return true;