Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
af7a3220
Commit
af7a3220
authored
Dec 06, 2018
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add IsComplete() to SummaryItems
parent
e8d15401
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
21 deletions
+19
-21
prometheus_metrics_service.cpp
src/brpc/builtin/prometheus_metrics_service.cpp
+19
-21
No files found.
src/brpc/builtin/prometheus_metrics_service.cpp
View file @
af7a3220
...
...
@@ -64,13 +64,11 @@ private:
std
::
string
latency_avg
;
std
::
string
count
;
std
::
string
metric_name
;
bool
IsComplete
()
const
{
return
!
metric_name
.
empty
();
}
};
// Return true iff name ends with suffix output by LatencyRecorder.
// If all bvars in LatencyRecorder have been gathered and are ready
// to output a summary, *si_out is set properly.
bool
ProcessLatencyRecorderSuffix
(
const
butil
::
StringPiece
&
name
,
const
butil
::
StringPiece
&
desc
,
SummaryItems
**
si_out
);
const
SummaryItems
*
ProcessLatencyRecorderSuffix
(
const
butil
::
StringPiece
&
name
,
const
butil
::
StringPiece
&
desc
);
private
:
butil
::
IOBufBuilder
*
_os
;
...
...
@@ -95,10 +93,9 @@ bool PrometheusMetricsDumper::dump(const std::string& name,
return
true
;
}
bool
PrometheusMetricsDumper
::
ProcessLatencyRecorderSuffix
(
const
butil
::
StringPiece
&
name
,
const
butil
::
StringPiece
&
desc
,
PrometheusMetricsDumper
::
SummaryItems
**
si_out
)
{
const
PrometheusMetricsDumper
::
SummaryItems
*
PrometheusMetricsDumper
::
ProcessLatencyRecorderSuffix
(
const
butil
::
StringPiece
&
name
,
const
butil
::
StringPiece
&
desc
)
{
static
std
::
string
latency_names
[]
=
{
butil
::
string_printf
(
"_latency_%d"
,
(
int
)
bvar
::
FLAGS_bvar_latency_p1
),
butil
::
string_printf
(
"_latency_%d"
,
(
int
)
bvar
::
FLAGS_bvar_latency_p2
),
...
...
@@ -115,26 +112,27 @@ bool PrometheusMetricsDumper::ProcessLatencyRecorderSuffix(
SummaryItems
*
si
=
&
_m
[
metric_name
.
as_string
()];
si
->
latency_percentiles
[
i
]
=
desc
.
as_string
();
if
(
i
==
NPERCENTILES
-
1
)
{
// 'max_latency' is the last suffix name that appear in the sorted bvar
// '
_
max_latency' is the last suffix name that appear in the sorted bvar
// list, which means all related percentiles have been gathered and we are
// ready to output a Summary.
si
->
metric_name
=
metric_name
.
as_string
();
*
si_out
=
si
;
}
return
true
;
return
si
;
}
// Get the average of latency in recent window size
if
(
metric_name
.
ends_with
(
"_latency"
))
{
metric_name
.
remove_suffix
(
8
);
_m
[
metric_name
.
as_string
()].
latency_avg
=
desc
.
as_string
();
return
true
;
SummaryItems
*
si
=
&
_m
[
metric_name
.
as_string
()];
si
->
latency_avg
=
desc
.
as_string
();
return
si
;
}
if
(
metric_name
.
ends_with
(
"_count"
))
{
metric_name
.
remove_suffix
(
6
);
_m
[
metric_name
.
as_string
()].
count
=
desc
.
as_string
();
return
true
;
SummaryItems
*
si
=
&
_m
[
metric_name
.
as_string
()];
si
->
count
=
desc
.
as_string
();
return
si
;
}
return
false
;
return
NULL
;
}
bool
PrometheusMetricsDumper
::
DumpLatencyRecorderSuffix
(
...
...
@@ -143,11 +141,11 @@ bool PrometheusMetricsDumper::DumpLatencyRecorderSuffix(
if
(
!
name
.
starts_with
(
_server_prefix
))
{
return
false
;
}
SummaryItems
*
si
=
NULL
;
if
(
!
ProcessLatencyRecorderSuffix
(
name
,
desc
,
&
si
)
)
{
const
SummaryItems
*
si
=
ProcessLatencyRecorderSuffix
(
name
,
desc
)
;
if
(
!
si
)
{
return
false
;
}
if
(
!
si
)
{
if
(
!
si
->
IsComplete
()
)
{
return
true
;
}
*
_os
<<
"# HELP "
<<
si
->
metric_name
<<
'\n'
...
...
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