Mercurial > hg > orthanc
annotate OrthancFramework/Sources/MetricsRegistry.h @ 5581:4ad301c35f6e find-refactoring
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 27 Apr 2024 15:02:24 +0200 |
parents | 48b8dae6dc77 |
children | f7adfb22e20e |
rev | line source |
---|---|
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5337
diff
changeset
|
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium |
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5337
diff
changeset
|
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * This program is free software: you can redistribute it and/or |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
10 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
11 * the License, or (at your option) any later version. |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, but |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
16 * Lesser General Public License for more details. |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
19 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
20 * <http://www.gnu.org/licenses/>. |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 **/ |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #pragma once |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
26 #include "OrthancFramework.h" |
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
27 |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 #if !defined(ORTHANC_SANDBOXED) |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 # error The macro ORTHANC_SANDBOXED must be defined |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 #endif |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 #if ORTHANC_SANDBOXED == 1 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 # error The class MetricsRegistry cannot be used in sandboxed environments |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 #endif |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 #include <boost/thread/mutex.hpp> |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 #include <boost/date_time/posix_time/posix_time.hpp> |
5326
fbe857e942cd
store metrics as integers instead of floats to avoid precision loss in increments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5325
diff
changeset
|
38 #include <stdint.h> |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 namespace Orthanc |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 { |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
42 enum MetricsUpdatePolicy |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 { |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
44 MetricsUpdatePolicy_Directly, |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
45 MetricsUpdatePolicy_MaxOver10Seconds, |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
46 MetricsUpdatePolicy_MaxOver1Minute, |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
47 MetricsUpdatePolicy_MinOver10Seconds, |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
48 MetricsUpdatePolicy_MinOver1Minute |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
49 }; |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
50 |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
51 enum MetricsDataType |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
52 { |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
53 MetricsDataType_Float, |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
54 MetricsDataType_Integer |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 }; |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
57 class ORTHANC_PUBLIC MetricsRegistry : public boost::noncopyable |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 { |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 private: |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 class Item; |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
61 class FloatItem; |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
62 class IntegerItem; |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 typedef std::map<std::string, Item*> Content; |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 bool enabled_; |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 boost::mutex mutex_; |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 Content content_; |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 |
5325
9c00e832985f
refactoring MetricsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
70 // The mutex must be locked |
9c00e832985f
refactoring MetricsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
71 Item& GetItemInternal(const std::string& name, |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
72 MetricsUpdatePolicy policy, |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
73 MetricsDataType type); |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 public: |
4300 | 76 MetricsRegistry(); |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 ~MetricsRegistry(); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 |
4300 | 80 bool IsEnabled() const; |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 void SetEnabled(bool enabled); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 void Register(const std::string& name, |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
85 MetricsUpdatePolicy policy, |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
86 MetricsDataType type); |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
88 void SetFloatValue(const std::string& name, |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
89 float value, |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
90 MetricsUpdatePolicy policy /* only used if this is a new metrics */); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
91 |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
92 void SetFloatValue(const std::string& name, |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
93 float value) |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
94 { |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
95 SetFloatValue(name, value, MetricsUpdatePolicy_Directly); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
96 } |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
98 void SetIntegerValue(const std::string& name, |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
99 int64_t value, |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
100 MetricsUpdatePolicy policy /* only used if this is a new metrics */); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
101 |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
102 void SetIntegerValue(const std::string& name, |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
103 int64_t value) |
5325
9c00e832985f
refactoring MetricsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
104 { |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
105 SetIntegerValue(name, value, MetricsUpdatePolicy_Directly); |
5325
9c00e832985f
refactoring MetricsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
106 } |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
107 |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
108 void IncrementIntegerValue(const std::string& name, |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
109 int64_t delta); |
5325
9c00e832985f
refactoring MetricsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
110 |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
111 MetricsUpdatePolicy GetUpdatePolicy(const std::string& metrics); |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
113 MetricsDataType GetDataType(const std::string& metrics); |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 // https://prometheus.io/docs/instrumenting/exposition_formats/#text-based-format |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 void ExportPrometheusText(std::string& s); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 |
4026
05a363186da6
ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3992
diff
changeset
|
119 class ORTHANC_PUBLIC SharedMetrics : public boost::noncopyable |
3176
784bbb03fb54
new metrics: orthanc_rest_api_active_requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
120 { |
784bbb03fb54
new metrics: orthanc_rest_api_active_requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
121 private: |
784bbb03fb54
new metrics: orthanc_rest_api_active_requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
122 boost::mutex mutex_; |
784bbb03fb54
new metrics: orthanc_rest_api_active_requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
123 MetricsRegistry& registry_; |
784bbb03fb54
new metrics: orthanc_rest_api_active_requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
124 std::string name_; |
5326
fbe857e942cd
store metrics as integers instead of floats to avoid precision loss in increments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5325
diff
changeset
|
125 int64_t value_; |
3176
784bbb03fb54
new metrics: orthanc_rest_api_active_requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
126 |
784bbb03fb54
new metrics: orthanc_rest_api_active_requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
127 public: |
784bbb03fb54
new metrics: orthanc_rest_api_active_requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
128 SharedMetrics(MetricsRegistry& registry, |
784bbb03fb54
new metrics: orthanc_rest_api_active_requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
129 const std::string& name, |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
130 MetricsUpdatePolicy policy); |
3176
784bbb03fb54
new metrics: orthanc_rest_api_active_requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
131 |
5326
fbe857e942cd
store metrics as integers instead of floats to avoid precision loss in increments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5325
diff
changeset
|
132 void Add(int64_t delta); |
3176
784bbb03fb54
new metrics: orthanc_rest_api_active_requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
133 }; |
784bbb03fb54
new metrics: orthanc_rest_api_active_requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
134 |
784bbb03fb54
new metrics: orthanc_rest_api_active_requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
135 |
4026
05a363186da6
ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3992
diff
changeset
|
136 class ORTHANC_PUBLIC ActiveCounter : public boost::noncopyable |
3176
784bbb03fb54
new metrics: orthanc_rest_api_active_requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
137 { |
784bbb03fb54
new metrics: orthanc_rest_api_active_requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
138 private: |
784bbb03fb54
new metrics: orthanc_rest_api_active_requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
139 SharedMetrics& metrics_; |
784bbb03fb54
new metrics: orthanc_rest_api_active_requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
140 |
784bbb03fb54
new metrics: orthanc_rest_api_active_requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
141 public: |
4300 | 142 explicit ActiveCounter(SharedMetrics& metrics); |
3176
784bbb03fb54
new metrics: orthanc_rest_api_active_requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
143 |
4300 | 144 ~ActiveCounter(); |
3176
784bbb03fb54
new metrics: orthanc_rest_api_active_requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
145 }; |
784bbb03fb54
new metrics: orthanc_rest_api_active_requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
146 |
784bbb03fb54
new metrics: orthanc_rest_api_active_requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
147 |
4026
05a363186da6
ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3992
diff
changeset
|
148 class ORTHANC_PUBLIC Timer : public boost::noncopyable |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 { |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 private: |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 MetricsRegistry& registry_; |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 std::string name_; |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
153 MetricsUpdatePolicy policy_; |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 bool active_; |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 boost::posix_time::ptime start_; |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 void Start(); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 public: |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 Timer(MetricsRegistry& registry, |
4300 | 161 const std::string& name); |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 Timer(MetricsRegistry& registry, |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 const std::string& name, |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
165 MetricsUpdatePolicy policy); |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 ~Timer(); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 }; |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 }; |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 } |