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
052e3b60
Commit
052e3b60
authored
May 13, 2022
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix instance getters on the metric registry
parent
1ea3128e
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
138 additions
and
70 deletions
+138
-70
CHANGELOG.md
CHANGELOG.md
+2
-0
libcaf_core/caf/telemetry/metric_registry.hpp
libcaf_core/caf/telemetry/metric_registry.hpp
+14
-29
libcaf_core/src/telemetry/metric_registry.cpp
libcaf_core/src/telemetry/metric_registry.cpp
+9
-0
libcaf_core/test/telemetry/metric_registry.cpp
libcaf_core/test/telemetry/metric_registry.cpp
+113
-41
No files found.
CHANGELOG.md
View file @
052e3b60
...
@@ -16,6 +16,8 @@ is based on [Keep a Changelog](https://keepachangelog.com).
...
@@ -16,6 +16,8 @@ is based on [Keep a Changelog](https://keepachangelog.com).
-
The JSON reader now automatically widens integers to doubles as necessary.
-
The JSON reader now automatically widens integers to doubles as necessary.
-
Module options (e.g. for the
`middleman`
) now show up in
`--long-help`
output.
-
Module options (e.g. for the
`middleman`
) now show up in
`--long-help`
output.
-
Fix undefined behavior in the Qt group chat example (#1336).
-
Fix undefined behavior in the Qt group chat example (#1336).
-
The
`..._instance`
convenience functions on the registry metric now properly
support
`double`
metrics and histograms.
### Changed
### Changed
...
...
libcaf_core/caf/telemetry/metric_registry.hpp
View file @
052e3b60
...
@@ -136,8 +136,9 @@ public:
...
@@ -136,8 +136,9 @@ public:
gauge_instance
(
std
::
string_view
prefix
,
std
::
string_view
name
,
gauge_instance
(
std
::
string_view
prefix
,
std
::
string_view
name
,
span_t
<
label_view
>
labels
,
std
::
string_view
helptext
,
span_t
<
label_view
>
labels
,
std
::
string_view
helptext
,
std
::
string_view
unit
=
"1"
,
bool
is_sum
=
false
)
{
std
::
string_view
unit
=
"1"
,
bool
is_sum
=
false
)
{
auto
fptr
=
gauge_family
<
ValueType
>
(
prefix
,
name
,
labels
,
helptext
,
unit
,
auto
label_names
=
get_label_names
(
labels
);
is_sum
);
auto
fptr
=
gauge_family
<
ValueType
>
(
prefix
,
name
,
label_names
,
helptext
,
unit
,
is_sum
);
return
fptr
->
get_or_add
(
labels
);
return
fptr
->
get_or_add
(
labels
);
}
}
...
@@ -228,27 +229,6 @@ public:
...
@@ -228,27 +229,6 @@ public:
is_sum
);
is_sum
);
}
}
/// @copydoc counter_family
template
<
class
ValueType
=
int64_t
>
metric_family_impl
<
counter
<
ValueType
>>*
counter_family
(
std
::
string_view
prefix
,
std
::
string_view
name
,
span_t
<
label_view
>
labels
,
std
::
string_view
helptext
,
std
::
string_view
unit
=
"1"
,
bool
is_sum
=
false
)
{
using
counter_type
=
counter
<
ValueType
>
;
using
family_type
=
metric_family_impl
<
counter_type
>
;
std
::
unique_lock
<
std
::
mutex
>
guard
{
families_mx_
};
if
(
auto
ptr
=
fetch
(
prefix
,
name
))
{
assert_properties
(
ptr
,
counter_type
::
runtime_type
,
labels
,
unit
,
is_sum
);
return
static_cast
<
family_type
*>
(
ptr
);
}
auto
ptr
=
std
::
make_unique
<
family_type
>
(
std
::
string
{
prefix
},
std
::
string
{
name
},
to_sorted_vec
(
labels
),
std
::
string
{
helptext
},
std
::
string
{
unit
},
is_sum
);
auto
result
=
ptr
.
get
();
families_
.
emplace_back
(
std
::
move
(
ptr
));
return
result
;
}
/// Returns a counter. Creates all objects lazily if necessary, but fails
/// Returns a counter. Creates all objects lazily if necessary, but fails
/// if the full name already belongs to a different family.
/// if the full name already belongs to a different family.
/// @param prefix The prefix (namespace) this family belongs to. Usually the
/// @param prefix The prefix (namespace) this family belongs to. Usually the
...
@@ -269,8 +249,9 @@ public:
...
@@ -269,8 +249,9 @@ public:
counter_instance
(
std
::
string_view
prefix
,
std
::
string_view
name
,
counter_instance
(
std
::
string_view
prefix
,
std
::
string_view
name
,
span_t
<
label_view
>
labels
,
std
::
string_view
helptext
,
span_t
<
label_view
>
labels
,
std
::
string_view
helptext
,
std
::
string_view
unit
=
"1"
,
bool
is_sum
=
false
)
{
std
::
string_view
unit
=
"1"
,
bool
is_sum
=
false
)
{
auto
fptr
=
counter_family
<
ValueType
>
(
prefix
,
name
,
labels
,
helptext
,
unit
,
auto
label_names
=
get_label_names
(
labels
);
is_sum
);
auto
fptr
=
counter_family
<
ValueType
>
(
prefix
,
name
,
label_names
,
helptext
,
unit
,
is_sum
);
return
fptr
->
get_or_add
(
labels
);
return
fptr
->
get_or_add
(
labels
);
}
}
...
@@ -419,8 +400,10 @@ public:
...
@@ -419,8 +400,10 @@ public:
span_t
<
label_view
>
labels
,
span_t
<
ValueType
>
upper_bounds
,
span_t
<
label_view
>
labels
,
span_t
<
ValueType
>
upper_bounds
,
std
::
string_view
helptext
,
std
::
string_view
unit
=
"1"
,
std
::
string_view
helptext
,
std
::
string_view
unit
=
"1"
,
bool
is_sum
=
false
)
{
bool
is_sum
=
false
)
{
auto
fptr
=
histogram_family
<
ValueType
>
(
prefix
,
name
,
labels
,
upper_bounds
,
auto
label_names
=
get_label_names
(
labels
);
helptext
,
unit
,
is_sum
);
auto
fptr
=
histogram_family
<
ValueType
>
(
prefix
,
name
,
label_names
,
upper_bounds
,
helptext
,
unit
,
is_sum
);
return
fptr
->
get_or_add
(
labels
);
return
fptr
->
get_or_add
(
labels
);
}
}
...
@@ -432,8 +415,8 @@ public:
...
@@ -432,8 +415,8 @@ public:
span_t
<
ValueType
>
upper_bounds
,
std
::
string_view
helptext
,
span_t
<
ValueType
>
upper_bounds
,
std
::
string_view
helptext
,
std
::
string_view
unit
=
"1"
,
bool
is_sum
=
false
)
{
std
::
string_view
unit
=
"1"
,
bool
is_sum
=
false
)
{
span_t
<
label_view
>
lbls
{
labels
.
begin
(),
labels
.
size
()};
span_t
<
label_view
>
lbls
{
labels
.
begin
(),
labels
.
size
()};
return
histogram_instance
(
prefix
,
name
,
lbls
,
upper_bounds
,
helptext
,
unit
,
return
histogram_instance
<
ValueType
>
(
prefix
,
name
,
lbls
,
upper_bounds
,
is_sum
);
helptext
,
unit
,
is_sum
);
}
}
/// Returns a histogram metric singleton, i.e., the single instance of a
/// Returns a histogram metric singleton, i.e., the single instance of a
...
@@ -489,6 +472,8 @@ private:
...
@@ -489,6 +472,8 @@ private:
metric_family
*
fetch
(
const
std
::
string_view
&
prefix
,
metric_family
*
fetch
(
const
std
::
string_view
&
prefix
,
const
std
::
string_view
&
name
);
const
std
::
string_view
&
name
);
static
std
::
vector
<
std
::
string_view
>
get_label_names
(
span_t
<
label_view
>
xs
);
static
std
::
vector
<
std
::
string
>
to_sorted_vec
(
span_t
<
std
::
string_view
>
xs
);
static
std
::
vector
<
std
::
string
>
to_sorted_vec
(
span_t
<
std
::
string_view
>
xs
);
static
std
::
vector
<
std
::
string
>
to_sorted_vec
(
span_t
<
label_view
>
xs
);
static
std
::
vector
<
std
::
string
>
to_sorted_vec
(
span_t
<
label_view
>
xs
);
...
...
libcaf_core/src/telemetry/metric_registry.cpp
View file @
052e3b60
...
@@ -63,6 +63,15 @@ metric_family* metric_registry::fetch(const std::string_view& prefix,
...
@@ -63,6 +63,15 @@ metric_family* metric_registry::fetch(const std::string_view& prefix,
return
nullptr
;
return
nullptr
;
}
}
std
::
vector
<
std
::
string_view
>
metric_registry
::
get_label_names
(
span_t
<
label_view
>
xs
)
{
std
::
vector
<
std
::
string_view
>
result
;
result
.
reserve
(
xs
.
size
());
for
(
auto
&
x
:
xs
)
result
.
push_back
(
x
.
name
());
return
result
;
}
std
::
vector
<
std
::
string
>
std
::
vector
<
std
::
string
>
metric_registry
::
to_sorted_vec
(
span
<
const
std
::
string_view
>
xs
)
{
metric_registry
::
to_sorted_vec
(
span
<
const
std
::
string_view
>
xs
)
{
std
::
vector
<
std
::
string
>
result
;
std
::
vector
<
std
::
string
>
result
;
...
...
libcaf_core/test/telemetry/metric_registry.cpp
View file @
052e3b60
This diff is collapsed.
Click to expand it.
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