call_log_batch.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 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 
20 
21 #include <inttypes.h>
22 #include <stddef.h>
23 
24 #include <algorithm>
25 #include <string>
26 #include <vector>
27 
28 #include "absl/strings/str_format.h"
29 #include "absl/strings/str_join.h"
30 #include "absl/strings/string_view.h"
31 
33 #include <grpc/support/alloc.h>
34 #include <grpc/support/log.h>
35 
40 
41 static void add_metadata(const grpc_metadata* md, size_t count,
42  std::vector<std::string>* b) {
43  if (md == nullptr) {
44  b->push_back("(nil)");
45  return;
46  }
47  for (size_t i = 0; i < count; i++) {
48  b->push_back("\nkey=");
50  b->push_back(" value=");
52  b->push_back(dump);
53  gpr_free(dump);
54  }
55 }
56 
58  std::vector<std::string> parts;
59  switch (op->op) {
61  parts.push_back("SEND_INITIAL_METADATA");
64  break;
66  parts.push_back(absl::StrFormat("SEND_MESSAGE ptr=%p",
68  break;
70  parts.push_back("SEND_CLOSE_FROM_CLIENT");
71  break;
73  parts.push_back(
74  absl::StrFormat("SEND_STATUS_FROM_SERVER status=%d details=",
77  char* dump = grpc_dump_slice(
79  parts.push_back(dump);
80  gpr_free(dump);
81  } else {
82  parts.push_back("(null)");
83  }
86  &parts);
87  break;
89  parts.push_back(absl::StrFormat(
90  "RECV_INITIAL_METADATA ptr=%p",
92  break;
94  parts.push_back(absl::StrFormat("RECV_MESSAGE ptr=%p",
96  break;
98  parts.push_back(absl::StrFormat(
99  "RECV_STATUS_ON_CLIENT metadata=%p status=%p details=%p",
103  break;
105  parts.push_back(absl::StrFormat("RECV_CLOSE_ON_SERVER cancelled=%p",
107  }
108  return absl::StrJoin(parts, "");
109 }
110 
112  const grpc_op* ops, size_t nops) {
113  for (size_t i = 0; i < nops; i++) {
114  gpr_log(file, line, severity, "ops[%" PRIuPTR "]: %s", i,
115  grpc_op_string(&ops[i]).c_str());
116  }
117 }
grpc_op::grpc_op_data::grpc_op_send_message::send_message
struct grpc_byte_buffer * send_message
Definition: grpc_types.h:668
grpc_op::grpc_op_data::grpc_op_recv_status_on_client::trailing_metadata
grpc_metadata_array * trailing_metadata
Definition: grpc_types.h:701
log.h
bloat_diff.severity
def severity
Definition: bloat_diff.py:143
grpc_op::grpc_op_data::grpc_op_recv_status_on_client::status
grpc_status_code * status
Definition: grpc_types.h:702
absl::StrFormat
ABSL_MUST_USE_RESULT std::string StrFormat(const FormatSpec< Args... > &format, const Args &... args)
Definition: abseil-cpp/absl/strings/str_format.h:338
grpc_dump_slice
char * grpc_dump_slice(const grpc_slice &s, uint32_t flags)
Definition: slice_string_helpers.cc:25
grpc_op::grpc_op_data::send_initial_metadata
struct grpc_op::grpc_op_data::grpc_op_send_initial_metadata send_initial_metadata
string.h
grpc_core::StringViewFromSlice
absl::string_view StringViewFromSlice(const grpc_slice &slice)
Definition: slice_internal.h:93
gpr_free
GPRAPI void gpr_free(void *ptr)
Definition: alloc.cc:51
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
file
Definition: bloaty/third_party/zlib/examples/gzappend.c:170
GPR_DUMP_HEX
#define GPR_DUMP_HEX
Definition: string.h:34
GPR_DUMP_ASCII
#define GPR_DUMP_ASCII
Definition: string.h:35
grpc_op::grpc_op_data::recv_message
struct grpc_op::grpc_op_data::grpc_op_recv_message recv_message
grpc_op::data
union grpc_op::grpc_op_data data
gpr_log_severity
gpr_log_severity
Definition: include/grpc/impl/codegen/log.h:45
grpc_types.h
grpc_op::grpc_op_data::grpc_op_recv_message::recv_message
struct grpc_byte_buffer ** recv_message
Definition: grpc_types.h:693
grpc_metadata
Definition: grpc_types.h:537
GRPC_OP_RECV_INITIAL_METADATA
@ GRPC_OP_RECV_INITIAL_METADATA
Definition: grpc_types.h:617
absl::StrJoin
std::string StrJoin(Iterator start, Iterator end, absl::string_view sep, Formatter &&fmt)
Definition: abseil-cpp/absl/strings/str_join.h:239
GRPC_OP_SEND_STATUS_FROM_SERVER
@ GRPC_OP_SEND_STATUS_FROM_SERVER
Definition: grpc_types.h:612
gen_stats_data.c_str
def c_str(s, encoding='ascii')
Definition: gen_stats_data.py:38
grpc_op::grpc_op_data::grpc_op_send_status_from_server::status
grpc_status_code status
Definition: grpc_types.h:673
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
grpc_op
Definition: grpc_types.h:640
GRPC_OP_SEND_MESSAGE
@ GRPC_OP_SEND_MESSAGE
Definition: grpc_types.h:602
grpc_op::grpc_op_data::grpc_op_send_status_from_server::trailing_metadata
grpc_metadata * trailing_metadata
Definition: grpc_types.h:672
slice_internal.h
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
grpc_op::op
grpc_op_type op
Definition: grpc_types.h:642
grpc_op::grpc_op_data::grpc_op_send_initial_metadata::count
size_t count
Definition: grpc_types.h:653
grpc_op::grpc_op_data::grpc_op_recv_status_on_client::status_details
grpc_slice * status_details
Definition: grpc_types.h:703
value
const char * value
Definition: hpack_parser_table.cc:165
grpc_op::grpc_op_data::recv_close_on_server
struct grpc_op::grpc_op_data::grpc_op_recv_close_on_server recv_close_on_server
GRPC_OP_RECV_MESSAGE
@ GRPC_OP_RECV_MESSAGE
Definition: grpc_types.h:621
benchmark.md
md
Definition: benchmark.py:86
grpc_op_string
static std::string grpc_op_string(const grpc_op *op)
Definition: call_log_batch.cc:57
grpc_op::grpc_op_data::send_status_from_server
struct grpc_op::grpc_op_data::grpc_op_send_status_from_server send_status_from_server
key
const char * key
Definition: hpack_parser_table.cc:164
count
int * count
Definition: bloaty/third_party/googletest/googlemock/test/gmock_stress_test.cc:96
GRPC_OP_SEND_INITIAL_METADATA
@ GRPC_OP_SEND_INITIAL_METADATA
Definition: grpc_types.h:598
grpc_op::grpc_op_data::send_message
struct grpc_op::grpc_op_data::grpc_op_send_message send_message
add_metadata
static void add_metadata(const grpc_metadata *md, size_t count, std::vector< std::string > *b)
Definition: call_log_batch.cc:41
alloc.h
grpc_op::grpc_op_data::grpc_op_send_initial_metadata::metadata
grpc_metadata * metadata
Definition: grpc_types.h:654
grpc_op::grpc_op_data::recv_status_on_client
struct grpc_op::grpc_op_data::grpc_op_recv_status_on_client recv_status_on_client
grpc_op::grpc_op_data::grpc_op_send_status_from_server::trailing_metadata_count
size_t trailing_metadata_count
Definition: grpc_types.h:671
grpc_call_log_batch
void grpc_call_log_batch(const char *file, int line, gpr_log_severity severity, const grpc_op *ops, size_t nops)
Definition: call_log_batch.cc:111
regen-readme.line
line
Definition: regen-readme.py:30
GRPC_OP_RECV_CLOSE_ON_SERVER
@ GRPC_OP_RECV_CLOSE_ON_SERVER
Definition: grpc_types.h:633
grpc_op::grpc_op_data::recv_initial_metadata
struct grpc_op::grpc_op_data::grpc_op_recv_initial_metadata recv_initial_metadata
grpc_op::grpc_op_data::grpc_op_send_status_from_server::status_details
grpc_slice * status_details
Definition: grpc_types.h:677
GRPC_OP_RECV_STATUS_ON_CLIENT
@ GRPC_OP_RECV_STATUS_ON_CLIENT
Definition: grpc_types.h:627
grpc_op::grpc_op_data::grpc_op_recv_initial_metadata::recv_initial_metadata
grpc_metadata_array * recv_initial_metadata
Definition: grpc_types.h:685
op
static grpc_op * op
Definition: test/core/fling/client.cc:47
ops
static grpc_op ops[6]
Definition: test/core/fling/client.cc:39
grpc_op::grpc_op_data::grpc_op_recv_close_on_server::cancelled
int * cancelled
Definition: grpc_types.h:714
call.h
GRPC_OP_SEND_CLOSE_FROM_CLIENT
@ GRPC_OP_SEND_CLOSE_FROM_CLIENT
Definition: grpc_types.h:607
slice_string_helpers.h
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:42