Mercurial > hg > orthanc
diff Plugins/Samples/Basic/Plugin.c @ 3179:fca730c267d7
New primitives to set and refresh metrics
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 30 Jan 2019 17:12:15 +0100 |
parents | 4e43e67f8ecf |
children | 6c86d4d407da |
line wrap: on
line diff
--- a/Plugins/Samples/Basic/Plugin.c Wed Jan 30 12:41:20 2019 +0100 +++ b/Plugins/Samples/Basic/Plugin.c Wed Jan 30 17:12:15 2019 +0100 @@ -335,6 +335,8 @@ case OrthancPluginChangeType_OrthancStarted: { + OrthancPluginSetMetricsValue(context, "sample_started", 1, OrthancPluginMetricsType_Default); + /* Make REST requests to the built-in Orthanc API */ OrthancPluginRestApiGet(context, &tmp, "/changes"); OrthancPluginFreeMemoryBuffer(context, &tmp); @@ -392,6 +394,13 @@ } +ORTHANC_PLUGINS_API void RefreshMetrics() +{ + static unsigned int count = 0; + OrthancPluginSetMetricsValue(context, "sample_counter", count++, OrthancPluginMetricsType_Default); +} + + ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c) { char info[1024], *s; @@ -455,7 +464,9 @@ OrthancPluginRegisterOnStoredInstanceCallback(context, OnStoredCallback); OrthancPluginRegisterOnChangeCallback(context, OnChangeCallback); OrthancPluginRegisterIncomingHttpRequestFilter(context, FilterIncomingHttpRequest); + OrthancPluginRegisterRefreshMetricsCallback(context, RefreshMetrics); + /* Declare several properties of the plugin */ OrthancPluginSetRootUri(context, "/plugin/hello"); OrthancPluginSetDescription(context, "This is the description of the sample plugin that can be seen in Orthanc Explorer.");