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
f0a92951
Commit
f0a92951
authored
Mar 09, 2023
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Normalize label names in Prometheus output
parent
d9aca2e1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
7 deletions
+10
-7
CHANGELOG.md
CHANGELOG.md
+2
-0
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.
CHANGELOG.md
View file @
f0a92951
...
...
@@ -27,6 +27,8 @@ is based on [Keep a Changelog](https://keepachangelog.com).
### Fixed
-
When exporting metrics to Prometheus, CAF now normalizes label names to meet
the Prometheus name requirements, e.g.,
`label-1`
becomes
`label_1`
(#1386).
-
The SPSC buffer now makes sure that subscribers get informed of a producer has
already left before the subscriber appeared and vice versa. This fixes a race
on the buffer that could cause indefinite hanging of an application.
...
...
libcaf_core/src/telemetry/collector/prometheus.cpp
View file @
f0a92951
...
...
@@ -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 @
f0a92951
...
...
@@ -30,7 +30,7 @@ BEGIN_FIXTURE_SCOPE(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
);
...
...
@@ -38,8 +38,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
);
...
...
@@ -51,8 +51,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