comparison 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
comparison
equal deleted inserted replaced
5325:9c00e832985f 5326:fbe857e942cd
5278 case _OrthancPluginService_SetMetricsValue: 5278 case _OrthancPluginService_SetMetricsValue:
5279 { 5279 {
5280 const _OrthancPluginSetMetricsValue& p = 5280 const _OrthancPluginSetMetricsValue& p =
5281 *reinterpret_cast<const _OrthancPluginSetMetricsValue*>(parameters); 5281 *reinterpret_cast<const _OrthancPluginSetMetricsValue*>(parameters);
5282 5282
5283 MetricsType type;
5284 switch (p.type)
5285 {
5286 case OrthancPluginMetricsType_Default:
5287 type = MetricsType_Default;
5288 break;
5289
5290 case OrthancPluginMetricsType_Timer:
5291 type = MetricsType_MaxOver10Seconds;
5292 break;
5293
5294 default:
5295 throw OrthancException(ErrorCode_ParameterOutOfRange);
5296 }
5297
5298 { 5283 {
5299 PImpl::ServerContextLock lock(*pimpl_); 5284 PImpl::ServerContextLock lock(*pimpl_);
5300 lock.GetContext().GetMetricsRegistry().SetValue(p.name, p.value, type); 5285 lock.GetContext().GetMetricsRegistry().SetValue(p.name, boost::math::llround(p.value),
5286 Plugins::Convert(p.type));
5287 }
5288
5289 return true;
5290 }
5291
5292 case _OrthancPluginService_SetMetricsIntegerValue:
5293 {
5294 const _OrthancPluginSetMetricsIntegerValue& p =
5295 *reinterpret_cast<const _OrthancPluginSetMetricsIntegerValue*>(parameters);
5296
5297 {
5298 PImpl::ServerContextLock lock(*pimpl_);
5299 lock.GetContext().GetMetricsRegistry().SetValue(p.name, p.value, Plugins::Convert(p.type));
5301 } 5300 }
5302 5301
5303 return true; 5302 return true;
5304 } 5303 }
5305 5304