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
server
orca
orca_interceptor.cc
Go to the documentation of this file.
1
//
2
// Copyright 2022 gRPC authors.
3
//
4
// Licensed under the Apache License, Version 2.0 (the "License");
5
// you may not use this file except in compliance with the License.
6
// You may obtain a copy of the License at
7
//
8
// http://www.apache.org/licenses/LICENSE-2.0
9
//
10
// Unless required by applicable law or agreed to in writing, software
11
// distributed under the License is distributed on an "AS IS" BASIS,
12
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
// See the License for the specific language governing permissions and
14
// limitations under the License.
15
//
16
17
#include "
src/cpp/server/orca/orca_interceptor.h
"
18
19
#include <algorithm>
20
#include <map>
21
#include <memory>
22
#include <string>
23
#include <type_traits>
24
#include <utility>
25
#include <vector>
26
27
#include "absl/memory/memory.h"
28
#include "absl/strings/string_view.h"
29
#include "absl/types/optional.h"
30
31
#include <
grpcpp/ext/call_metric_recorder.h
>
32
#include <
grpcpp/server_builder.h
>
33
#include <
grpcpp/server_context.h
>
34
#include <
grpcpp/support/config.h
>
35
36
#include "
src/core/lib/transport/metadata_batch.h
"
37
38
namespace
grpc
{
39
namespace
experimental {
40
41
void
OrcaServerInterceptor::Intercept
(
InterceptorBatchMethods
* methods) {
42
if
(methods->
QueryInterceptionHookPoint
(
43
InterceptionHookPoints::POST_RECV_INITIAL_METADATA
)) {
44
auto
context
=
info_
->
server_context
();
45
context
->CreateCallMetricRecorder();
46
}
else
if
(methods->
QueryInterceptionHookPoint
(
47
InterceptionHookPoints::PRE_SEND_STATUS
)) {
48
auto
trailers = methods->
GetSendTrailingMetadata
();
49
if
(trailers !=
nullptr
) {
50
auto
context
=
info_
->
server_context
();
51
auto
* recorder =
context
->call_metric_recorder_;
52
auto
serialized = recorder->CreateSerializedReport();
53
if
(serialized.has_value() && !serialized->empty()) {
54
std::string
key
=
55
std::string
(
grpc_core::EndpointLoadMetricsBinMetadata::key
());
56
trailers->emplace(
57
std::make_pair(
std::move
(
key
),
std::move
(serialized.value())));
58
}
59
}
60
}
61
methods->
Proceed
();
62
}
63
64
Interceptor
*
OrcaServerInterceptorFactory::CreateServerInterceptor
(
65
ServerRpcInfo
* info) {
66
return
new
OrcaServerInterceptor
(info);
67
}
68
69
void
OrcaServerInterceptorFactory::Register
(
grpc::ServerBuilder
*
builder
) {
70
builder
->internal_interceptor_creators_.push_back(
71
absl::make_unique<OrcaServerInterceptorFactory>());
72
}
73
74
void
EnableCallMetricRecording
(
grpc::ServerBuilder
*
builder
) {
75
OrcaServerInterceptorFactory::Register
(
builder
);
76
}
77
78
}
// namespace experimental
79
}
// namespace grpc
metadata_batch.h
grpc
Definition:
grpcpp/alarm.h:33
grpc::experimental::InterceptionHookPoints::POST_RECV_INITIAL_METADATA
@ POST_RECV_INITIAL_METADATA
The following two are for all clients and servers.
testing::internal::string
::std::string string
Definition:
bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
grpc::experimental::ServerRpcInfo::server_context
ServerContextBase * server_context()
Definition:
impl/codegen/server_interceptor.h:81
grpc::experimental::InterceptorBatchMethods::QueryInterceptionHookPoint
virtual bool QueryInterceptionHookPoint(InterceptionHookPoints type)=0
grpc::experimental::InterceptionHookPoints::PRE_SEND_STATUS
@ PRE_SEND_STATUS
profile_analyzer.builder
builder
Definition:
profile_analyzer.py:159
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition:
abseil-cpp/absl/utility/utility.h:221
grpc::ServerBuilder
A builder class for the creation and startup of grpc::Server instances.
Definition:
grpcpp/server_builder.h:86
grpc::experimental::InterceptorBatchMethods::GetSendTrailingMetadata
virtual std::multimap< std::string, std::string > * GetSendTrailingMetadata()=0
grpc::experimental::OrcaServerInterceptor
Definition:
orca_interceptor.h:30
grpc_core::EndpointLoadMetricsBinMetadata::key
static absl::string_view key()
Definition:
metadata_batch.h:234
call_metric_recorder.h
grpc::experimental::OrcaServerInterceptorFactory::Register
static void Register(ServerBuilder *builder)
Definition:
orca_interceptor.cc:69
config.h
grpc::experimental::InterceptorBatchMethods
Definition:
impl/codegen/interceptor.h:98
grpc::experimental::OrcaServerInterceptor::info_
ServerRpcInfo * info_
Definition:
orca_interceptor.h:37
grpc::experimental::OrcaServerInterceptorFactory::CreateServerInterceptor
Interceptor * CreateServerInterceptor(ServerRpcInfo *info) override
Definition:
orca_interceptor.cc:64
key
const char * key
Definition:
hpack_parser_table.cc:164
grpc::experimental::EnableCallMetricRecording
void EnableCallMetricRecording(ServerBuilder *)
Definition:
orca_interceptor.cc:74
grpc::experimental::Interceptor
Definition:
impl/codegen/interceptor.h:221
server_context.h
grpc::experimental::ServerRpcInfo
Definition:
impl/codegen/server_interceptor.h:58
grpc::experimental::OrcaServerInterceptor::Intercept
void Intercept(InterceptorBatchMethods *methods) override
Definition:
orca_interceptor.cc:41
context
grpc::ClientContext context
Definition:
istio_echo_server_lib.cc:61
grpc::experimental::InterceptorBatchMethods::Proceed
virtual void Proceed()=0
orca_interceptor.h
server_builder.h
grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:46