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
4a9a8f60
Commit
4a9a8f60
authored
Mar 09, 2023
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Normalize label names in Prometheus output
(cherry picked from commit
f0a92951
)
parent
c649baa6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
7 deletions
+8
-7
libcaf_core/src/telemetry/collector/prometheus.cpp
libcaf_core/src/telemetry/collector/prometheus.cpp
+3
-2
libcaf_core/test/telemetry/collector/prometheus.cpp
libcaf_core/test/telemetry/collector/prometheus.cpp
+5
-5
No files found.
libcaf_core/src/telemetry/collector/prometheus.cpp
View file @
4a9a8f60
...
...
@@ -144,9 +144,10 @@ void append(prometheus::char_buffer& buf, const std::vector<label>& labels,
if
(
!
labels
.
empty
())
{
append
(
buf
,
'{'
);
auto
i
=
labels
.
begin
();
append
(
buf
,
i
->
name
()
,
"=
\"
"
_sv
,
i
->
value
(),
'"'
);
append
(
buf
,
separator_to_underline
{
i
->
name
()}
,
"=
\"
"
_sv
,
i
->
value
(),
'"'
);
while
(
++
i
!=
labels
.
end
())
append
(
buf
,
','
,
i
->
name
(),
"=
\"
"
,
i
->
value
(),
'"'
);
append
(
buf
,
','
,
separator_to_underline
{
i
->
name
()},
"=
\"
"
_sv
,
i
->
value
(),
'"'
);
append
(
buf
,
'}'
);
}
append
(
buf
,
std
::
forward
<
Ts
>
(
xs
)...);
...
...
libcaf_core/test/telemetry/collector/prometheus.cpp
View file @
4a9a8f60
...
...
@@ -31,7 +31,7 @@ CAF_TEST_FIXTURE_SCOPE(prometheus_tests, fixture)
CAF_TEST
(
the
Prometheus
collector
generates
text
output
)
{
auto
fb
=
registry
.
gauge_family
(
"foo"
,
"bar"
,
{},
"Some value without labels."
,
"seconds"
);
auto
sv
=
registry
.
gauge_family
(
"some"
,
"value"
,
{
"
a"
,
"b
"
},
auto
sv
=
registry
.
gauge_family
(
"some"
,
"value"
,
{
"
label-1"
,
"label-2
"
},
"Some (total) value with two labels."
,
"1"
,
true
);
auto
ov
=
registry
.
gauge_family
(
"other"
,
"value"
,
{
"x"
},
""
,
"seconds"
,
true
);
...
...
@@ -39,8 +39,8 @@ CAF_TEST(the Prometheus collector generates text output) {
auto
sr
=
registry
.
histogram_family
(
"some"
,
"request-duration"
,
{
"x"
},
upper_bounds
,
"Some help."
,
"seconds"
);
fb
->
get_or_add
({})
->
value
(
123
);
sv
->
get_or_add
({{
"
a"
,
"1"
},
{
"b
"
,
"2"
}})
->
value
(
12
);
sv
->
get_or_add
({{
"
b"
,
"1"
},
{
"a
"
,
"2"
}})
->
value
(
21
);
sv
->
get_or_add
({{
"
label-1"
,
"1"
},
{
"label-2
"
,
"2"
}})
->
value
(
12
);
sv
->
get_or_add
({{
"
label-2"
,
"1"
},
{
"label-1
"
,
"2"
}})
->
value
(
21
);
ov
->
get_or_add
({{
"x"
,
"true"
}})
->
value
(
31337
);
auto
h
=
sr
->
get_or_add
({{
"x"
,
"get"
}});
h
->
observe
(
3
);
...
...
@@ -52,8 +52,8 @@ CAF_TEST(the Prometheus collector generates text output) {
foo_bar_seconds 123 42000
# HELP some_value_total Some (total) value with two labels.
# TYPE some_value_total gauge
some_value_total{
a="1",b
="2"} 12 42000
some_value_total{
a="2",b
="1"} 21 42000
some_value_total{
label_1="1",label_2
="2"} 12 42000
some_value_total{
label_1="2",label_2
="1"} 21 42000
# TYPE other_value_seconds_total gauge
other_value_seconds_total{x="true"} 31337 42000
# HELP some_request_duration_seconds Some help.
...
...
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