Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
z
Enumerations
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
z
Classes
Class List
Class Hierarchy
Class Members
All
:
[
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
[
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
Enumerations
a
b
c
d
e
f
h
i
k
l
m
n
o
p
r
s
t
u
v
w
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
Properties
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Related Functions
:
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
grpc
src
cpp
util
core_stats.cc
Go to the documentation of this file.
1
/*
2
*
3
* Copyright 2017 gRPC authors.
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*
17
*/
18
19
#include "
src/cpp/util/core_stats.h
"
20
21
#include <
string.h
>
22
23
#include <string>
24
25
#include <
grpc/support/atm.h
>
26
#include <
grpc/support/log.h
>
27
28
#include "
src/core/lib/debug/stats_data.h
"
29
30
// IWYU pragma: no_include <google/protobuf/repeated_ptr_field.h>
31
32
using
grpc::core::Bucket;
33
using
grpc::core::Histogram
;
34
using
grpc::core::Metric
;
35
using
grpc::core::Stats;
36
37
namespace
grpc
{
38
39
void
CoreStatsToProto
(
const
grpc_stats_data
& core, Stats* proto) {
40
for
(
int
i
= 0;
i
<
GRPC_STATS_COUNTER_COUNT
;
i
++) {
41
Metric
*
m
= proto->add_metrics();
42
m
->set_name(
grpc_stats_counter_name
[
i
]);
43
m
->set_count(core.
counters
[
i
]);
44
}
45
for
(
int
i
= 0;
i
<
GRPC_STATS_HISTOGRAM_COUNT
;
i
++) {
46
Metric
*
m
= proto->add_metrics();
47
m
->set_name(
grpc_stats_histogram_name
[
i
]);
48
Histogram
* h =
m
->mutable_histogram();
49
for
(
int
j = 0; j <
grpc_stats_histo_buckets
[
i
]; j++) {
50
Bucket*
b
= h->add_buckets();
51
b
->set_start(
grpc_stats_histo_bucket_boundaries
[
i
][j]);
52
b
->set_count(core.
histograms
[
grpc_stats_histo_start
[
i
] + j]);
53
}
54
}
55
}
56
57
void
ProtoToCoreStats
(
const
grpc::core::Stats& proto,
grpc_stats_data
* core) {
58
memset
(core, 0,
sizeof
(*core));
59
for
(
const
auto
&
m
: proto.metrics()) {
60
switch
(
m
.value_case()) {
61
case
Metric::VALUE_NOT_SET:
62
break
;
63
case
Metric::kCount:
64
for
(
int
i
= 0;
i
<
GRPC_STATS_COUNTER_COUNT
;
i
++) {
65
if
(
m
.name() ==
grpc_stats_counter_name
[
i
]) {
66
core->
counters
[
i
] =
m
.count();
67
break
;
68
}
69
}
70
break
;
71
case
Metric::kHistogram:
72
for
(
int
i
= 0;
i
<
GRPC_STATS_HISTOGRAM_COUNT
;
i
++) {
73
if
(
m
.name() ==
grpc_stats_histogram_name
[
i
]) {
74
const
auto
& h =
m
.histogram();
75
bool
valid
=
true
;
76
if
(
grpc_stats_histo_buckets
[
i
] != h.buckets_size())
valid
=
false
;
77
for
(
int
j = 0;
valid
&& j < h.buckets_size(); j++) {
78
if
(
grpc_stats_histo_bucket_boundaries
[
i
][j] !=
79
h.buckets(j).start()) {
80
valid
=
false
;
81
}
82
}
83
if
(!
valid
) {
84
gpr_log
(
GPR_ERROR
,
85
"Found histogram %s but shape is different from proto"
,
86
m
.name().c_str());
87
}
88
for
(
int
j = 0;
valid
&& j < h.buckets_size(); j++) {
89
core->
histograms
[
grpc_stats_histo_start
[
i
] + j] =
90
h.buckets(j).count();
91
}
92
}
93
}
94
break
;
95
}
96
}
97
}
98
99
}
// namespace grpc
stats_data.h
log.h
memset
return memset(p, 0, total)
grpc_stats_histo_buckets
const int grpc_stats_histo_buckets[13]
Definition:
stats_data.cc:663
grpc
Definition:
grpcpp/alarm.h:33
GRPC_STATS_HISTOGRAM_COUNT
@ GRPC_STATS_HISTOGRAM_COUNT
Definition:
stats_data.h:142
string.h
grpc::ProtoToCoreStats
void ProtoToCoreStats(const grpc::core::Stats &proto, grpc_stats_data *core)
Definition:
core_stats.cc:57
grpc_stats_counter_name
const char * grpc_stats_counter_name[GRPC_STATS_COUNTER_COUNT]
Definition:
stats_data.cc:30
grpc_stats_data::counters
gpr_atm counters[GRPC_STATS_COUNTER_COUNT]
Definition:
src/core/lib/debug/stats.h:34
core_stats.h
performance.massage_qps_stats_helpers.Histogram
Histogram
Definition:
massage_qps_stats_helpers.py:51
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
grpc_stats_data::histograms
gpr_atm histograms[GRPC_STATS_HISTOGRAM_BUCKETS]
Definition:
src/core/lib/debug/stats.h:35
valid
@ valid
Definition:
base64_test.cc:37
opencensus.proto.metrics.v1.metrics_pb2.Metric
Metric
Definition:
metrics_pb2.py:787
grpc_stats_histo_start
const int grpc_stats_histo_start[13]
Definition:
stats_data.cc:665
GPR_ERROR
#define GPR_ERROR
Definition:
include/grpc/impl/codegen/log.h:57
b
uint64_t b
Definition:
abseil-cpp/absl/container/internal/layout_test.cc:53
grpc_stats_histogram_name
const char * grpc_stats_histogram_name[GRPC_STATS_HISTOGRAM_COUNT]
Definition:
stats_data.cc:254
grpc::CoreStatsToProto
void CoreStatsToProto(const grpc_stats_data &core, Stats *proto)
Definition:
core_stats.cc:39
grpc_stats_data
Definition:
src/core/lib/debug/stats.h:33
GRPC_STATS_COUNTER_COUNT
@ GRPC_STATS_COUNTER_COUNT
Definition:
stats_data.h:124
atm.h
regress.m
m
Definition:
regress/regress.py:25
i
uint64_t i
Definition:
abseil-cpp/absl/container/btree_benchmark.cc:230
grpc_stats_histo_bucket_boundaries
const int *const grpc_stats_histo_bucket_boundaries[13]
Definition:
stats_data.cc:667
grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:57