Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
515c1459
Commit
515c1459
authored
Jun 17, 2020
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use counters for histograms
parent
32c4f24d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
11 deletions
+14
-11
libcaf_core/caf/telemetry/histogram.hpp
libcaf_core/caf/telemetry/histogram.hpp
+7
-4
libcaf_core/src/actor_registry.cpp
libcaf_core/src/actor_registry.cpp
+1
-1
libcaf_core/src/telemetry/collector/prometheus.cpp
libcaf_core/src/telemetry/collector/prometheus.cpp
+2
-2
libcaf_core/test/telemetry/histogram.cpp
libcaf_core/test/telemetry/histogram.cpp
+4
-4
No files found.
libcaf_core/caf/telemetry/histogram.hpp
View file @
515c1459
...
...
@@ -24,6 +24,7 @@
#include "caf/config.hpp"
#include "caf/fwd.hpp"
#include "caf/span.hpp"
#include "caf/telemetry/counter.hpp"
#include "caf/telemetry/gauge.hpp"
#include "caf/telemetry/metric_type.hpp"
...
...
@@ -39,11 +40,13 @@ public:
using
gauge_type
=
gauge
<
value_type
>
;
using
counter_type
=
counter
<
value_type
>
;
using
family_setting
=
std
::
vector
<
value_type
>
;
struct
bucket_type
{
value_type
upper_bound
;
gauge_type
gauge
;
counter_type
count
;
};
// -- constants --------------------------------------------------------------
...
...
@@ -85,11 +88,11 @@ public:
void
observe
(
value_type
value
)
{
// The last bucket has an upper bound of +inf or int_max, so we'll always
// find a bucket and increment the
gauge
s.
// find a bucket and increment the
counter
s.
for
(
size_t
index
=
0
;;
++
index
)
{
auto
&
[
upper_bound
,
gauge
]
=
buckets_
[
index
];
auto
&
[
upper_bound
,
count
]
=
buckets_
[
index
];
if
(
value
<=
upper_bound
)
{
gauge
.
inc
();
count
.
inc
();
sum_
.
inc
(
value
);
return
;
}
...
...
libcaf_core/src/actor_registry.cpp
View file @
515c1459
...
...
@@ -50,7 +50,7 @@ actor_registry::~actor_registry() {
actor_registry
::
actor_registry
(
actor_system
&
sys
)
:
system_
(
sys
)
{
running_
=
sys
.
telemetry
().
gauge_singleton
(
"caf"
,
"running
_
actors"
,
"Number of currently running actors."
);
"caf"
,
"running
-
actors"
,
"Number of currently running actors."
);
}
strong_actor_ptr
actor_registry
::
get_impl
(
actor_id
key
)
const
{
...
...
libcaf_core/src/telemetry/collector/prometheus.cpp
View file @
515c1459
...
...
@@ -290,10 +290,10 @@ void prometheus::append_histogram(const metric_family* family,
auto
buckets
=
val
->
buckets
();
size_t
index
=
0
;
for
(;
index
<
buckets
.
size
()
-
1
;
++
index
)
{
append
(
buf_
,
vm
[
index
],
buckets
[
index
].
gauge
.
value
(),
' '
,
append
(
buf_
,
vm
[
index
],
buckets
[
index
].
count
.
value
(),
' '
,
ms_timestamp
{
now_
},
'\n'
);
}
auto
count
=
buckets
[
index
].
gauge
.
value
();
auto
count
=
buckets
[
index
].
count
.
value
();
append
(
buf_
,
vm
[
index
],
count
,
' '
,
ms_timestamp
{
now_
},
'\n'
);
append
(
buf_
,
vm
[
++
index
],
val
->
sum
(),
' '
,
ms_timestamp
{
now_
},
'\n'
);
append
(
buf_
,
vm
[
++
index
],
count
,
' '
,
ms_timestamp
{
now_
},
'\n'
);
...
...
libcaf_core/test/telemetry/histogram.cpp
View file @
515c1459
...
...
@@ -53,9 +53,9 @@ CAF_TEST(histograms aggregate to buckets and keep a sum) {
h1
.
observe
(
value
);
auto
buckets
=
h1
.
buckets
();
CAF_REQUIRE_EQUAL
(
buckets
.
size
(),
4u
);
CAF_CHECK_EQUAL
(
buckets
[
0
].
gauge
.
value
(),
2
);
// 1, 2
CAF_CHECK_EQUAL
(
buckets
[
1
].
gauge
.
value
(),
2
);
// 3, 4
CAF_CHECK_EQUAL
(
buckets
[
2
].
gauge
.
value
(),
4
);
// 5, 6, 7, 8
CAF_CHECK_EQUAL
(
buckets
[
3
].
gauge
.
value
(),
2
);
// 9, 10
CAF_CHECK_EQUAL
(
buckets
[
0
].
count
.
value
(),
2
);
// 1, 2
CAF_CHECK_EQUAL
(
buckets
[
1
].
count
.
value
(),
2
);
// 3, 4
CAF_CHECK_EQUAL
(
buckets
[
2
].
count
.
value
(),
4
);
// 5, 6, 7, 8
CAF_CHECK_EQUAL
(
buckets
[
3
].
count
.
value
(),
2
);
// 9, 10
CAF_CHECK_EQUAL
(
h1
.
sum
(),
55
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment