Compare commits

..

1 Commits

Author SHA1 Message Date
Esun Kim 662661bff7
Revert "[Test] Silence gcc 7 (#36752)"
This reverts commit ca4c025091.
2024-06-05 15:57:32 -07:00
457 changed files with 6227 additions and 10503 deletions

4
.gitattributes vendored
View File

@ -35,7 +35,3 @@ src/core/lib/experiments/experiments.h linguist-generated=true
src/core/lib/experiments/experiments.cc linguist-generated=true
bazel/experiments.bzl linguist-generated=true
test/cpp/microbenchmarks/huffman_geometries/** linguist-generated=true
doc/trace_flags.md linguist-generated=true
src/core/lib/debug/trace_flags.h linguist-generated=true
src/core/lib/debug/trace_flags.cc linguist-generated=true
src/python/grpcio_observability/observability_lib_deps.py linguist-generated=true

89
BUILD
View File

@ -19,7 +19,6 @@ load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load(
"//bazel:grpc_build_system.bzl",
"grpc_cc_library",
"grpc_clang_cl_settings",
"grpc_filegroup",
"grpc_generate_one_off_targets",
"grpc_upb_proto_library",
@ -67,7 +66,29 @@ bool_flag(
build_setting_default = False,
)
grpc_clang_cl_settings()
platform(
name = "android_x86_64",
constraint_values = [
"@platforms//os:android",
"@platforms//cpu:x86_64",
],
)
platform(
name = "android_arm64",
constraint_values = [
"@platforms//os:android",
"@platforms//cpu:arm64",
],
)
platform(
name = "android_armv7",
constraint_values = [
"@platforms//os:android",
"@platforms//cpu:armv7",
],
)
config_setting(
name = "grpc_no_rls_flag",
@ -219,17 +240,12 @@ config_setting(
values = {"define": "use_strict_warning=true"},
)
config_setting(
name = "use_strict_warning_windows",
values = {"define": "use_strict_warning_windows=true"},
)
python_config_settings()
# This should be updated along with build_handwritten.yaml
g_stands_for = "gnarly" # @unused
core_version = "42.0.0" # @unused
core_version = "41.0.0" # @unused
version = "1.65.0-dev" # @unused
@ -1408,6 +1424,17 @@ grpc_cc_library(
],
)
grpc_cc_library(
name = "call_trace",
hdrs = [
"//src/core:lib/surface/call_trace.h",
],
language = "c++",
deps = [
"grpc_trace",
],
)
grpc_cc_library(
name = "dynamic_annotations",
hdrs = [
@ -1476,6 +1503,9 @@ grpc_cc_library(
grpc_cc_library(
name = "api_trace",
srcs = [
"//src/core:lib/surface/api_trace.cc",
],
hdrs = [
"//src/core:lib/surface/api_trace.h",
],
@ -1522,6 +1552,7 @@ grpc_cc_library(
"//src/core:lib/iomgr/ev_epoll1_linux.cc",
"//src/core:lib/iomgr/ev_poll_posix.cc",
"//src/core:lib/iomgr/ev_posix.cc",
"//src/core:lib/iomgr/ev_windows.cc",
"//src/core:lib/iomgr/fork_posix.cc",
"//src/core:lib/iomgr/fork_windows.cc",
"//src/core:lib/iomgr/gethostname_fallback.cc",
@ -1699,6 +1730,7 @@ grpc_cc_library(
"//src/core:posix_event_engine_endpoint",
"//src/core:resolved_address",
"//src/core:resource_quota",
"//src/core:resource_quota_trace",
"//src/core:slice",
"//src/core:slice_buffer",
"//src/core:slice_cast",
@ -2033,6 +2065,7 @@ grpc_cc_library(
deps = [
"api_trace",
"call_combiner",
"call_trace",
"call_tracer",
"channel",
"channel_arg_names",
@ -2069,6 +2102,7 @@ grpc_cc_library(
"//src/core:channel_args_preconditioning",
"//src/core:channel_fwd",
"//src/core:channel_init",
"//src/core:channel_stack_trace",
"//src/core:channel_stack_type",
"//src/core:closure",
"//src/core:compression",
@ -2098,6 +2132,7 @@ grpc_cc_library(
"//src/core:pipe",
"//src/core:poll",
"//src/core:promise_status",
"//src/core:promise_trace",
"//src/core:race",
"//src/core:ref_counted",
"//src/core:seq",
@ -2293,6 +2328,7 @@ grpc_cc_library(
visibility = ["@grpc:public"],
deps = [
"api_trace",
"call_trace",
"channel_arg_names",
"channelz",
"config",
@ -2328,6 +2364,7 @@ grpc_cc_library(
"//src/core:poll",
"//src/core:ref_counted",
"//src/core:resource_quota",
"//src/core:resource_quota_trace",
"//src/core:seq",
"//src/core:slice",
"//src/core:slice_refcount",
@ -2950,7 +2987,6 @@ grpc_cc_library(
],
language = "c++",
deps = [
":grpc++",
"//src/cpp/ext/otel:otel_plugin",
],
)
@ -2986,19 +3022,11 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_trace",
srcs = [
"//src/core:lib/debug/trace.cc",
"//src/core:lib/debug/trace_flags.cc",
],
hdrs = [
"//src/core:lib/debug/trace.h",
"//src/core:lib/debug/trace_flags.h",
"//src/core:lib/debug/trace_impl.h",
],
srcs = ["//src/core:lib/debug/trace.cc"],
hdrs = ["//src/core:lib/debug/trace.h"],
external_deps = [
"absl/log",
"absl/log:log",
"absl/strings",
"absl/container:flat_hash_map",
],
language = "c++",
visibility = ["@grpc:trace"],
@ -3006,8 +3034,6 @@ grpc_cc_library(
"config_vars",
"gpr",
"grpc_public_hdrs",
"//src/core:glob",
"//src/core:no_destruct",
],
)
@ -4304,6 +4330,7 @@ grpc_cc_library(
language = "c++",
visibility = ["@grpc:http"],
deps = [
"call_trace",
"call_tracer",
"channel_arg_names",
"config",
@ -4520,6 +4547,20 @@ grpc_cc_library(
deps = ["gpr"],
)
grpc_cc_library(
name = "http_trace",
srcs = [
"//src/core:ext/transport/chttp2/transport/http_trace.cc",
],
hdrs = [
"//src/core:ext/transport/chttp2/transport/http_trace.h",
],
deps = [
"gpr_platform",
"grpc_trace",
],
)
grpc_cc_library(
name = "hpack_parser_table",
srcs = [
@ -4540,6 +4581,7 @@ grpc_cc_library(
"gpr_platform",
"grpc_trace",
"hpack_parse_result",
"http_trace",
"//src/core:hpack_constants",
"//src/core:metadata_batch",
"//src/core:no_destruct",
@ -4642,6 +4684,7 @@ grpc_cc_library(
"grpc_base",
"grpc_public_hdrs",
"grpc_trace",
"http_trace",
"//src/core:hpack_constants",
"//src/core:hpack_encoder_table",
"//src/core:metadata_batch",
@ -4774,6 +4817,7 @@ grpc_cc_library(
"hpack_encoder",
"hpack_parser",
"hpack_parser_table",
"http_trace",
"httpcli",
"iomgr",
"iomgr_buffer_list",
@ -4810,6 +4854,7 @@ grpc_cc_library(
"//src/core:random_early_detection",
"//src/core:ref_counted",
"//src/core:resource_quota",
"//src/core:resource_quota_trace",
"//src/core:slice",
"//src/core:slice_buffer",
"//src/core:slice_refcount",

381
CMakeLists.txt generated

File diff suppressed because it is too large Load Diff

20
Makefile generated
View File

@ -367,7 +367,7 @@ E = @echo
Q = @
endif
CORE_VERSION = 42.0.0
CORE_VERSION = 41.0.0
CPP_VERSION = 1.65.0-dev
CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
@ -404,7 +404,7 @@ SHARED_EXT_CORE = dll
SHARED_EXT_CPP = dll
SHARED_PREFIX =
SHARED_VERSION_CORE = -42
SHARED_VERSION_CORE = -41
SHARED_VERSION_CPP = -1
else ifeq ($(SYSTEM),Darwin)
EXECUTABLE_SUFFIX =
@ -724,6 +724,7 @@ LIBGRPC_SRC = \
src/core/ext/transport/chttp2/transport/hpack_parser.cc \
src/core/ext/transport/chttp2/transport/hpack_parser_table.cc \
src/core/ext/transport/chttp2/transport/http2_settings.cc \
src/core/ext/transport/chttp2/transport/http_trace.cc \
src/core/ext/transport/chttp2/transport/huffsyms.cc \
src/core/ext/transport/chttp2/transport/max_concurrent_streams_policy.cc \
src/core/ext/transport/chttp2/transport/parsing.cc \
@ -734,6 +735,7 @@ LIBGRPC_SRC = \
src/core/ext/transport/chttp2/transport/varint.cc \
src/core/ext/transport/chttp2/transport/write_size_policy.cc \
src/core/ext/transport/chttp2/transport/writing.cc \
src/core/ext/transport/inproc/inproc_plugin.cc \
src/core/ext/transport/inproc/inproc_transport.cc \
src/core/ext/transport/inproc/legacy_inproc_transport.cc \
src/core/ext/upb-gen/envoy/admin/v3/certs.upb_minitable.c \
@ -1071,6 +1073,7 @@ LIBGRPC_SRC = \
src/core/lib/channel/channel_stack.cc \
src/core/lib/channel/channel_stack_builder.cc \
src/core/lib/channel/channel_stack_builder_impl.cc \
src/core/lib/channel/channel_stack_trace.cc \
src/core/lib/channel/connected_channel.cc \
src/core/lib/channel/promise_based_filter.cc \
src/core/lib/channel/status_util.cc \
@ -1083,7 +1086,6 @@ LIBGRPC_SRC = \
src/core/lib/config/load_config.cc \
src/core/lib/debug/event_log.cc \
src/core/lib/debug/trace.cc \
src/core/lib/debug/trace_flags.cc \
src/core/lib/event_engine/ares_resolver.cc \
src/core/lib/event_engine/cf_engine/cf_engine.cc \
src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc \
@ -1122,6 +1124,7 @@ LIBGRPC_SRC = \
src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc \
src/core/lib/event_engine/thready_event_engine/thready_event_engine.cc \
src/core/lib/event_engine/time_util.cc \
src/core/lib/event_engine/trace.cc \
src/core/lib/event_engine/utils.cc \
src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc \
src/core/lib/event_engine/windows/iocp.cc \
@ -1137,7 +1140,6 @@ LIBGRPC_SRC = \
src/core/lib/gprpp/dump_args.cc \
src/core/lib/gprpp/examine_stack.cc \
src/core/lib/gprpp/fork.cc \
src/core/lib/gprpp/glob.cc \
src/core/lib/gprpp/host_port.cc \
src/core/lib/gprpp/linux/env.cc \
src/core/lib/gprpp/load_file.cc \
@ -1177,6 +1179,7 @@ LIBGRPC_SRC = \
src/core/lib/iomgr/ev_epoll1_linux.cc \
src/core/lib/iomgr/ev_poll_posix.cc \
src/core/lib/iomgr/ev_posix.cc \
src/core/lib/iomgr/ev_windows.cc \
src/core/lib/iomgr/event_engine_shims/closure.cc \
src/core/lib/iomgr/event_engine_shims/endpoint.cc \
src/core/lib/iomgr/event_engine_shims/tcp_client.cc \
@ -1241,6 +1244,7 @@ LIBGRPC_SRC = \
src/core/lib/promise/activity.cc \
src/core/lib/promise/party.cc \
src/core/lib/promise/sleep.cc \
src/core/lib/promise/trace.cc \
src/core/lib/resource_quota/api.cc \
src/core/lib/resource_quota/arena.cc \
src/core/lib/resource_quota/connection_quota.cc \
@ -1248,6 +1252,7 @@ LIBGRPC_SRC = \
src/core/lib/resource_quota/periodic_update.cc \
src/core/lib/resource_quota/resource_quota.cc \
src/core/lib/resource_quota/thread_quota.cc \
src/core/lib/resource_quota/trace.cc \
src/core/lib/security/authorization/audit_logging.cc \
src/core/lib/security/authorization/authorization_policy_provider_vtable.cc \
src/core/lib/security/authorization/evaluate_args.cc \
@ -1313,7 +1318,9 @@ LIBGRPC_SRC = \
src/core/lib/slice/percent_encoding.cc \
src/core/lib/slice/slice.cc \
src/core/lib/slice/slice_buffer.cc \
src/core/lib/slice/slice_refcount.cc \
src/core/lib/slice/slice_string_helpers.cc \
src/core/lib/surface/api_trace.cc \
src/core/lib/surface/byte_buffer.cc \
src/core/lib/surface/byte_buffer_reader.cc \
src/core/lib/surface/call.cc \
@ -1404,6 +1411,7 @@ LIBGRPC_SRC = \
src/core/resolver/sockaddr/sockaddr_resolver.cc \
src/core/resolver/xds/xds_dependency_manager.cc \
src/core/resolver/xds/xds_resolver.cc \
src/core/resolver/xds/xds_resolver_trace.cc \
src/core/server/server.cc \
src/core/server/server_call_tracer_filter.cc \
src/core/server/server_config_selector_filter.cc \
@ -1833,8 +1841,8 @@ $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_
ifeq ($(SYSTEM),Darwin)
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libcares.a $(OPENSSL_MERGE_LIBS) $(ZLIB_MERGE_LIBS) $(LDLIBS_SECURE) $(LDLIBS)
else
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc.so.42 -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libcares.a $(OPENSSL_MERGE_LIBS) $(ZLIB_MERGE_LIBS) $(LDLIBS_SECURE) $(LDLIBS)
$(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so.42
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc.so.41 -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libcares.a $(OPENSSL_MERGE_LIBS) $(ZLIB_MERGE_LIBS) $(LDLIBS_SECURE) $(LDLIBS)
$(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so.41
$(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so
endif
endif

21
Package.swift generated
View File

@ -237,6 +237,8 @@ let package = Package(
"src/core/ext/transport/chttp2/transport/hpack_parser_table.h",
"src/core/ext/transport/chttp2/transport/http2_settings.cc",
"src/core/ext/transport/chttp2/transport/http2_settings.h",
"src/core/ext/transport/chttp2/transport/http_trace.cc",
"src/core/ext/transport/chttp2/transport/http_trace.h",
"src/core/ext/transport/chttp2/transport/huffsyms.cc",
"src/core/ext/transport/chttp2/transport/huffsyms.h",
"src/core/ext/transport/chttp2/transport/internal.h",
@ -256,6 +258,7 @@ let package = Package(
"src/core/ext/transport/chttp2/transport/write_size_policy.cc",
"src/core/ext/transport/chttp2/transport/write_size_policy.h",
"src/core/ext/transport/chttp2/transport/writing.cc",
"src/core/ext/transport/inproc/inproc_plugin.cc",
"src/core/ext/transport/inproc/inproc_transport.cc",
"src/core/ext/transport/inproc/inproc_transport.h",
"src/core/ext/transport/inproc/legacy_inproc_transport.cc",
@ -1100,6 +1103,8 @@ let package = Package(
"src/core/lib/channel/channel_stack_builder.h",
"src/core/lib/channel/channel_stack_builder_impl.cc",
"src/core/lib/channel/channel_stack_builder_impl.h",
"src/core/lib/channel/channel_stack_trace.cc",
"src/core/lib/channel/channel_stack_trace.h",
"src/core/lib/channel/connected_channel.cc",
"src/core/lib/channel/connected_channel.h",
"src/core/lib/channel/promise_based_filter.cc",
@ -1122,9 +1127,6 @@ let package = Package(
"src/core/lib/debug/event_log.h",
"src/core/lib/debug/trace.cc",
"src/core/lib/debug/trace.h",
"src/core/lib/debug/trace_flags.cc",
"src/core/lib/debug/trace_flags.h",
"src/core/lib/debug/trace_impl.h",
"src/core/lib/event_engine/ares_resolver.cc",
"src/core/lib/event_engine/ares_resolver.h",
"src/core/lib/event_engine/cf_engine/cf_engine.cc",
@ -1217,6 +1219,7 @@ let package = Package(
"src/core/lib/event_engine/thready_event_engine/thready_event_engine.h",
"src/core/lib/event_engine/time_util.cc",
"src/core/lib/event_engine/time_util.h",
"src/core/lib/event_engine/trace.cc",
"src/core/lib/event_engine/trace.h",
"src/core/lib/event_engine/utils.cc",
"src/core/lib/event_engine/utils.h",
@ -1259,8 +1262,6 @@ let package = Package(
"src/core/lib/gprpp/examine_stack.h",
"src/core/lib/gprpp/fork.cc",
"src/core/lib/gprpp/fork.h",
"src/core/lib/gprpp/glob.cc",
"src/core/lib/gprpp/glob.h",
"src/core/lib/gprpp/host_port.cc",
"src/core/lib/gprpp/host_port.h",
"src/core/lib/gprpp/if_list.h",
@ -1350,6 +1351,7 @@ let package = Package(
"src/core/lib/iomgr/ev_poll_posix.h",
"src/core/lib/iomgr/ev_posix.cc",
"src/core/lib/iomgr/ev_posix.h",
"src/core/lib/iomgr/ev_windows.cc",
"src/core/lib/iomgr/event_engine_shims/closure.cc",
"src/core/lib/iomgr/event_engine_shims/closure.h",
"src/core/lib/iomgr/event_engine_shims/endpoint.cc",
@ -1492,6 +1494,8 @@ let package = Package(
"src/core/lib/promise/sleep.cc",
"src/core/lib/promise/sleep.h",
"src/core/lib/promise/status_flag.h",
"src/core/lib/promise/trace.cc",
"src/core/lib/promise/trace.h",
"src/core/lib/promise/try_join.h",
"src/core/lib/promise/try_seq.h",
"src/core/lib/resource_quota/api.cc",
@ -1508,6 +1512,8 @@ let package = Package(
"src/core/lib/resource_quota/resource_quota.h",
"src/core/lib/resource_quota/thread_quota.cc",
"src/core/lib/resource_quota/thread_quota.h",
"src/core/lib/resource_quota/trace.cc",
"src/core/lib/resource_quota/trace.h",
"src/core/lib/security/authorization/audit_logging.cc",
"src/core/lib/security/authorization/audit_logging.h",
"src/core/lib/security/authorization/authorization_engine.h",
@ -1636,9 +1642,11 @@ let package = Package(
"src/core/lib/slice/slice_buffer.cc",
"src/core/lib/slice/slice_buffer.h",
"src/core/lib/slice/slice_internal.h",
"src/core/lib/slice/slice_refcount.cc",
"src/core/lib/slice/slice_refcount.h",
"src/core/lib/slice/slice_string_helpers.cc",
"src/core/lib/slice/slice_string_helpers.h",
"src/core/lib/surface/api_trace.cc",
"src/core/lib/surface/api_trace.h",
"src/core/lib/surface/byte_buffer.cc",
"src/core/lib/surface/byte_buffer_reader.cc",
@ -1647,6 +1655,7 @@ let package = Package(
"src/core/lib/surface/call_details.cc",
"src/core/lib/surface/call_log_batch.cc",
"src/core/lib/surface/call_test_only.h",
"src/core/lib/surface/call_trace.h",
"src/core/lib/surface/call_utils.cc",
"src/core/lib/surface/call_utils.h",
"src/core/lib/surface/channel.cc",
@ -1814,6 +1823,8 @@ let package = Package(
"src/core/resolver/xds/xds_dependency_manager.h",
"src/core/resolver/xds/xds_resolver.cc",
"src/core/resolver/xds/xds_resolver_attributes.h",
"src/core/resolver/xds/xds_resolver_trace.cc",
"src/core/resolver/xds/xds_resolver_trace.h",
"src/core/server/server.cc",
"src/core/server/server.h",
"src/core/server/server_call_tracer_filter.cc",

View File

@ -4,27 +4,16 @@ This guide is for troubleshooting gRPC implementations based on C core library (
## Enabling extra logging and tracing
Extra logging can be very useful for diagnosing problems. It can be used to increase the amount of information
Extra logging can be very useful for diagnosing problems. All gRPC implementations based on C core library support
the `GRPC_VERBOSITY` and `GRPC_TRACE` environment variables that can be used to increase the amount of information
that gets printed to stderr.
## GRPC_VERBOSITY
<!-- BEGIN_GOOGLE_INTERNAL_DOCUMENTATION
GRPC_VERBOSITY has been disabled for internal usage and will not work anymore.
If anyone wants to debug, we need to set verbose logs using absl.
END_GOOGLE_INTERNAL_DOCUMENTATION -->
<!-- BEGIN_OPEN_SOURCE_DOCUMENTATION -->
`GRPC_VERBOSITY` is used to set the minimum level of log messages printed by gRPC (supported values are `DEBUG`, `INFO` and `ERROR`). If this environment variable is unset, only `ERROR` logs will be printed. `ERROR` is recomeded for production systems.
<!-- END_OPEN_SOURCE_DOCUMENTATION -->
`GRPC_VERBOSITY` is used to set the minimum level of log messages printed by gRPC (supported values are `DEBUG`, `INFO` and `ERROR`). If this environment variable is unset, only `ERROR` logs will be printed.
## GRPC_TRACE
<!-- BEGIN_GOOGLE_INTERNAL_DOCUMENTATION
GRPC_VERBOSITY has been disabled for internal usage and will not work anymore.
If anyone wants to debug, we need to set verbose logs using absl.
END_GOOGLE_INTERNAL_DOCUMENTATION -->
`GRPC_TRACE` can be used to enable extra logging for some internal gRPC components. Enabling the right traces can be invaluable
for diagnosing for what is going wrong when things aren't working as intended. Possible values for `GRPC_TRACE` are listed in [Environment Variables Overview](doc/environment_variables.md).
Multiple traces can be enabled at once (use comma as separator).

View File

@ -128,12 +128,6 @@ load("@com_github_google_benchmark//:bazel/benchmark_deps.bzl", "benchmark_deps"
benchmark_deps()
# This is a transitive dependency from google_cloud_cpp
bind(
name = "cares",
actual = "@com_github_cares_cares//:ares",
)
load("@io_opentelemetry_cpp//bazel:repository.bzl", "opentelemetry_cpp_deps")
opentelemetry_cpp_deps()
@ -142,12 +136,6 @@ load("@io_opentelemetry_cpp//bazel:extra_deps.bzl", "opentelemetry_extra_deps")
opentelemetry_extra_deps()
# Transitive dependency of opentelemetry_extra_deps()
bind(
name = "madler_zlib",
actual = "@zlib//:zlib",
)
# TODO: Enable below once https://github.com/bazel-xcode/PodToBUILD/issues/232 is resolved
#
#http_archive(

View File

@ -57,107 +57,7 @@ GRPC_LLVM_WARNING_FLAGS = [
"-Wno-unused-function",
]
GRPC_LLVM_WINDOWS_WARNING_FLAGS = GRPC_LLVM_WARNING_FLAGS + [
### Some checks that are missing with clang-cl
"-Wthread-safety",
"-Wreorder-ctor",
### Avoid some checks that are default on clang-cl
"-Wno-c++98-compat-pedantic",
"-Wno-missing-prototypes",
"-Wno-thread-safety-precise", # too many aliases
# abseil offenses
"-Wno-comma",
"-Wno-deprecated-redundant-constexpr-static-def",
"-Wno-deprecated", # remove when the above works in all clang versions we test with
"-Wno-float-equal",
"-Wno-gcc-compat",
"-Wno-reserved-identifier",
"-Wno-thread-safety-negative",
"-Wno-sign-compare",
# re2 offenses
"-Wno-zero-as-null-pointer-constant",
# ares offenses
"-Wno-macro-redefined",
# protobuf offenses
"-Wno-cast-align",
"-Wno-inconsistent-missing-destructor-override",
# xxhash offenses
"-Wno-disabled-macro-expansion",
# benchmark offenses
"-Wno-shift-sign-overflow",
# Evidently nodiscard is inappropriately pinned as a C++17 feature
"-Wno-c++17-attribute-extensions",
# declarations are not used in many places
"-Wno-missing-variable-declarations",
# TODO: delete iomgr
"-Wno-old-style-cast",
"-Wno-cast-qual",
"-Wno-unused-member-function",
"-Wno-unused-template",
# TODO(hork): see if the TraceFlag offense can be removed
"-Wno-global-constructors",
# TODO(hork): clean up EE offenses
"-Wno-missing-field-initializers",
"-Wno-non-virtual-dtor",
"-Wno-thread-safety-reference-return",
# TODO(ctiller): offense: dump_args. signed to unsigned
"-Wno-sign-conversion",
"-Wno-shorten-64-to-32",
# TODO: general cleanup required. Maybe new developer or rainy day projects.
"-Wno-unreachable-code-break",
"-Wno-unreachable-code-return",
"-Wno-unreachable-code",
"-Wno-used-but-marked-unused",
"-Wno-newline-eof",
"-Wno-unused-const-variable",
"-Wno-extra-semi",
"-Wno-extra-semi-stmt",
"-Wno-suggest-destructor-override",
"-Wno-shadow",
"-Wno-missing-noreturn",
"-Wno-nested-anon-types",
"-Wno-gnu-anonymous-struct",
"-Wno-nonportable-system-include-path",
"-Wno-microsoft-cast",
"-Wno-exit-time-destructors",
"-Wno-undef", # #if <MACRO_NAME> to #ifdef <MACRO_NAME>
"-Wno-unused-macros",
"-Wno-redundant-parens",
"-Wno-undefined-func-template",
"-Wno-gnu-zero-variadic-macro-arguments",
"-Wno-double-promotion",
"-Wno-implicit-float-conversion",
"-Wno-implicit-int-conversion",
"-Wno-float-conversion",
"-Wno-unused-parameter",
"-Wno-suggest-override",
"-Wno-documentation",
"-Wno-documentation-unknown-command",
"-Wno-unsafe-buffer-usage",
### possibly bad warnings for this codebase
"-Wno-covered-switch-default",
"-Wno-switch-default",
"-Wno-switch-enum",
"-Wno-c99-extensions",
"-Wno-unused-private-field", # GRPC_UNUSED does not appear to work for private fields
]
GRPC_DEFAULT_COPTS = select({
"//:use_strict_warning": GRPC_LLVM_WARNING_FLAGS + ["-DUSE_STRICT_WARNING=1"],
"//:use_strict_warning_windows": GRPC_LLVM_WINDOWS_WARNING_FLAGS + ["-DUSE_STRICT_WARNING=1"],
"//conditions:default": [],
})

12
bazel/experiments.bzl generated
View File

@ -41,7 +41,7 @@ EXPERIMENT_ENABLES = {
"trace_record_callops": "trace_record_callops",
"unconstrained_max_quota_buffer_size": "unconstrained_max_quota_buffer_size",
"work_serializer_clears_time_cache": "work_serializer_clears_time_cache",
"work_serializer_dispatch": "work_serializer_dispatch",
"work_serializer_dispatch": "event_engine_client,work_serializer_dispatch",
}
EXPERIMENT_POLLERS = [
@ -55,10 +55,16 @@ EXPERIMENTS = {
"dbg": {
},
"off": {
"core_end2end_test": [
"event_engine_client",
],
"endpoint_test": [
"tcp_frame_size_tuning",
"tcp_rcv_lowat",
],
"event_engine_client_test": [
"event_engine_client",
],
"flow_control_test": [
"multiping",
"peer_state_based_framing",
@ -76,15 +82,11 @@ EXPERIMENTS = {
"event_engine_dns",
],
"core_end2end_test": [
"event_engine_client",
"event_engine_listener",
],
"cpp_lb_end2end_test": [
"pick_first_new",
],
"event_engine_client_test": [
"event_engine_client",
],
"event_engine_listener_test": [
"event_engine_listener",
],

View File

@ -45,7 +45,6 @@ def if_not_windows(a):
return select({
"//:windows": [],
"//:windows_msvc": [],
"//:windows_clang": [],
"//conditions:default": a,
})
@ -53,7 +52,6 @@ def if_windows(a):
return select({
"//:windows": a,
"//:windows_msvc": a,
"//:windows_clang": a,
"//conditions:default": [],
})
@ -69,7 +67,7 @@ def _get_external_deps(external_deps):
elif dep == "cares":
ret += select({
"//:grpc_no_ares": [],
"//conditions:default": ["//third_party:cares"],
"//conditions:default": ["//external:cares"],
})
elif dep == "cronet_c_for_grpc":
ret.append("//third_party/objective_c/Cronet:cronet_c_for_grpc")
@ -84,7 +82,7 @@ def _get_external_deps(external_deps):
elif dep == "libprotobuf_mutator":
ret.append("@com_google_libprotobuf_mutator//:libprotobuf_mutator")
else:
ret.append("//third_party:" + dep)
ret.append("//external:" + dep)
return ret
def _update_visibility(visibility):
@ -804,22 +802,3 @@ def python_config_settings():
name = "python3",
flag_values = {"@bazel_tools//tools/python:python_version": "PY3"},
)
# buildifier: disable=unnamed-macro
def grpc_clang_cl_settings():
native.platform(
name = "x64_windows-clang-cl",
constraint_values = [
"@platforms//cpu:x86_64",
"@platforms//os:windows",
"@bazel_tools//tools/cpp:clang-cl",
],
)
native.config_setting(
name = "windows_clang",
constraint_values = [
"@platforms//cpu:x86_64",
"@platforms//os:windows",
"@bazel_tools//tools/cpp:clang-cl",
],
)

View File

@ -14,12 +14,167 @@
"""Load dependencies needed to compile and test the grpc library as a 3rd-party consumer."""
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("//bazel:grpc_python_deps.bzl", "grpc_python_deps")
load("@com_github_grpc_grpc//bazel:grpc_python_deps.bzl", "grpc_python_deps")
# buildifier: disable=unnamed-macro
def grpc_deps():
"""Loads dependencies need to compile and test the grpc library."""
native.bind(
name = "libssl",
actual = "@boringssl//:ssl",
)
native.bind(
name = "libcrypto",
actual = "@boringssl//:crypto",
)
native.bind(
name = "madler_zlib",
actual = "@zlib//:zlib",
)
native.bind(
name = "protobuf",
actual = "@com_google_protobuf//:protobuf",
)
native.bind(
name = "protobuf_clib",
actual = "@com_google_protobuf//:protoc_lib",
)
native.bind(
name = "protobuf_headers",
actual = "@com_google_protobuf//:protobuf_headers",
)
native.bind(
name = "protocol_compiler",
actual = "@com_google_protobuf//:protoc",
)
native.bind(
name = "cares",
actual = "@com_github_cares_cares//:ares",
)
native.bind(
name = "gtest",
actual = "@com_google_googletest//:gtest",
)
native.bind(
name = "fuzztest",
actual = "@com_google_fuzztest//fuzztest",
)
native.bind(
name = "fuzztest_main",
actual = "@com_google_fuzztest//fuzztest:fuzztest_gtest_main",
)
native.bind(
name = "benchmark",
actual = "@com_github_google_benchmark//:benchmark",
)
native.bind(
name = "re2",
actual = "@com_googlesource_code_re2//:re2",
)
native.bind(
name = "grpc_cpp_plugin",
actual = "@com_github_grpc_grpc//src/compiler:grpc_cpp_plugin",
)
native.bind(
name = "grpc++_codegen_proto",
actual = "@com_github_grpc_grpc//:grpc++_codegen_proto",
)
native.bind(
name = "opencensus-context",
actual = "@io_opencensus_cpp//opencensus/context:context",
)
native.bind(
name = "opencensus-trace",
actual = "@io_opencensus_cpp//opencensus/trace:trace",
)
native.bind(
name = "opencensus-trace-context_util",
actual = "@io_opencensus_cpp//opencensus/trace:context_util",
)
native.bind(
name = "opencensus-trace-propagation",
actual = "@io_opencensus_cpp//opencensus/trace:grpc_trace_bin",
)
native.bind(
name = "opencensus-trace-span_context",
actual = "@io_opencensus_cpp//opencensus/trace:span_context",
)
native.bind(
name = "opencensus-stats",
actual = "@io_opencensus_cpp//opencensus/stats:stats",
)
native.bind(
name = "opencensus-stats-test",
actual = "@io_opencensus_cpp//opencensus/stats:test_utils",
)
native.bind(
name = "opencensus-with-tag-map",
actual = "@io_opencensus_cpp//opencensus/tags:with_tag_map",
)
native.bind(
name = "opencensus-tags",
actual = "@io_opencensus_cpp//opencensus/tags:tags",
)
native.bind(
name = "opencensus-tags-context_util",
actual = "@io_opencensus_cpp//opencensus/tags:context_util",
)
native.bind(
name = "opencensus-trace-stackdriver_exporter",
actual = "@io_opencensus_cpp//opencensus/exporters/trace/stackdriver:stackdriver_exporter",
)
native.bind(
name = "opencensus-stats-stackdriver_exporter",
actual = "@io_opencensus_cpp//opencensus/exporters/stats/stackdriver:stackdriver_exporter",
)
native.bind(
name = "googleapis_trace_grpc_service",
actual = "@com_google_googleapis//google/devtools/cloudtrace/v2:cloudtrace_cc_grpc",
)
native.bind(
name = "googleapis_monitoring_grpc_service",
actual = "@com_google_googleapis//google/monitoring/v3:monitoring_cc_grpc",
)
native.bind(
name = "googleapis_logging_grpc_service",
actual = "@com_google_googleapis//google/logging/v2:logging_cc_grpc",
)
native.bind(
name = "googleapis_logging_cc_proto",
actual = "@com_google_googleapis//google/logging/v2:logging_cc_proto",
)
if "platforms" not in native.existing_rules():
http_archive(
name = "platforms",
@ -67,7 +222,6 @@ def grpc_deps():
],
patches = [
"@com_github_grpc_grpc//third_party:protobuf.patch",
"@com_github_grpc_grpc//third_party:protobuf.10007.patch",
],
patch_args = ["-p1"],
)
@ -341,6 +495,15 @@ def grpc_test_only_deps():
Loads dependencies that are only needed to run grpc library's tests.
"""
native.bind(
name = "twisted",
actual = "@com_github_twisted_twisted//:twisted",
)
native.bind(
name = "yaml",
actual = "@com_github_yaml_pyyaml//:yaml",
)
if "com_github_twisted_twisted" not in native.existing_rules():
http_archive(

View File

@ -1,37 +0,0 @@
# Copyright 2024 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
platform(
name = "x86_64",
constraint_values = [
"@platforms//os:android",
"@platforms//cpu:x86_64",
],
)
platform(
name = "arm64-v8a",
constraint_values = [
"@platforms//os:android",
"@platforms//cpu:arm64",
],
)
platform(
name = "armeabi-v7a",
constraint_values = [
"@platforms//os:android",
"@platforms//cpu:armv7",
],
)

412
build_autogenerated.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -13,5 +13,5 @@
# limitations under the License.
module GrpcBuildConfig
CORE_WINDOWS_DLL = '/tmp/libs/opt/grpc-42.dll'
CORE_WINDOWS_DLL = '/tmp/libs/opt/grpc-41.dll'
end

View File

@ -12,7 +12,7 @@ settings:
'#08': Use "-preN" suffixes to identify pre-release versions
'#09': Per-language overrides are possible with (eg) ruby_version tag here
'#10': See the expand_version.py for all the quirks here
core_version: 42.0.0
core_version: 41.0.0
csharp_major_version: 2
g_stands_for: gnarly
protobuf_version: 3.26.1

12
config.m4 generated
View File

@ -99,6 +99,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/ext/transport/chttp2/transport/hpack_parser.cc \
src/core/ext/transport/chttp2/transport/hpack_parser_table.cc \
src/core/ext/transport/chttp2/transport/http2_settings.cc \
src/core/ext/transport/chttp2/transport/http_trace.cc \
src/core/ext/transport/chttp2/transport/huffsyms.cc \
src/core/ext/transport/chttp2/transport/max_concurrent_streams_policy.cc \
src/core/ext/transport/chttp2/transport/parsing.cc \
@ -109,6 +110,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/ext/transport/chttp2/transport/varint.cc \
src/core/ext/transport/chttp2/transport/write_size_policy.cc \
src/core/ext/transport/chttp2/transport/writing.cc \
src/core/ext/transport/inproc/inproc_plugin.cc \
src/core/ext/transport/inproc/inproc_transport.cc \
src/core/ext/transport/inproc/legacy_inproc_transport.cc \
src/core/ext/upb-gen/envoy/admin/v3/certs.upb_minitable.c \
@ -446,6 +448,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/channel/channel_stack.cc \
src/core/lib/channel/channel_stack_builder.cc \
src/core/lib/channel/channel_stack_builder_impl.cc \
src/core/lib/channel/channel_stack_trace.cc \
src/core/lib/channel/connected_channel.cc \
src/core/lib/channel/promise_based_filter.cc \
src/core/lib/channel/status_util.cc \
@ -458,7 +461,6 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/config/load_config.cc \
src/core/lib/debug/event_log.cc \
src/core/lib/debug/trace.cc \
src/core/lib/debug/trace_flags.cc \
src/core/lib/event_engine/ares_resolver.cc \
src/core/lib/event_engine/cf_engine/cf_engine.cc \
src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc \
@ -497,6 +499,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc \
src/core/lib/event_engine/thready_event_engine/thready_event_engine.cc \
src/core/lib/event_engine/time_util.cc \
src/core/lib/event_engine/trace.cc \
src/core/lib/event_engine/utils.cc \
src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc \
src/core/lib/event_engine/windows/iocp.cc \
@ -512,7 +515,6 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/gprpp/dump_args.cc \
src/core/lib/gprpp/examine_stack.cc \
src/core/lib/gprpp/fork.cc \
src/core/lib/gprpp/glob.cc \
src/core/lib/gprpp/host_port.cc \
src/core/lib/gprpp/linux/env.cc \
src/core/lib/gprpp/load_file.cc \
@ -552,6 +554,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/iomgr/ev_epoll1_linux.cc \
src/core/lib/iomgr/ev_poll_posix.cc \
src/core/lib/iomgr/ev_posix.cc \
src/core/lib/iomgr/ev_windows.cc \
src/core/lib/iomgr/event_engine_shims/closure.cc \
src/core/lib/iomgr/event_engine_shims/endpoint.cc \
src/core/lib/iomgr/event_engine_shims/tcp_client.cc \
@ -616,6 +619,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/promise/activity.cc \
src/core/lib/promise/party.cc \
src/core/lib/promise/sleep.cc \
src/core/lib/promise/trace.cc \
src/core/lib/resource_quota/api.cc \
src/core/lib/resource_quota/arena.cc \
src/core/lib/resource_quota/connection_quota.cc \
@ -623,6 +627,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/resource_quota/periodic_update.cc \
src/core/lib/resource_quota/resource_quota.cc \
src/core/lib/resource_quota/thread_quota.cc \
src/core/lib/resource_quota/trace.cc \
src/core/lib/security/authorization/audit_logging.cc \
src/core/lib/security/authorization/authorization_policy_provider_vtable.cc \
src/core/lib/security/authorization/evaluate_args.cc \
@ -688,7 +693,9 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/slice/percent_encoding.cc \
src/core/lib/slice/slice.cc \
src/core/lib/slice/slice_buffer.cc \
src/core/lib/slice/slice_refcount.cc \
src/core/lib/slice/slice_string_helpers.cc \
src/core/lib/surface/api_trace.cc \
src/core/lib/surface/byte_buffer.cc \
src/core/lib/surface/byte_buffer_reader.cc \
src/core/lib/surface/call.cc \
@ -779,6 +786,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/resolver/sockaddr/sockaddr_resolver.cc \
src/core/resolver/xds/xds_dependency_manager.cc \
src/core/resolver/xds/xds_resolver.cc \
src/core/resolver/xds/xds_resolver_trace.cc \
src/core/server/server.cc \
src/core/server/server_call_tracer_filter.cc \
src/core/server/server_config_selector_filter.cc \

12
config.w32 generated
View File

@ -64,6 +64,7 @@ if (PHP_GRPC != "no") {
"src\\core\\ext\\transport\\chttp2\\transport\\hpack_parser.cc " +
"src\\core\\ext\\transport\\chttp2\\transport\\hpack_parser_table.cc " +
"src\\core\\ext\\transport\\chttp2\\transport\\http2_settings.cc " +
"src\\core\\ext\\transport\\chttp2\\transport\\http_trace.cc " +
"src\\core\\ext\\transport\\chttp2\\transport\\huffsyms.cc " +
"src\\core\\ext\\transport\\chttp2\\transport\\max_concurrent_streams_policy.cc " +
"src\\core\\ext\\transport\\chttp2\\transport\\parsing.cc " +
@ -74,6 +75,7 @@ if (PHP_GRPC != "no") {
"src\\core\\ext\\transport\\chttp2\\transport\\varint.cc " +
"src\\core\\ext\\transport\\chttp2\\transport\\write_size_policy.cc " +
"src\\core\\ext\\transport\\chttp2\\transport\\writing.cc " +
"src\\core\\ext\\transport\\inproc\\inproc_plugin.cc " +
"src\\core\\ext\\transport\\inproc\\inproc_transport.cc " +
"src\\core\\ext\\transport\\inproc\\legacy_inproc_transport.cc " +
"src\\core\\ext\\upb-gen\\envoy\\admin\\v3\\certs.upb_minitable.c " +
@ -411,6 +413,7 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\channel\\channel_stack.cc " +
"src\\core\\lib\\channel\\channel_stack_builder.cc " +
"src\\core\\lib\\channel\\channel_stack_builder_impl.cc " +
"src\\core\\lib\\channel\\channel_stack_trace.cc " +
"src\\core\\lib\\channel\\connected_channel.cc " +
"src\\core\\lib\\channel\\promise_based_filter.cc " +
"src\\core\\lib\\channel\\status_util.cc " +
@ -423,7 +426,6 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\config\\load_config.cc " +
"src\\core\\lib\\debug\\event_log.cc " +
"src\\core\\lib\\debug\\trace.cc " +
"src\\core\\lib\\debug\\trace_flags.cc " +
"src\\core\\lib\\event_engine\\ares_resolver.cc " +
"src\\core\\lib\\event_engine\\cf_engine\\cf_engine.cc " +
"src\\core\\lib\\event_engine\\cf_engine\\cfstream_endpoint.cc " +
@ -462,6 +464,7 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\event_engine\\thread_pool\\work_stealing_thread_pool.cc " +
"src\\core\\lib\\event_engine\\thready_event_engine\\thready_event_engine.cc " +
"src\\core\\lib\\event_engine\\time_util.cc " +
"src\\core\\lib\\event_engine\\trace.cc " +
"src\\core\\lib\\event_engine\\utils.cc " +
"src\\core\\lib\\event_engine\\windows\\grpc_polled_fd_windows.cc " +
"src\\core\\lib\\event_engine\\windows\\iocp.cc " +
@ -477,7 +480,6 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\gprpp\\dump_args.cc " +
"src\\core\\lib\\gprpp\\examine_stack.cc " +
"src\\core\\lib\\gprpp\\fork.cc " +
"src\\core\\lib\\gprpp\\glob.cc " +
"src\\core\\lib\\gprpp\\host_port.cc " +
"src\\core\\lib\\gprpp\\linux\\env.cc " +
"src\\core\\lib\\gprpp\\load_file.cc " +
@ -517,6 +519,7 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\iomgr\\ev_epoll1_linux.cc " +
"src\\core\\lib\\iomgr\\ev_poll_posix.cc " +
"src\\core\\lib\\iomgr\\ev_posix.cc " +
"src\\core\\lib\\iomgr\\ev_windows.cc " +
"src\\core\\lib\\iomgr\\event_engine_shims\\closure.cc " +
"src\\core\\lib\\iomgr\\event_engine_shims\\endpoint.cc " +
"src\\core\\lib\\iomgr\\event_engine_shims\\tcp_client.cc " +
@ -581,6 +584,7 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\promise\\activity.cc " +
"src\\core\\lib\\promise\\party.cc " +
"src\\core\\lib\\promise\\sleep.cc " +
"src\\core\\lib\\promise\\trace.cc " +
"src\\core\\lib\\resource_quota\\api.cc " +
"src\\core\\lib\\resource_quota\\arena.cc " +
"src\\core\\lib\\resource_quota\\connection_quota.cc " +
@ -588,6 +592,7 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\resource_quota\\periodic_update.cc " +
"src\\core\\lib\\resource_quota\\resource_quota.cc " +
"src\\core\\lib\\resource_quota\\thread_quota.cc " +
"src\\core\\lib\\resource_quota\\trace.cc " +
"src\\core\\lib\\security\\authorization\\audit_logging.cc " +
"src\\core\\lib\\security\\authorization\\authorization_policy_provider_vtable.cc " +
"src\\core\\lib\\security\\authorization\\evaluate_args.cc " +
@ -653,7 +658,9 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\slice\\percent_encoding.cc " +
"src\\core\\lib\\slice\\slice.cc " +
"src\\core\\lib\\slice\\slice_buffer.cc " +
"src\\core\\lib\\slice\\slice_refcount.cc " +
"src\\core\\lib\\slice\\slice_string_helpers.cc " +
"src\\core\\lib\\surface\\api_trace.cc " +
"src\\core\\lib\\surface\\byte_buffer.cc " +
"src\\core\\lib\\surface\\byte_buffer_reader.cc " +
"src\\core\\lib\\surface\\call.cc " +
@ -744,6 +751,7 @@ if (PHP_GRPC != "no") {
"src\\core\\resolver\\sockaddr\\sockaddr_resolver.cc " +
"src\\core\\resolver\\xds\\xds_dependency_manager.cc " +
"src\\core\\resolver\\xds\\xds_resolver.cc " +
"src\\core\\resolver\\xds\\xds_resolver_trace.cc " +
"src\\core\\server\\server.cc " +
"src\\core\\server\\server_call_tracer_filter.cc " +
"src\\core\\server\\server_config_selector_filter.cc " +

View File

@ -41,29 +41,110 @@ some configuration as environment variables that can be set.
- legacy - the (deprecated) original polling engine for gRPC
* GRPC_TRACE
A comma-separated list of tracer names or glob patterns that provide
additional insight into how gRPC C core is processing requests via debug logs.
Available tracers and their usage can be found in
[gRPC Trace Flags](trace_flags.md)
A comma separated list of tracers that provide additional insight into how
gRPC C core is processing requests via debug logs. Available tracers include:
- api - traces api calls to the C core
- bdp_estimator - traces behavior of bdp estimation logic
- call_error - traces the possible errors contributing to final call status
- cares_resolver - traces operations of the c-ares based DNS resolver
- cares_address_sorting - traces operations of the c-ares based DNS
resolver's resolved address sorter
- cds_lb - traces cds LB policy
- channel - traces operations on the C core channel stack
- channel_stack - traces the set of filters in a channel stack upon
construction
- client_channel - traces client channel control plane activity, including
resolver and load balancing policy interaction
- client_channel_call - traces client channel call activity related to name
resolution
- client_channel_lb_call - traces client channel call activity related
to load balancing picking
- compression - traces compression operations
- connectivity_state - traces connectivity state changes to channels
- cronet - traces state in the cronet transport engine
- dns_resolver - traces state in the native DNS resolver
- executor - traces grpc's internal thread pool ('the executor')
- glb - traces the grpclb load balancer
- handshaker - traces handshaking state
- health_check_client - traces health checking client code
- http - traces state in the http2 transport engine
- http2_stream_state - traces all http2 stream state mutations.
- http2_ping - traces pings/ping acks/antagonist writes in http2 stack.
- http1 - traces HTTP/1.x operations performed by gRPC
- inproc - traces the in-process transport
- http_keepalive - traces gRPC keepalive pings
- flowctl - traces http2 flow control
- op_failure - traces error information when failure is pushed onto a
completion queue
- pick_first - traces the pick first load balancing policy
- plugin_credentials - traces plugin credentials
- pollable_refcount - traces reference counting of 'pollable' objects (only
in DEBUG)
- priority_lb - traces priority LB policy
- resource_quota - trace resource quota objects internals
- ring_hash_lb - traces the ring hash load balancing policy
- rls_lb - traces the RLS load balancing policy
- round_robin - traces the round_robin load balancing policy
- weighted_round_robin_lb - traces the weighted_round_robin load balancing
policy
- queue_pluck
- grpc_authz_api - traces gRPC authorization
- server_channel - lightweight trace of significant server channel events
- secure_endpoint - traces bytes flowing through encrypted channels
- subchannel - traces the connectivity state of subchannel
- subchannel_pool - traces subchannel pool
- timer - timers (alarms) in the grpc internals
- timer_check - more detailed trace of timer logic in grpc internals
- transport_security - traces metadata about secure channel establishment
- tcp - traces bytes in and out of a channel
- tsi - traces tsi transport security
- weighted_target_lb - traces weighted_target LB policy
- xds_client - traces xds client
- xds_cluster_manager_lb - traces cluster manager LB policy
- xds_cluster_impl_lb - traces cluster impl LB policy
- xds_resolver - traces xds resolver
The following tracers will only run in binaries built in DEBUG mode. This is
accomplished by invoking `CONFIG=dbg make <target>`
- metadata - tracks creation and mutation of metadata
- combiner - traces combiner lock state
- call_combiner - traces call combiner state
- closure - tracks closure creation, scheduling, and completion
- fd_trace - traces fd create(), shutdown() and close() calls for channel fds.
- pending_tags - traces still-in-progress tags on completion queues
- polling - traces the selected polling engine
- polling_api - traces the api calls to polling engine
- subchannel_refcount
- queue_refcount
- error_refcount
- stream_refcount
- slice_refcount
- workqueue_refcount
- fd_refcount
- cq_refcount
- auth_context_refcount
- security_connector_refcount
- resolver_refcount
- lb_policy_refcount
- chttp2_refcount
'all' can additionally be used to turn all traces on.
Individual traces can be disabled by prefixing them with '-'.
'refcount' will turn on all of the tracers for refcount debugging.
if 'list_tracers' is present, then all of the available tracers will be
printed when the program starts up.
Example:
export GRPC_TRACE=all,-pending_tags
* GRPC_VERBOSITY
<!-- BEGIN_GOOGLE_INTERNAL_DOCUMENTATION"
GRPC_VERBOSITY has been disabled for internal usage and will not work anymore.
If anyone wants to debug, we need to set verbose logs using absl.
END_GOOGLE_INTERNAL_DOCUMENTATION -->
<!-- BEGIN_OPEN_SOURCE_DOCUMENTATION -->
`GRPC_VERBOSITY` is used to set the minimum level of log messages printed by gRPC (supported values are `DEBUG`, `INFO` and `ERROR`). If this environment variable is unset, only `ERROR` logs will be printed.
gRPC logging verbosity - one of:
- DEBUG - log INFO, WARNING, ERROR and FATAL messages. Also sets absl VLOG(2) logs enabled. This is not recommended for production systems. This will be expensive for staging environments too, so it can be used when you want to debug a specific issue.
- INFO - log INFO, WARNING, ERROR and FATAL messages. This is not recommended for production systems. This may be slightly expensive for staging environments too. We recommend that you use your discretion for staging environments.
- ERROR - log ERROR and FATAL messages. This is recommended for production systems.
- NONE - won't log any.
GRPC_VERBOSITY will set verbosity of absl logging.
- If the external application sets some other verbosity, then whatever is set later will be honoured.
- If nothing is set as GRPC_VERBOSITY, then the setting of the exernal application will be honoured.
- If nothing is set by the external application also, the default set by absl will be honoured.
<!-- END_OPEN_SOURCE_DOCUMENTATION -->
Default gRPC logging verbosity - one of:
- DEBUG - log all gRPC messages
- INFO - log INFO and ERROR message
- ERROR - log only errors (default)
- NONE - won't log any
* GRPC_STACKTRACE_MINLOGLEVEL
Minimum loglevel to print the stack-trace - one of DEBUG, INFO, ERROR, and NONE.

View File

@ -71,7 +71,6 @@ Aggregate Cluster Behavior Fixes | [A75](https://github.com/grpc/proposal/blob/m
[Authorization (RBAC)](https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/http/rbac/v3/rbac.proto):<br><ul><li>`LOG` action has no effect<li>CEL unsupported and rejected</ul> | [A41](https://github.com/grpc/proposal/blob/master/A41-xds-rbac.md) | v1.51.0<br>(C++ and Python) | v1.42.0 | 1.42.0 | |
[Least Request LB Policy](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers.html#weighted-least-request) | [A48](https://github.com/grpc/proposal/blob/master/A48-xds-least-request-lb-policy.md) | | v1.48.0 | | |
[Outlier Detection](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/outlier):<br>Only the following detection types are supported:<ul><li>Success Rate</li><li>Failure Percentage</li></ul> | [A50](https://github.com/grpc/proposal/blob/master/A50-xds-outlier-detection.md) | v1.51.0 | v1.49.0 | v1.50.0 | v1.7.0 |
Ignore Resource Deletion | [A53](https://github.com/grpc/proposal/blob/master/A53-xds-ignore-resource-deletion.md) | v1.48.0 | v1.48.0 | v1.55.0 | v1.7.0 |
[Custom Load Balancer Configuration](https://github.com/envoyproxy/envoy/blob/57be3189ffa3372b34e9480d1f02b2d165e49077/api/envoy/config/cluster/v3/cluster.proto#L1208) | [A52](https://github.com/grpc/proposal/blob/master/A52-xds-custom-lb-policies.md) | v1.55.0 | v1.47.0 | v1.56.0 | v1.10.0 |
[xDS Federation](https://github.com/cncf/xds/blob/main/proposals/TP1-xds-transport-next.md) | [A47](https://github.com/grpc/proposal/blob/master/A47-xds-federation.md) | v1.55.0 | v1.55.0 | v1.55.0 | |
[Client-Side Weighted Round Robin LB Policy](https://github.com/envoyproxy/envoy/blob/a6d46b6ac4750720eec9a49abe701f0df9bf8e0a/api/envoy/extensions/load_balancing_policies/client_side_weighted_round_robin/v3/client_side_weighted_round_robin.proto#L36) | [A58](https://github.com/grpc/proposal/blob/master/A58-client-side-weighted-round-robin-lb-policy.md) | v1.55.0 | v1.54.0 | v1.56.0 | |

View File

@ -1,120 +0,0 @@
<!---
Automatically generated by tools/codegen/core/gen_trace_flags.py
--->
gRPC Trace Flags
----------------
The `GRPC_TRACE` environment variable supports a comma-separated list of tracer
names or glob patterns that provide additional insight into how gRPC C core is
processing requests via debug logs. Available tracers include:
- api - API calls to the C core.
- backend_metric - C++ backend metric recorder APIs.
- backend_metric_filter - Filter that populates backend metric data in server trailing metadata.
- bdp_estimator - Behavior of bdp estimation logic.
- call - Traces operations on a call through the gRPC stack.
- call_error - Possible errors contributing to final call statuses.
- cares_address_sorting - Operations of the c-ares based DNS resolver's address sorter.
- cares_resolver - Operations of the c-ares based DNS resolver.
- cds_lb - CDS LB policy.
- channel - Operations on the C core channel stack.
- channel_stack - Construction of the set of filters in a channel stack.
- chaotic_good - Chaotic good transport.
- chttp2_hpack_parser - HTTP/2 HPACK parser.
- chttp2_new_stream - HTTP/2 incoming stream creation.
- client_channel - Client channel control plane activity, including resolver and load balancing policy interaction.
- client_channel_call - Client channel call activity related to name resolution.
- client_channel_lb_call - Client channel call activity related to load balancing picking.
- client_idle_filter - Client idleness filter.
- compression - Compression operations.
- connectivity_state - Connectivity state changes to channels.
- cronet - Cronet transport engine.
- dns_resolver - The active DNS resolver.
- environment_autodetect - GCP environment auto-detection.
- event_engine - High-level EventEngine operations.
- event_engine_client_channel_resolver - EventEngine-based client channel resolver state and events.
- event_engine_dns - EventEngine DNS resolver.
- event_engine_endpoint - EventEngine Endpoint operations.
- event_engine_endpoint_data - Detailed dump of EventEngine endpoint TCP data.
- event_engine_poller - EventEngine Poller events.
- executor - gRPC's legacy thread pool ('the executor').
- fault_injection_filter - Fault injection.
- flowctl - Http2 flow control.
- fork - Fork support.
- glb - gRPClb load balancer.
- grpc_authz_api - gRPC authorization.
- handshaker - Handshaking state.
- health_check_client - Health checking client code.
- http - Http2 transport engine.
- http1 - HTTP/1.x operations performed by gRPC.
- http2_ping - Pings/ping acks/antagonist writes in http2 stack.
- http2_stream_state - Http2 stream state mutations.
- http_keepalive - gRPC keepalive pings.
- inproc - In-process transport.
- metadata_query - GCP metadata queries.
- op_failure - Error information when failure is pushed onto a completion queue. The `api` tracer must be enabled for this flag to have any effect.
- orca_client - Out-of-band backend metric reporting client.
- outlier_detection_lb - Outlier detection.
- pick_first - Pick first load balancing policy.
- plugin_credentials - Plugin credentials.
- priority_lb - Priority LB policy.
- queue_pluck - Completion queue plucking. The `api` tracer must be enabled for this flag to have any effect.
- resource_quota - Resource quota objects internals.
- retry - Call retries.
- ring_hash_lb - Ring hash load balancing policy.
- rls_lb - RLS load balancing policy.
- round_robin - Round robin load balancing policy.
- secure_endpoint - Bytes flowing through encrypted channels.
- server_channel - Lightweight trace of significant server channel events.
- stateful_session_filter - Stateful session affinity.
- subchannel - Connectivity state of subchannels.
- subchannel_pool - Subchannel pool.
- tcp - Bytes in and out of a channel.
- timer - Timers (alarms) in the grpc internals.
- timer_check - more detailed trace of timer logic in grpc internals.
- tsi - TSI transport security.
- weighted_round_robin_lb - Weighted round robin load balancing policy.
- weighted_target_lb - Weighted target LB policy.
- xds_client - XDS client.
- xds_client_refcount - Refcount of XDS client.
- xds_cluster_impl_lb - XDS Cluster impl LB policy.
- xds_cluster_manager_lb - XDS Cluster manager LB policy.
- xds_override_host_lb - XDS Override host LB.
- xds_resolver - XDS Resolver.
- xds_server_config_fetcher - XDS Server config fetcher.
- xds_wrr_locality_lb - XDS WRR locality LB policy.
The following tracers will only run in binaries built in DEBUG mode. This is
accomplished by invoking `bazel build --config=dbg <target>`
- auth_context_refcount - Auth context refcounting.
- call_combiner - Call combiner state.
- call_refcount - Refcount on call.
- closure - Legacy closure creation, scheduling, and completion.
- combiner - Combiner lock state.
- cq_refcount - Completion queue refcounting.
- error_refcount - Error refcounting.
- fd_refcount - File descriptor refcounting.
- fd_trace - Legacy file descriptor create(), shutdown() and close() calls for channel fds.
- lb_policy_refcount - LB policy refcounting.
- party_state - Coordination of activities related to a call.
- pending_tags - Still-in-progress tags on completion queues. The `api` tracer must be enabled for this flag to have any effect.
- polling - The active polling engine.
- polling_api - API calls to polling engine.
- promise_primitives - Low-level primitives in the promise library.
- resolver_refcount - Resolver refcouting.
- security_connector_refcount - Refcounting for security connectors (part of channel credentials).
- slice_refcount - Slice refcounting.
- stream_refcount - Stream refcounting.
- subchannel_refcount - Subchannel refcounting.
- work_serializer - A synchronization mechanism used to ensure that only one thread is executing at a given time.
Glob patterns and special cases:
- `*` can be used to turn all traces on.
- Individual traces can be disabled by prefixing them with `-`.
- `*refcount*` will turn on all of the tracers for refcount debugging.
- if `list_tracers` is present, then all of the available tracers will be
printed when the program starts up.
Example:
export GRPC_TRACE=*,-pending_tags

View File

@ -13,7 +13,7 @@
```
bazel build \
--extra_toolchains=@androidndk//:all \
--android_platforms=//bazel/platforms/android:x86_64,//bazel/platforms/android:armeabi-v7a,//bazel/platforms/android:arm64-v8a \
--android_platforms=//:android_x86_64,//:android_armv7,//:android_arm64 \
--copt=-Wno-unknown-warning-option \
//examples/android/binder/java/io/grpc/binder/cpp/exampleserver:app \
//examples/android/binder/java/io/grpc/binder/cpp/exampleclient:app

View File

@ -1,54 +0,0 @@
# Copyright 2024 the gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
licenses(["notice"])
cc_library(
name = "helper",
srcs = ["helper.cc"],
hdrs = ["helper.h"],
)
cc_binary(
name = "ssl_client",
srcs = ["ssl_client.cc"],
data = [
"credentials/root.crt",
],
defines = ["BAZEL_BUILD"],
deps = [
":helper",
"//:grpc++",
"//examples/protos:helloworld_cc_grpc",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
],
)
cc_binary(
name = "ssl_server",
srcs = ["ssl_server.cc"],
data = [
"credentials/localhost.crt",
"credentials/localhost.key",
],
defines = ["BAZEL_BUILD"],
deps = [
":helper",
"//:grpc++",
"//examples/protos:helloworld_cc_grpc",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
],
)

View File

@ -1,77 +0,0 @@
# Copyright 2024 the gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# cmake build file for C++ keyvaluestore example.
# Assumes protobuf and gRPC have been installed using cmake.
# See cmake_externalproject/CMakeLists.txt for all-in-one cmake build
# that automatically builds all the dependencies before building keyvaluestore.
cmake_minimum_required(VERSION 3.8)
project(Cancellation C CXX)
include(../cmake/common.cmake)
# Proto files
get_filename_component(hw_proto "../../protos/helloworld.proto" ABSOLUTE)
get_filename_component(hw_proto_path "${hw_proto}" PATH)
# Generated sources
set(hw_proto_srcs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.pb.cc")
set(hw_proto_hdrs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.pb.h")
set(hw_grpc_srcs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.grpc.pb.cc")
set(hw_grpc_hdrs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.grpc.pb.h")
add_custom_command(
OUTPUT "${hw_proto_srcs}" "${hw_proto_hdrs}" "${hw_grpc_srcs}" "${hw_grpc_hdrs}"
COMMAND ${_PROTOBUF_PROTOC}
ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}"
--cpp_out "${CMAKE_CURRENT_BINARY_DIR}"
-I "${hw_proto_path}"
--plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}"
"${hw_proto}"
DEPENDS "${hw_proto}")
# Include generated *.pb.h files
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
# hw_grpc_proto
add_library(hw_grpc_proto
${hw_grpc_srcs}
${hw_grpc_hdrs}
${hw_proto_srcs}
${hw_proto_hdrs})
target_link_libraries(hw_grpc_proto
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF})
# example helper
add_library(helper
"helper.h"
"helper.cc")
# Targets greeter_(client|server)
foreach(_target
ssl_client ssl_server)
add_executable(${_target} "${_target}.cc")
target_link_libraries(${_target}
helper
hw_grpc_proto
absl::flags
absl::flags_parse
absl::strings
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF})
endforeach()

View File

@ -1,39 +0,0 @@
# Authentication Example
## Overview
SSL is a commonly used cryptographic protocol to provide end-to-end
communication security. In the example, we show how to set up a server
authenticated SSL connection to transmit RPC.
We provide `grpc::SslServerCredentials` and `grpc::SslCredentials` types
to use SSL conections.
In our example, we use the public/private keys created ahead:
* "localhost.crt" contains the server certificate (public key).
* "localhost.key" contains the server private key.
* "root.crt" contains the certificate (certificate authority)
that can verify the server's certificate.
### Try it!
Once you have working gRPC, you can build this example using either bazel or cmake.
Make sure to run those at this directory so that they can read credential files properly.
Run the server, which will listen on port 50051:
```sh
$ ./ssl_server
```
Run the client (in a different terminal):
```sh
$ ./ssl_client
```
If things go smoothly, you will see the client output:
```
Greeter received: Hello world
```

View File

@ -1,19 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIDFjCCAf4CCQCzrLIhrWa55zANBgkqhkiG9w0BAQsFADBCMQswCQYDVQQGEwJV
UzETMBEGA1UECAwKQ2FsaWZvcm5pYTEPMA0GA1UECgwGR29vZ2xlMQ0wCwYDVQQL
DARnUlBDMCAXDTE5MDYyNDIyMjIzM1oYDzIxMTkwNTMxMjIyMjMzWjBWMQswCQYD
VQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEPMA0GA1UECgwGR29vZ2xlMQ0w
CwYDVQQLDARnUlBDMRIwEAYDVQQDDAlsb2NhbGhvc3QwggEiMA0GCSqGSIb3DQEB
AQUAA4IBDwAwggEKAoIBAQCtCW0TjugnIUu8BEVIYvdMP+/2GENQDjZhZ8eKR5C6
toDGbgjsDtt/GxISAg4cg70fIvy0XolnGPZodvfHDM4lJ7yHBOdZD8TXQoE6okR7
HZuLUJ20M0pXgWqtRewKRUjuYsSDXBnzLiZw1dcv9nGpo+Bqa8NonpiGRRpEkshF
D6T9KU9Ts/x+wMQBIra2Gj0UMh79jPhUuxcYAQA0JQGivnOtdwuPiumpnUT8j8h6
tWg5l01EsCZWJecCF85KnGpJEVYPyPqBqGsy0nGS9plGotOWF87+jyUQt+KD63xA
aBmTro86mKDDKEK4JvzjVeMGz2UbVcLPiiZnErTFaiXJAgMBAAEwDQYJKoZIhvcN
AQELBQADggEBAKsDgOPCWp5WCy17vJbRlgfgk05sVNIHZtzrmdswjBmvSg8MUpep
XqcPNUpsljAXsf9UM5IFEMRdilUsFGWvHjBEtNAW8WUK9UV18WRuU//0w1Mp5HAN
xUEKb4BoyZr65vlCnTR+AR5c9FfPvLibhr5qHs2RA8Y3GyLOcGqBWed87jhdQLCc
P1bxB+96le5JeXq0tw215lxonI2/3ZYVK4/ok9gwXrQoWm8YieJqitk/ZQ4S17/4
pynHtDfdxLn23EXeGx+UTxJGfpRmhEZdJ+MN7QGYoomzx5qS5XoYKxRNrDlirJpr
OqXIn8E1it+6d5gOZfuHawcNGhRLplE/pfA=
-----END CERTIFICATE-----

View File

@ -1,27 +0,0 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEArQltE47oJyFLvARFSGL3TD/v9hhDUA42YWfHikeQuraAxm4I
7A7bfxsSEgIOHIO9HyL8tF6JZxj2aHb3xwzOJSe8hwTnWQ/E10KBOqJEex2bi1Cd
tDNKV4FqrUXsCkVI7mLEg1wZ8y4mcNXXL/ZxqaPgamvDaJ6YhkUaRJLIRQ+k/SlP
U7P8fsDEASK2tho9FDIe/Yz4VLsXGAEANCUBor5zrXcLj4rpqZ1E/I/IerVoOZdN
RLAmViXnAhfOSpxqSRFWD8j6gahrMtJxkvaZRqLTlhfO/o8lELfig+t8QGgZk66P
OpigwyhCuCb841XjBs9lG1XCz4omZxK0xWolyQIDAQABAoIBADeq/Kh6JT3RfGf0
h8WN8TlaqHxnueAbcmtL0+oss+cdp7gu1jf7X6o4r0uT1a5ew40s2Fe+wj2kzkE1
ZOlouTlC22gkr7j7Vbxa7PBMG/Pvxoa/XL0IczZLsGImSJXVTG1E4SvRiZeulTdf
1GbdxhtpWV1jZe5Wd4Na3+SHxF5S7m3PrHiZlYdz1ND+8XZs1NlL9+ej72qSFul9
t/QjMWJ9pky/Wad5abnRLRyOsg+BsgnXbkUy2rD89ZxFMLda9pzXo3TPyAlBHonr
mkEsE4eRMWMpjBM79JbeyDdHn/cs/LjAZrzeDf7ugXr2CHQpKaM5O0PsNHezJII9
L5kCfzECgYEA4M/rz1UP1/BJoSqigUlSs0tPAg8a5UlkVsh6Osuq72IPNo8qg/Fw
oV/IiIS+q+obRcFj1Od3PGdTpCJwW5dzd2fXBQGmGdj0HucnCrs13RtBh91JiF5i
y/YYI9KfgOG2ZT9gG68T0gTs6jRrS3Qd83npqjrkJqMOd7s00MK9tUcCgYEAxQq7
T541oCYHSBRIIb0IrR25krZy9caxzCqPDwOcuuhaCqCiaq+ATvOWlSfgecm4eH0K
PCH0xlWxG0auPEwm4pA8+/WR/XJwscPZMuoht1EoKy1his4eKx/s7hHNeO6KOF0V
Y/zqIiuZnEwUoKbn7EqqNFSTT65PJKyGsICJFG8CgYAfaw9yl1myfQNdQb8aQGwN
YJ33FLNWje427qeeZe5KrDKiFloDvI9YDjHRWnPnRL1w/zj7fSm9yFb5HlMDieP6
MQnsyjEzdY2QcA+VwVoiv3dmDHgFVeOKy6bOAtaFxYWfGr9MvygO9t9BT/gawGyb
JVORlc9i0vDnrMMR1dV7awKBgBpTWLtGc/u1mPt0Wj7HtsUKV6TWY32a0l5owTxM
S0BdksogtBJ06DukJ9Y9wawD23WdnyRxlPZ6tHLkeprrwbY7dypioOKvy4a0l+xJ
g7+uRCOgqIuXBkjUtx8HmeAyXp0xMo5tWArAsIFFWOwt4IadYygitJvMuh44PraO
NcJZAoGADEiV0dheXUCVr8DrtSom8DQMj92/G/FIYjXL8OUhh0+F+YlYP0+F8PEU
yYIWEqL/S5tVKYshimUXQa537JcRKsTVJBG/ZKD2kuqgOc72zQy3oplimXeJDCXY
h2eAQ0u8GN6tN9C4t8Kp4a3y6FGsxgu+UTxdnL3YQ+yHAVhtCzo=
-----END RSA PRIVATE KEY-----

View File

@ -1,20 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIDWTCCAkGgAwIBAgIJAPOConZMwykwMA0GCSqGSIb3DQEBCwUAMEIxCzAJBgNV
BAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMQ8wDQYDVQQKDAZHb29nbGUxDTAL
BgNVBAsMBGdSUEMwIBcNMTkwNjI0MjIyMDA3WhgPMjExOTA1MzEyMjIwMDdaMEIx
CzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMQ8wDQYDVQQKDAZHb29n
bGUxDTALBgNVBAsMBGdSUEMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB
AQCwqei3TfyLidnQNDJ2lierMYo229K92DuORni7nSjJQ59Jc3dNMsmqGQJjCD8o
6mTlKM/oCbs27Wpx+OxcOLvT95j2kiDGca1fCvaMdguIod09SWiyMpv/hp0trLv7
NJIKHznath6rHYX2Ii3fZ1yCPzyQbEPSAA+GNpoNm1v1ZWmWKke9v7vLlS3inNlW
Mt9jepK7DrtbNZnVDjeItnppBSbVYRMxIyNHkepFbqXx5TpkCvl4M4XQZw9bfSxQ
i3WZ3q+T1Tw//OUdPNc+OfMhu0MA0QoMwikskP0NaIC3dbJZ5Ogx0RcnaB4E+9C6
O/znUEh3WuKVl5HXBF+UwWoFAgMBAAGjUDBOMB0GA1UdDgQWBBRm3JIgzgK4G97J
fbMGatWMZc7V3jAfBgNVHSMEGDAWgBRm3JIgzgK4G97JfbMGatWMZc7V3jAMBgNV
HRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQCNiV8x41if094ry2srS0YucpiN
3rTPk08FOLsENTMYai524TGXJti1P6ofGr5KXCL0uxTByHE3fEiMMud2TIY5iHQo
Y4mzDTTcb+Q7yKHwYZMlcp6nO8W+NeY5t+S0JPHhb8deKWepcN2UpXBUYQLw7AiE
l96T9Gi+vC9h/XE5IVwHFQXTxf5UYzXtW1nfapvrOONg/ms41dgmrRKIi+knWfiJ
FdHpHX2sfDAoJtnpEISX+nxRGNVTLY64utXWm4yxaZJshvy2s8zWJgRg7rtwAhTT
Np9E9MnihXLEmDI4Co9XlLPJyZFmqImsbmVuKFeQOCiLAoPJaMI2lbi7fiTo
-----END CERTIFICATE-----

View File

@ -1,34 +0,0 @@
/*
*
* Copyright 2024 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include "helper.h"
#include <fstream>
#include <iostream>
#include <sstream>
std::string LoadStringFromFile(std::string path) {
std::ifstream file(path);
if (!file.is_open()) {
std::cout << "Failed to open " << path << std::endl;
abort();
}
std::stringstream sstr;
sstr << file.rdbuf();
return sstr.str();
}

View File

@ -1,26 +0,0 @@
/*
*
* Copyright 2024 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPC_EXAMPLES_CPP_AUTH_HELPER_H_
#define GRPC_EXAMPLES_CPP_AUTH_HELPER_H_
#include <string>
std::string LoadStringFromFile(std::string path);
#endif // GRPC_EXAMPLES_CPP_AUTH_HELPER_H_

View File

@ -1,121 +0,0 @@
/*
*
* Copyright 2024 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <condition_variable>
#include <iostream>
#include <memory>
#include <mutex>
#include <string>
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "helper.h"
#include <grpcpp/grpcpp.h>
#ifdef BAZEL_BUILD
#include "examples/protos/helloworld.grpc.pb.h"
#else
#include "helloworld.grpc.pb.h"
#endif
ABSL_FLAG(uint16_t, port, 50051, "Server port for the service");
using grpc::Channel;
using grpc::ClientContext;
using grpc::Status;
using helloworld::Greeter;
using helloworld::HelloReply;
using helloworld::HelloRequest;
class GreeterClient {
public:
GreeterClient(std::shared_ptr<Channel> channel)
: stub_(Greeter::NewStub(channel)) {}
// Assembles the client's payload, sends it and presents the response back
// from the server.
std::string SayHello(const std::string& user) {
// Data we are sending to the server.
HelloRequest request;
request.set_name(user);
// Container for the data we expect from the server.
HelloReply reply;
// Context for the client. It could be used to convey extra information to
// the server and/or tweak certain RPC behaviors.
ClientContext context;
// The actual RPC.
std::mutex mu;
std::condition_variable cv;
bool done = false;
Status status;
stub_->async()->SayHello(&context, &request, &reply,
[&mu, &cv, &done, &status](Status s) {
status = std::move(s);
std::lock_guard<std::mutex> lock(mu);
done = true;
cv.notify_one();
});
std::unique_lock<std::mutex> lock(mu);
while (!done) {
cv.wait(lock);
}
// Act upon its status.
if (status.ok()) {
return reply.message();
} else {
std::cout << status.error_code() << ": " << status.error_message()
<< std::endl;
return "RPC failed";
}
}
private:
std::unique_ptr<Greeter::Stub> stub_;
};
#ifdef BAZEL_BUILD
constexpr char kRootCertificate[] = "examples/cpp/auth/credentials/root.crt";
#else
constexpr char kRootCertificate[] = "credentials/root.crt";
#endif
int main(int argc, char** argv) {
absl::ParseCommandLine(argc, argv);
// Instantiate the client. It requires a channel, out of which the actual RPCs
// are created. This channel models a connection to an endpoint specified by
// the argument "--target=" which is the only expected argument.
std::string target_str =
absl::StrFormat("localhost:%d", absl::GetFlag(FLAGS_port));
// Build a SSL options for the channel
grpc::SslCredentialsOptions ssl_options;
ssl_options.pem_root_certs = LoadStringFromFile(kRootCertificate);
// Create a channel with SSL credentials
GreeterClient greeter(
grpc::CreateChannel(target_str, grpc::SslCredentials(ssl_options)));
std::string user("world");
std::string reply = greeter.SayHello(user);
std::cout << "Greeter received: " << reply << std::endl;
return 0;
}

View File

@ -1,94 +0,0 @@
// Copyright 2024 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <iostream>
#include <memory>
#include <string>
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/strings/str_format.h"
#include "helper.h"
#include <grpcpp/grpcpp.h>
#ifdef BAZEL_BUILD
#include "examples/protos/helloworld.grpc.pb.h"
#else
#include "helloworld.grpc.pb.h"
#endif
ABSL_FLAG(uint16_t, port, 50051, "Server port for the service");
using grpc::CallbackServerContext;
using grpc::Server;
using grpc::ServerBuilder;
using grpc::ServerUnaryReactor;
using grpc::Status;
using helloworld::Greeter;
using helloworld::HelloReply;
using helloworld::HelloRequest;
// Logic and data behind the server's behavior.
class GreeterServiceImpl final : public Greeter::CallbackService {
ServerUnaryReactor* SayHello(CallbackServerContext* context,
const HelloRequest* request,
HelloReply* reply) override {
std::string prefix("Hello ");
reply->set_message(prefix + request->name());
ServerUnaryReactor* reactor = context->DefaultReactor();
reactor->Finish(Status::OK);
return reactor;
}
};
#ifdef BAZEL_BUILD
constexpr char kServerCertPath[] =
"examples/cpp/auth/credentials/localhost.crt";
constexpr char kServerKeyPath[] = "examples/cpp/auth/credentials/localhost.key";
#else
constexpr char kServerCertPath[] = "credentials/localhost.crt";
constexpr char kServerKeyPath[] = "credentials/localhost.key";
#endif
void RunServer(uint16_t port) {
std::string server_address = absl::StrFormat("0.0.0.0:%d", port);
GreeterServiceImpl service;
ServerBuilder builder;
// Load SSL credentials and build a SSL credential options
grpc::SslServerCredentialsOptions::PemKeyCertPair key_cert_pair = {
LoadStringFromFile(kServerKeyPath), LoadStringFromFile(kServerCertPath)};
grpc::SslServerCredentialsOptions ssl_options;
ssl_options.pem_key_cert_pairs.emplace_back(key_cert_pair);
// Listen on the given address with SSL credentials
builder.AddListeningPort(server_address,
grpc::SslServerCredentials(ssl_options));
// Register "service" as the instance through which we'll communicate with
// clients. In this case it corresponds to an *synchronous* service.
builder.RegisterService(&service);
// Finally assemble the server.
std::unique_ptr<Server> server(builder.BuildAndStart());
std::cout << "Server listening on " << server_address << std::endl;
// Wait for the server to shutdown. Note that some other thread must be
// responsible for shutting down the server for this call to ever return.
server->Wait();
}
int main(int argc, char** argv) {
absl::ParseCommandLine(argc, argv);
RunServer(absl::GetFlag(FLAGS_port));
return 0;
}

View File

@ -27,10 +27,10 @@ objc_grpc_library(
deps = ["//examples/protos:helloworld_proto"],
)
# This one works with import "third_party/com_github_grpc_grpc/examples/protos/Keyvaluestore.pbrpc.h"
# This one works with import "external/com_github_grpc_grpc/examples/protos/Keyvaluestore.pbrpc.h"
objc_grpc_library(
name = "Keyvaluestore_grpc_proto_external",
srcs = ["//third_party/com_github_grpc_grpc/examples/protos:keyvaluestore.proto"],
srcs = ["//external/com_github_grpc_grpc/examples/protos:keyvaluestore.proto"],
tags = ["manual"],
deps = ["@com_github_grpc_grpc//examples/protos:keyvaluestore_proto"],
)

View File

@ -1,46 +0,0 @@
# Copyright 2024 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
load("@grpc_python_dependencies//:requirements.bzl", "requirement")
# TODO(xuanwn): Instaed of using Bazel build, we should pip install all dependencies
# once we have a released version of grpcio-csm-observability.
py_binary(
name = "csm_greeter_client",
srcs = ["csm_greeter_client.py"],
python_version = "PY3",
deps = [
"//src/proto/grpc/testing:py_messages_proto",
"//src/proto/grpc/testing:py_test_proto",
"//src/proto/grpc/testing:test_py_pb2_grpc",
"//src/python/grpcio/grpc:grpcio",
"//src/python/grpcio_csm_observability/grpc_csm_observability:csm_observability",
requirement("opentelemetry-exporter-prometheus"),
],
)
py_binary(
name = "csm_greeter_server",
srcs = ["csm_greeter_server.py"],
python_version = "PY3",
deps = [
"//src/proto/grpc/testing:py_messages_proto",
"//src/proto/grpc/testing:py_test_proto",
"//src/proto/grpc/testing:test_py_pb2_grpc",
"//src/python/grpcio/grpc:grpcio",
"//src/python/grpcio_csm_observability/grpc_csm_observability:csm_observability",
requirement("opentelemetry-exporter-prometheus"),
],
)

View File

@ -1,26 +0,0 @@
FROM python:3.9-slim-bookworm
RUN apt-get update -y && apt-get upgrade -y && apt-get install -y build-essential clang curl
WORKDIR /workdir
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN mkdir /artifacts
COPY . .
RUN tools/bazel build -c dbg //examples/python/observability/csm:csm_greeter_client
RUN cp -rL /workdir/bazel-bin/examples/python/observability/csm/csm_greeter_client* /artifacts/
FROM python:3.9-slim-bookworm
RUN apt-get update -y \
&& apt-get install -y python3 \
&& apt-get -y autoremove \
&& apt-get install -y curl \
&& rm -rf /var/lib/apt/lists/*
RUN ln -s /usr/bin/python3 /usr/bin/python
COPY --from=0 /artifacts ./
ENTRYPOINT ["/csm_greeter_client"]

View File

@ -1,26 +0,0 @@
FROM python:3.9-slim-bookworm
RUN apt-get update -y && apt-get upgrade -y && apt-get install -y build-essential clang curl
WORKDIR /workdir
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN mkdir /artifacts
COPY . .
RUN tools/bazel build -c dbg //examples/python/observability/csm:csm_greeter_server
RUN cp -rL /workdir/bazel-bin/examples/python/observability/csm/csm_greeter_server* /artifacts/
FROM python:3.9-slim-bookworm
RUN apt-get update -y \
&& apt-get install -y python3 \
&& apt-get -y autoremove \
&& apt-get install -y curl \
&& rm -rf /var/lib/apt/lists/*
RUN ln -s /usr/bin/python3 /usr/bin/python
COPY --from=0 /artifacts ./
ENTRYPOINT ["/csm_greeter_server"]

View File

@ -1,33 +0,0 @@
# gRPC Python CSM Hello World Example
This CSM example builds on the [Python xDS Example](https://github.com/grpc/grpc/tree/master/examples/python/xds) and changes the gRPC client and server to accept configuration from an xDS control plane and test CSM observability.
## Configuration
The client takes the following command-line arguments -
* `--target` - By default, the client tries to connect to the target "xds:///helloworld:50051" and gRPC would use xDS to resolve this target and connect to the server backend. This can be overriden to change the target.
* `--secure_mode` - Whether to use xDS to retrieve server credentials. Default value is False.
* `--prometheus_endpoint` - Endpoint used for prometheus. Default value is localhost:9464.
The server takes the following command-line arguments -
* `--port` - Port on which the Hello World service is run. Defaults to 50051.
* `--secure_mode` - Whether to use xDS to retrieve server credentials. Default value is False.
* `--server_id` - The server ID to return in responses.
* `--prometheus_endpoint` - Endpoint used for prometheus. Default value is `localhost:9464`.
## Building
From the gRPC workspace folder:
Client:
```
docker build -f examples/python/observability/csm/Dockerfile.client -t "us-docker.pkg.dev/grpc-testing/examples/csm-o11y-example-python-client" .
```
Server:
```
docker build -f examples/python/observability/csm/Dockerfile.server -t "us-docker.pkg.dev/grpc-testing/examples/csm-o11y-example-python-server" .
```
And then push the tagged image using `docker push`.

View File

@ -1,101 +0,0 @@
# Copyright 2024 The gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
import logging
import time
import grpc
from grpc_csm_observability import CsmOpenTelemetryPlugin
from opentelemetry.exporter.prometheus import PrometheusMetricReader
from opentelemetry.sdk.metrics import MeterProvider
from prometheus_client import start_http_server
from src.proto.grpc.testing import messages_pb2
from src.proto.grpc.testing import test_pb2_grpc
logger = logging.getLogger()
console_handler = logging.StreamHandler()
formatter = logging.Formatter(fmt="%(asctime)s: %(levelname)-8s %(message)s")
console_handler.setFormatter(formatter)
logger.addHandler(console_handler)
def _run(target: int, secure_mode: bool, prometheus_endpoint: int):
csm_plugin = _prepare_csm_observability_plugin(prometheus_endpoint)
csm_plugin.register_global()
if secure_mode:
fallback_creds = grpc.experimental.insecure_channel_credentials()
channel_creds = grpc.xds_channel_credentials(fallback_creds)
channel = grpc.secure_channel(target, channel_creds)
else:
channel = grpc.insecure_channel(target)
with channel:
stub = test_pb2_grpc.TestServiceStub(channel)
# Continuously send RPCs every second.
while True:
request = messages_pb2.SimpleRequest()
logger.info("Sending request to server")
stub.UnaryCall(request)
time.sleep(1)
csm_plugin.deregister_global()
def _prepare_csm_observability_plugin(
prometheus_endpoint: int,
) -> CsmOpenTelemetryPlugin:
# Start Prometheus client
start_http_server(port=prometheus_endpoint, addr="0.0.0.0")
reader = PrometheusMetricReader()
meter_provider = MeterProvider(metric_readers=[reader])
csm_plugin = CsmOpenTelemetryPlugin(
meter_provider=meter_provider,
)
return csm_plugin
def bool_arg(arg: str) -> bool:
if arg.lower() in ("true", "yes", "y"):
return True
elif arg.lower() in ("false", "no", "n"):
return False
else:
raise argparse.ArgumentTypeError(f"Could not parse '{arg}' as a bool.")
if __name__ == "__main__":
logging.basicConfig()
logger.setLevel(logging.INFO)
parser = argparse.ArgumentParser(
description="Run Python CSM Observability Test client."
)
parser.add_argument(
"--target",
default="xds:///helloworld:50051",
help="The address of the server.",
)
parser.add_argument(
"--secure_mode",
default="False",
type=bool_arg,
help="If specified, uses xDS credentials to connect to the server.",
)
parser.add_argument(
"--prometheus_endpoint",
type=int,
default=9464,
help="Port for servers besides test server.",
)
args = parser.parse_args()
_run(args.target, args.secure_mode, args.prometheus_endpoint)

View File

@ -1,149 +0,0 @@
# Copyright 2024 The gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
from concurrent import futures
import logging
import socket
import grpc
from grpc_csm_observability import CsmOpenTelemetryPlugin
from opentelemetry.exporter.prometheus import PrometheusMetricReader
from opentelemetry.sdk.metrics import MeterProvider
from prometheus_client import start_http_server
from src.proto.grpc.testing import messages_pb2
from src.proto.grpc.testing import test_pb2_grpc
_LISTEN_HOST = "0.0.0.0"
_THREAD_POOL_SIZE = 256
logger = logging.getLogger()
console_handler = logging.StreamHandler()
formatter = logging.Formatter(fmt="%(asctime)s: %(levelname)-8s %(message)s")
console_handler.setFormatter(formatter)
logger.addHandler(console_handler)
class TestService(test_pb2_grpc.TestServiceServicer):
def __init__(self, server_id, hostname):
self._server_id = server_id
self._hostname = hostname
def UnaryCall(
self, request: messages_pb2.SimpleRequest, context: grpc.ServicerContext
) -> messages_pb2.SimpleResponse:
context.send_initial_metadata((("hostname", self._hostname),))
if request.response_size > 0:
response = messages_pb2.SimpleResponse(
payload=messages_pb2.Payload(body=b"0" * request.response_size)
)
else:
response = messages_pb2.SimpleResponse()
response.server_id = self._server_id
response.hostname = self._hostname
logger.info("Sending response to client")
return response
def _run(
port: int,
secure_mode: bool,
server_id: str,
prometheus_endpoint: int,
) -> None:
csm_plugin = _prepare_csm_observability_plugin(prometheus_endpoint)
csm_plugin.register_global()
server = grpc.server(
futures.ThreadPoolExecutor(max_workers=_THREAD_POOL_SIZE)
)
_configure_test_server(server, port, secure_mode, server_id)
server.start()
logger.info("Test server listening on port %d", port)
server.wait_for_termination()
csm_plugin.deregister_global()
def _prepare_csm_observability_plugin(
prometheus_endpoint: int,
) -> CsmOpenTelemetryPlugin:
# Start Prometheus client
start_http_server(port=prometheus_endpoint, addr="0.0.0.0")
reader = PrometheusMetricReader()
meter_provider = MeterProvider(metric_readers=[reader])
csm_plugin = CsmOpenTelemetryPlugin(
meter_provider=meter_provider,
)
return csm_plugin
def _configure_test_server(
server: grpc.Server, port: int, secure_mode: bool, server_id: str
) -> None:
test_pb2_grpc.add_TestServiceServicer_to_server(
TestService(server_id, socket.gethostname()), server
)
listen_address = f"{_LISTEN_HOST}:{port}"
if not secure_mode:
server.add_insecure_port(listen_address)
else:
logger.info("Running with xDS Server credentials")
server_fallback_creds = grpc.insecure_server_credentials()
server_creds = grpc.xds_server_credentials(server_fallback_creds)
server.add_secure_port(listen_address, server_creds)
def bool_arg(arg: str) -> bool:
if arg.lower() in ("true", "yes", "y"):
return True
elif arg.lower() in ("false", "no", "n"):
return False
else:
raise argparse.ArgumentTypeError(f"Could not parse '{arg}' as a bool.")
if __name__ == "__main__":
logging.basicConfig()
logger.setLevel(logging.INFO)
parser = argparse.ArgumentParser(
description="Run Python CSM Observability Test server."
)
parser.add_argument(
"--port", type=int, default=50051, help="Port for test server."
)
parser.add_argument(
"--secure_mode",
type=bool_arg,
default="False",
help="If specified, uses xDS to retrieve server credentials.",
)
parser.add_argument(
"--server_id",
type=str,
default="python_server",
help="The server ID to return in responses.",
)
parser.add_argument(
"--prometheus_endpoint",
type=int,
default=9464,
help="Port for servers besides test server.",
)
args = parser.parse_args()
_run(
args.port,
args.secure_mode,
args.server_id,
args.prometheus_endpoint,
)

18
gRPC-C++.podspec generated
View File

@ -365,6 +365,7 @@ Pod::Spec.new do |s|
'src/core/ext/transport/chttp2/transport/hpack_parser.h',
'src/core/ext/transport/chttp2/transport/hpack_parser_table.h',
'src/core/ext/transport/chttp2/transport/http2_settings.h',
'src/core/ext/transport/chttp2/transport/http_trace.h',
'src/core/ext/transport/chttp2/transport/huffsyms.h',
'src/core/ext/transport/chttp2/transport/internal.h',
'src/core/ext/transport/chttp2/transport/legacy_frame.h',
@ -881,6 +882,7 @@ Pod::Spec.new do |s|
'src/core/lib/channel/channel_stack.h',
'src/core/lib/channel/channel_stack_builder.h',
'src/core/lib/channel/channel_stack_builder_impl.h',
'src/core/lib/channel/channel_stack_trace.h',
'src/core/lib/channel/connected_channel.h',
'src/core/lib/channel/promise_based_filter.h',
'src/core/lib/channel/status_util.h',
@ -891,8 +893,6 @@ Pod::Spec.new do |s|
'src/core/lib/config/load_config.h',
'src/core/lib/debug/event_log.h',
'src/core/lib/debug/trace.h',
'src/core/lib/debug/trace_flags.h',
'src/core/lib/debug/trace_impl.h',
'src/core/lib/event_engine/ares_resolver.h',
'src/core/lib/event_engine/cf_engine/cf_engine.h',
'src/core/lib/event_engine/cf_engine/cfstream_endpoint.h',
@ -974,7 +974,6 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/env.h',
'src/core/lib/gprpp/examine_stack.h',
'src/core/lib/gprpp/fork.h',
'src/core/lib/gprpp/glob.h',
'src/core/lib/gprpp/host_port.h',
'src/core/lib/gprpp/if_list.h',
'src/core/lib/gprpp/load_file.h',
@ -1103,6 +1102,7 @@ Pod::Spec.new do |s|
'src/core/lib/promise/seq.h',
'src/core/lib/promise/sleep.h',
'src/core/lib/promise/status_flag.h',
'src/core/lib/promise/trace.h',
'src/core/lib/promise/try_join.h',
'src/core/lib/promise/try_seq.h',
'src/core/lib/resource_quota/api.h',
@ -1112,6 +1112,7 @@ Pod::Spec.new do |s|
'src/core/lib/resource_quota/periodic_update.h',
'src/core/lib/resource_quota/resource_quota.h',
'src/core/lib/resource_quota/thread_quota.h',
'src/core/lib/resource_quota/trace.h',
'src/core/lib/security/authorization/audit_logging.h',
'src/core/lib/security/authorization/authorization_engine.h',
'src/core/lib/security/authorization/authorization_policy_provider.h',
@ -1176,6 +1177,7 @@ Pod::Spec.new do |s|
'src/core/lib/surface/api_trace.h',
'src/core/lib/surface/call.h',
'src/core/lib/surface/call_test_only.h',
'src/core/lib/surface/call_trace.h',
'src/core/lib/surface/call_utils.h',
'src/core/lib/surface/channel.h',
'src/core/lib/surface/channel_create.h',
@ -1258,6 +1260,7 @@ Pod::Spec.new do |s|
'src/core/resolver/server_address.h',
'src/core/resolver/xds/xds_dependency_manager.h',
'src/core/resolver/xds/xds_resolver_attributes.h',
'src/core/resolver/xds/xds_resolver_trace.h',
'src/core/server/server.h',
'src/core/server/server_call_tracer_filter.h',
'src/core/server/server_config_selector.h',
@ -1638,6 +1641,7 @@ Pod::Spec.new do |s|
'src/core/ext/transport/chttp2/transport/hpack_parser.h',
'src/core/ext/transport/chttp2/transport/hpack_parser_table.h',
'src/core/ext/transport/chttp2/transport/http2_settings.h',
'src/core/ext/transport/chttp2/transport/http_trace.h',
'src/core/ext/transport/chttp2/transport/huffsyms.h',
'src/core/ext/transport/chttp2/transport/internal.h',
'src/core/ext/transport/chttp2/transport/legacy_frame.h',
@ -2154,6 +2158,7 @@ Pod::Spec.new do |s|
'src/core/lib/channel/channel_stack.h',
'src/core/lib/channel/channel_stack_builder.h',
'src/core/lib/channel/channel_stack_builder_impl.h',
'src/core/lib/channel/channel_stack_trace.h',
'src/core/lib/channel/connected_channel.h',
'src/core/lib/channel/promise_based_filter.h',
'src/core/lib/channel/status_util.h',
@ -2164,8 +2169,6 @@ Pod::Spec.new do |s|
'src/core/lib/config/load_config.h',
'src/core/lib/debug/event_log.h',
'src/core/lib/debug/trace.h',
'src/core/lib/debug/trace_flags.h',
'src/core/lib/debug/trace_impl.h',
'src/core/lib/event_engine/ares_resolver.h',
'src/core/lib/event_engine/cf_engine/cf_engine.h',
'src/core/lib/event_engine/cf_engine/cfstream_endpoint.h',
@ -2247,7 +2250,6 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/env.h',
'src/core/lib/gprpp/examine_stack.h',
'src/core/lib/gprpp/fork.h',
'src/core/lib/gprpp/glob.h',
'src/core/lib/gprpp/host_port.h',
'src/core/lib/gprpp/if_list.h',
'src/core/lib/gprpp/load_file.h',
@ -2376,6 +2378,7 @@ Pod::Spec.new do |s|
'src/core/lib/promise/seq.h',
'src/core/lib/promise/sleep.h',
'src/core/lib/promise/status_flag.h',
'src/core/lib/promise/trace.h',
'src/core/lib/promise/try_join.h',
'src/core/lib/promise/try_seq.h',
'src/core/lib/resource_quota/api.h',
@ -2385,6 +2388,7 @@ Pod::Spec.new do |s|
'src/core/lib/resource_quota/periodic_update.h',
'src/core/lib/resource_quota/resource_quota.h',
'src/core/lib/resource_quota/thread_quota.h',
'src/core/lib/resource_quota/trace.h',
'src/core/lib/security/authorization/audit_logging.h',
'src/core/lib/security/authorization/authorization_engine.h',
'src/core/lib/security/authorization/authorization_policy_provider.h',
@ -2449,6 +2453,7 @@ Pod::Spec.new do |s|
'src/core/lib/surface/api_trace.h',
'src/core/lib/surface/call.h',
'src/core/lib/surface/call_test_only.h',
'src/core/lib/surface/call_trace.h',
'src/core/lib/surface/call_utils.h',
'src/core/lib/surface/channel.h',
'src/core/lib/surface/channel_create.h',
@ -2531,6 +2536,7 @@ Pod::Spec.new do |s|
'src/core/resolver/server_address.h',
'src/core/resolver/xds/xds_dependency_manager.h',
'src/core/resolver/xds/xds_resolver_attributes.h',
'src/core/resolver/xds/xds_resolver_trace.h',
'src/core/server/server.h',
'src/core/server/server_call_tracer_filter.h',
'src/core/server/server_config_selector.h',

30
gRPC-Core.podspec generated
View File

@ -356,6 +356,8 @@ Pod::Spec.new do |s|
'src/core/ext/transport/chttp2/transport/hpack_parser_table.h',
'src/core/ext/transport/chttp2/transport/http2_settings.cc',
'src/core/ext/transport/chttp2/transport/http2_settings.h',
'src/core/ext/transport/chttp2/transport/http_trace.cc',
'src/core/ext/transport/chttp2/transport/http_trace.h',
'src/core/ext/transport/chttp2/transport/huffsyms.cc',
'src/core/ext/transport/chttp2/transport/huffsyms.h',
'src/core/ext/transport/chttp2/transport/internal.h',
@ -375,6 +377,7 @@ Pod::Spec.new do |s|
'src/core/ext/transport/chttp2/transport/write_size_policy.cc',
'src/core/ext/transport/chttp2/transport/write_size_policy.h',
'src/core/ext/transport/chttp2/transport/writing.cc',
'src/core/ext/transport/inproc/inproc_plugin.cc',
'src/core/ext/transport/inproc/inproc_transport.cc',
'src/core/ext/transport/inproc/inproc_transport.h',
'src/core/ext/transport/inproc/legacy_inproc_transport.cc',
@ -1219,6 +1222,8 @@ Pod::Spec.new do |s|
'src/core/lib/channel/channel_stack_builder.h',
'src/core/lib/channel/channel_stack_builder_impl.cc',
'src/core/lib/channel/channel_stack_builder_impl.h',
'src/core/lib/channel/channel_stack_trace.cc',
'src/core/lib/channel/channel_stack_trace.h',
'src/core/lib/channel/connected_channel.cc',
'src/core/lib/channel/connected_channel.h',
'src/core/lib/channel/promise_based_filter.cc',
@ -1241,9 +1246,6 @@ Pod::Spec.new do |s|
'src/core/lib/debug/event_log.h',
'src/core/lib/debug/trace.cc',
'src/core/lib/debug/trace.h',
'src/core/lib/debug/trace_flags.cc',
'src/core/lib/debug/trace_flags.h',
'src/core/lib/debug/trace_impl.h',
'src/core/lib/event_engine/ares_resolver.cc',
'src/core/lib/event_engine/ares_resolver.h',
'src/core/lib/event_engine/cf_engine/cf_engine.cc',
@ -1336,6 +1338,7 @@ Pod::Spec.new do |s|
'src/core/lib/event_engine/thready_event_engine/thready_event_engine.h',
'src/core/lib/event_engine/time_util.cc',
'src/core/lib/event_engine/time_util.h',
'src/core/lib/event_engine/trace.cc',
'src/core/lib/event_engine/trace.h',
'src/core/lib/event_engine/utils.cc',
'src/core/lib/event_engine/utils.h',
@ -1378,8 +1381,6 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/examine_stack.h',
'src/core/lib/gprpp/fork.cc',
'src/core/lib/gprpp/fork.h',
'src/core/lib/gprpp/glob.cc',
'src/core/lib/gprpp/glob.h',
'src/core/lib/gprpp/host_port.cc',
'src/core/lib/gprpp/host_port.h',
'src/core/lib/gprpp/if_list.h',
@ -1469,6 +1470,7 @@ Pod::Spec.new do |s|
'src/core/lib/iomgr/ev_poll_posix.h',
'src/core/lib/iomgr/ev_posix.cc',
'src/core/lib/iomgr/ev_posix.h',
'src/core/lib/iomgr/ev_windows.cc',
'src/core/lib/iomgr/event_engine_shims/closure.cc',
'src/core/lib/iomgr/event_engine_shims/closure.h',
'src/core/lib/iomgr/event_engine_shims/endpoint.cc',
@ -1611,6 +1613,8 @@ Pod::Spec.new do |s|
'src/core/lib/promise/sleep.cc',
'src/core/lib/promise/sleep.h',
'src/core/lib/promise/status_flag.h',
'src/core/lib/promise/trace.cc',
'src/core/lib/promise/trace.h',
'src/core/lib/promise/try_join.h',
'src/core/lib/promise/try_seq.h',
'src/core/lib/resource_quota/api.cc',
@ -1627,6 +1631,8 @@ Pod::Spec.new do |s|
'src/core/lib/resource_quota/resource_quota.h',
'src/core/lib/resource_quota/thread_quota.cc',
'src/core/lib/resource_quota/thread_quota.h',
'src/core/lib/resource_quota/trace.cc',
'src/core/lib/resource_quota/trace.h',
'src/core/lib/security/authorization/audit_logging.cc',
'src/core/lib/security/authorization/audit_logging.h',
'src/core/lib/security/authorization/authorization_engine.h',
@ -1751,9 +1757,11 @@ Pod::Spec.new do |s|
'src/core/lib/slice/slice_buffer.cc',
'src/core/lib/slice/slice_buffer.h',
'src/core/lib/slice/slice_internal.h',
'src/core/lib/slice/slice_refcount.cc',
'src/core/lib/slice/slice_refcount.h',
'src/core/lib/slice/slice_string_helpers.cc',
'src/core/lib/slice/slice_string_helpers.h',
'src/core/lib/surface/api_trace.cc',
'src/core/lib/surface/api_trace.h',
'src/core/lib/surface/byte_buffer.cc',
'src/core/lib/surface/byte_buffer_reader.cc',
@ -1762,6 +1770,7 @@ Pod::Spec.new do |s|
'src/core/lib/surface/call_details.cc',
'src/core/lib/surface/call_log_batch.cc',
'src/core/lib/surface/call_test_only.h',
'src/core/lib/surface/call_trace.h',
'src/core/lib/surface/call_utils.cc',
'src/core/lib/surface/call_utils.h',
'src/core/lib/surface/channel.cc',
@ -1929,6 +1938,8 @@ Pod::Spec.new do |s|
'src/core/resolver/xds/xds_dependency_manager.h',
'src/core/resolver/xds/xds_resolver.cc',
'src/core/resolver/xds/xds_resolver_attributes.h',
'src/core/resolver/xds/xds_resolver_trace.cc',
'src/core/resolver/xds/xds_resolver_trace.h',
'src/core/server/server.cc',
'src/core/server/server.h',
'src/core/server/server_call_tracer_filter.cc',
@ -2412,6 +2423,7 @@ Pod::Spec.new do |s|
'src/core/ext/transport/chttp2/transport/hpack_parser.h',
'src/core/ext/transport/chttp2/transport/hpack_parser_table.h',
'src/core/ext/transport/chttp2/transport/http2_settings.h',
'src/core/ext/transport/chttp2/transport/http_trace.h',
'src/core/ext/transport/chttp2/transport/huffsyms.h',
'src/core/ext/transport/chttp2/transport/internal.h',
'src/core/ext/transport/chttp2/transport/legacy_frame.h',
@ -2928,6 +2940,7 @@ Pod::Spec.new do |s|
'src/core/lib/channel/channel_stack.h',
'src/core/lib/channel/channel_stack_builder.h',
'src/core/lib/channel/channel_stack_builder_impl.h',
'src/core/lib/channel/channel_stack_trace.h',
'src/core/lib/channel/connected_channel.h',
'src/core/lib/channel/promise_based_filter.h',
'src/core/lib/channel/status_util.h',
@ -2938,8 +2951,6 @@ Pod::Spec.new do |s|
'src/core/lib/config/load_config.h',
'src/core/lib/debug/event_log.h',
'src/core/lib/debug/trace.h',
'src/core/lib/debug/trace_flags.h',
'src/core/lib/debug/trace_impl.h',
'src/core/lib/event_engine/ares_resolver.h',
'src/core/lib/event_engine/cf_engine/cf_engine.h',
'src/core/lib/event_engine/cf_engine/cfstream_endpoint.h',
@ -3021,7 +3032,6 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/env.h',
'src/core/lib/gprpp/examine_stack.h',
'src/core/lib/gprpp/fork.h',
'src/core/lib/gprpp/glob.h',
'src/core/lib/gprpp/host_port.h',
'src/core/lib/gprpp/if_list.h',
'src/core/lib/gprpp/load_file.h',
@ -3150,6 +3160,7 @@ Pod::Spec.new do |s|
'src/core/lib/promise/seq.h',
'src/core/lib/promise/sleep.h',
'src/core/lib/promise/status_flag.h',
'src/core/lib/promise/trace.h',
'src/core/lib/promise/try_join.h',
'src/core/lib/promise/try_seq.h',
'src/core/lib/resource_quota/api.h',
@ -3159,6 +3170,7 @@ Pod::Spec.new do |s|
'src/core/lib/resource_quota/periodic_update.h',
'src/core/lib/resource_quota/resource_quota.h',
'src/core/lib/resource_quota/thread_quota.h',
'src/core/lib/resource_quota/trace.h',
'src/core/lib/security/authorization/audit_logging.h',
'src/core/lib/security/authorization/authorization_engine.h',
'src/core/lib/security/authorization/authorization_policy_provider.h',
@ -3223,6 +3235,7 @@ Pod::Spec.new do |s|
'src/core/lib/surface/api_trace.h',
'src/core/lib/surface/call.h',
'src/core/lib/surface/call_test_only.h',
'src/core/lib/surface/call_trace.h',
'src/core/lib/surface/call_utils.h',
'src/core/lib/surface/channel.h',
'src/core/lib/surface/channel_create.h',
@ -3305,6 +3318,7 @@ Pod::Spec.new do |s|
'src/core/resolver/server_address.h',
'src/core/resolver/xds/xds_dependency_manager.h',
'src/core/resolver/xds/xds_resolver_attributes.h',
'src/core/resolver/xds/xds_resolver_trace.h',
'src/core/server/server.h',
'src/core/server/server_call_tracer_filter.h',
'src/core/server/server_config_selector.h',

21
grpc.gemspec generated
View File

@ -243,6 +243,8 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/transport/chttp2/transport/hpack_parser_table.h )
s.files += %w( src/core/ext/transport/chttp2/transport/http2_settings.cc )
s.files += %w( src/core/ext/transport/chttp2/transport/http2_settings.h )
s.files += %w( src/core/ext/transport/chttp2/transport/http_trace.cc )
s.files += %w( src/core/ext/transport/chttp2/transport/http_trace.h )
s.files += %w( src/core/ext/transport/chttp2/transport/huffsyms.cc )
s.files += %w( src/core/ext/transport/chttp2/transport/huffsyms.h )
s.files += %w( src/core/ext/transport/chttp2/transport/internal.h )
@ -262,6 +264,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/transport/chttp2/transport/write_size_policy.cc )
s.files += %w( src/core/ext/transport/chttp2/transport/write_size_policy.h )
s.files += %w( src/core/ext/transport/chttp2/transport/writing.cc )
s.files += %w( src/core/ext/transport/inproc/inproc_plugin.cc )
s.files += %w( src/core/ext/transport/inproc/inproc_transport.cc )
s.files += %w( src/core/ext/transport/inproc/inproc_transport.h )
s.files += %w( src/core/ext/transport/inproc/legacy_inproc_transport.cc )
@ -1106,6 +1109,8 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/channel/channel_stack_builder.h )
s.files += %w( src/core/lib/channel/channel_stack_builder_impl.cc )
s.files += %w( src/core/lib/channel/channel_stack_builder_impl.h )
s.files += %w( src/core/lib/channel/channel_stack_trace.cc )
s.files += %w( src/core/lib/channel/channel_stack_trace.h )
s.files += %w( src/core/lib/channel/connected_channel.cc )
s.files += %w( src/core/lib/channel/connected_channel.h )
s.files += %w( src/core/lib/channel/promise_based_filter.cc )
@ -1128,9 +1133,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/debug/event_log.h )
s.files += %w( src/core/lib/debug/trace.cc )
s.files += %w( src/core/lib/debug/trace.h )
s.files += %w( src/core/lib/debug/trace_flags.cc )
s.files += %w( src/core/lib/debug/trace_flags.h )
s.files += %w( src/core/lib/debug/trace_impl.h )
s.files += %w( src/core/lib/event_engine/ares_resolver.cc )
s.files += %w( src/core/lib/event_engine/ares_resolver.h )
s.files += %w( src/core/lib/event_engine/cf_engine/cf_engine.cc )
@ -1223,6 +1225,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/event_engine/thready_event_engine/thready_event_engine.h )
s.files += %w( src/core/lib/event_engine/time_util.cc )
s.files += %w( src/core/lib/event_engine/time_util.h )
s.files += %w( src/core/lib/event_engine/trace.cc )
s.files += %w( src/core/lib/event_engine/trace.h )
s.files += %w( src/core/lib/event_engine/utils.cc )
s.files += %w( src/core/lib/event_engine/utils.h )
@ -1265,8 +1268,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/gprpp/examine_stack.h )
s.files += %w( src/core/lib/gprpp/fork.cc )
s.files += %w( src/core/lib/gprpp/fork.h )
s.files += %w( src/core/lib/gprpp/glob.cc )
s.files += %w( src/core/lib/gprpp/glob.h )
s.files += %w( src/core/lib/gprpp/host_port.cc )
s.files += %w( src/core/lib/gprpp/host_port.h )
s.files += %w( src/core/lib/gprpp/if_list.h )
@ -1356,6 +1357,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/iomgr/ev_poll_posix.h )
s.files += %w( src/core/lib/iomgr/ev_posix.cc )
s.files += %w( src/core/lib/iomgr/ev_posix.h )
s.files += %w( src/core/lib/iomgr/ev_windows.cc )
s.files += %w( src/core/lib/iomgr/event_engine_shims/closure.cc )
s.files += %w( src/core/lib/iomgr/event_engine_shims/closure.h )
s.files += %w( src/core/lib/iomgr/event_engine_shims/endpoint.cc )
@ -1498,6 +1500,8 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/promise/sleep.cc )
s.files += %w( src/core/lib/promise/sleep.h )
s.files += %w( src/core/lib/promise/status_flag.h )
s.files += %w( src/core/lib/promise/trace.cc )
s.files += %w( src/core/lib/promise/trace.h )
s.files += %w( src/core/lib/promise/try_join.h )
s.files += %w( src/core/lib/promise/try_seq.h )
s.files += %w( src/core/lib/resource_quota/api.cc )
@ -1514,6 +1518,8 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/resource_quota/resource_quota.h )
s.files += %w( src/core/lib/resource_quota/thread_quota.cc )
s.files += %w( src/core/lib/resource_quota/thread_quota.h )
s.files += %w( src/core/lib/resource_quota/trace.cc )
s.files += %w( src/core/lib/resource_quota/trace.h )
s.files += %w( src/core/lib/security/authorization/audit_logging.cc )
s.files += %w( src/core/lib/security/authorization/audit_logging.h )
s.files += %w( src/core/lib/security/authorization/authorization_engine.h )
@ -1638,9 +1644,11 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/slice/slice_buffer.cc )
s.files += %w( src/core/lib/slice/slice_buffer.h )
s.files += %w( src/core/lib/slice/slice_internal.h )
s.files += %w( src/core/lib/slice/slice_refcount.cc )
s.files += %w( src/core/lib/slice/slice_refcount.h )
s.files += %w( src/core/lib/slice/slice_string_helpers.cc )
s.files += %w( src/core/lib/slice/slice_string_helpers.h )
s.files += %w( src/core/lib/surface/api_trace.cc )
s.files += %w( src/core/lib/surface/api_trace.h )
s.files += %w( src/core/lib/surface/byte_buffer.cc )
s.files += %w( src/core/lib/surface/byte_buffer_reader.cc )
@ -1649,6 +1657,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/surface/call_details.cc )
s.files += %w( src/core/lib/surface/call_log_batch.cc )
s.files += %w( src/core/lib/surface/call_test_only.h )
s.files += %w( src/core/lib/surface/call_trace.h )
s.files += %w( src/core/lib/surface/call_utils.cc )
s.files += %w( src/core/lib/surface/call_utils.h )
s.files += %w( src/core/lib/surface/channel.cc )
@ -1816,6 +1825,8 @@ Gem::Specification.new do |s|
s.files += %w( src/core/resolver/xds/xds_dependency_manager.h )
s.files += %w( src/core/resolver/xds/xds_resolver.cc )
s.files += %w( src/core/resolver/xds/xds_resolver_attributes.h )
s.files += %w( src/core/resolver/xds/xds_resolver_trace.cc )
s.files += %w( src/core/resolver/xds/xds_resolver_trace.h )
s.files += %w( src/core/server/server.cc )
s.files += %w( src/core/server/server.h )
s.files += %w( src/core/server/server_call_tracer_filter.cc )

View File

@ -132,6 +132,8 @@ class EventEngine : public std::enable_shared_from_this<EventEngine>,
struct TaskHandle {
intptr_t keys[2];
static const GRPC_DLL TaskHandle kInvalid;
friend bool operator==(const TaskHandle& lhs, const TaskHandle& rhs);
friend bool operator!=(const TaskHandle& lhs, const TaskHandle& rhs);
};
/// A handle to a cancellable connection attempt.
///
@ -139,6 +141,10 @@ class EventEngine : public std::enable_shared_from_this<EventEngine>,
struct ConnectionHandle {
intptr_t keys[2];
static const GRPC_DLL ConnectionHandle kInvalid;
friend bool operator==(const ConnectionHandle& lhs,
const ConnectionHandle& rhs);
friend bool operator!=(const ConnectionHandle& lhs,
const ConnectionHandle& rhs);
};
/// Thin wrapper around a platform-specific sockaddr type. A sockaddr struct
/// exists on all platforms that gRPC supports.
@ -490,19 +496,6 @@ void EventEngineFactoryReset();
/// Create an EventEngine using the default factory.
std::unique_ptr<EventEngine> CreateEventEngine();
bool operator==(const EventEngine::TaskHandle& lhs,
const EventEngine::TaskHandle& rhs);
bool operator!=(const EventEngine::TaskHandle& lhs,
const EventEngine::TaskHandle& rhs);
std::ostream& operator<<(std::ostream& out,
const EventEngine::TaskHandle& handle);
bool operator==(const EventEngine::ConnectionHandle& lhs,
const EventEngine::ConnectionHandle& rhs);
bool operator!=(const EventEngine::ConnectionHandle& lhs,
const EventEngine::ConnectionHandle& rhs);
std::ostream& operator<<(std::ostream& out,
const EventEngine::ConnectionHandle& handle);
} // namespace experimental
} // namespace grpc_event_engine

View File

@ -398,8 +398,6 @@
* If unspecified, it is unlimited */
#define GRPC_ARG_MAX_ALLOWED_INCOMING_CONNECTIONS \
"grpc.max_allowed_incoming_connections"
/** Configure per-channel or per-server stats plugins. */
#define GRPC_ARG_EXPERIMENTAL_STATS_PLUGINS "grpc.experimental.stats_plugins"
/** \} */
#endif /* GRPC_IMPL_CHANNEL_ARG_NAMES_H */

View File

@ -82,7 +82,6 @@ struct gpr_log_func_args {
typedef struct gpr_log_func_args gpr_log_func_args;
typedef void (*gpr_log_func)(gpr_log_func_args* args);
GPRAPI void gpr_set_log_function(gpr_log_func func);
GPRAPI void gpr_assertion_failed(const char* filename, int line,

View File

@ -272,9 +272,6 @@
#define GPR_PLATFORM_STRING "ios"
#define GPR_CPU_IPHONE 1
#define GRPC_CFSTREAM 1
#ifndef GRPC_IOS_EVENT_ENGINE_CLIENT
#define GRPC_IOS_EVENT_ENGINE_CLIENT 1
#endif /* GRPC_IOS_EVENT_ENGINE_CLIENT */
/* the c-ares resolver isn't safe to enable on iOS */
#define GRPC_ARES 0
#else /* TARGET_OS_IPHONE */

View File

@ -26,18 +26,17 @@
#include "absl/functional/any_invocable.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
#include "opentelemetry/metrics/meter_provider.h"
#include <grpc/support/metrics.h>
#include <grpc/support/port_platform.h>
#include <grpcpp/server_builder.h>
#include <grpcpp/support/channel_arguments.h>
namespace grpc {
namespace internal {
class OpenTelemetryPluginBuilderImpl;
class OpenTelemetryPlugin;
} // namespace internal
class OpenTelemetryPluginOption {
@ -45,21 +44,6 @@ class OpenTelemetryPluginOption {
virtual ~OpenTelemetryPluginOption() = default;
};
namespace experimental {
/// EXPERIMENTAL API
class OpenTelemetryPlugin {
public:
virtual ~OpenTelemetryPlugin() = default;
/// EXPERIMENTAL API
/// Adds this OpenTelemetryPlugin to the channel args \a args.
virtual void AddToChannelArguments(grpc::ChannelArguments* args) = 0;
/// EXPERIMENTAL API
/// Adds this OpenTelemetryPlugin to the channel arguments that will be used
/// to create the server through \a builder.
virtual void AddToServerBuilder(grpc::ServerBuilder* builder) = 0;
};
} // namespace experimental
/// The most common way to use this API is -
///
/// OpenTelemetryPluginBuilder().SetMeterProvider(provider).BuildAndRegister();
@ -129,8 +113,8 @@ class OpenTelemetryPluginBuilder {
/// If set, \a generic_method_attribute_filter is called per call with a
/// generic method type to decide whether to record the method name or to
/// replace it with "other". Non-generic or pre-registered methods remain
/// unaffected. If not set, by default, generic method names are replaced
/// with "other" when recording metrics.
/// unaffected. If not set, by default, generic method names are replaced with
/// "other" when recording metrics.
OpenTelemetryPluginBuilder& SetGenericMethodAttributeFilter(
absl::AnyInvocable<bool(absl::string_view /*generic_method*/) const>
generic_method_attribute_filter);
@ -155,16 +139,9 @@ class OpenTelemetryPluginBuilder {
OpenTelemetryPluginBuilder& SetChannelScopeFilter(
absl::AnyInvocable<bool(const ChannelScope& /*scope*/) const>
channel_scope_filter);
/// Builds and registers a global plugin that acts on all channels and servers
/// running on the process. Must be called no more than once and must not be
/// called if Build() is called.
/// Registers a global plugin that acts on all channels and servers running on
/// the process.
absl::Status BuildAndRegisterGlobal();
/// EXPERIMENTAL API
/// Builds an open telemetry plugin, returns the plugin object when succeeded
/// or an error status when failed. Must be called no more than once and must
/// not be called if BuildAndRegisterGlobal() is called.
GRPC_MUST_USE_RESULT
absl::StatusOr<std::shared_ptr<experimental::OpenTelemetryPlugin>> Build();
private:
std::unique_ptr<internal::OpenTelemetryPluginBuilderImpl> impl_;

21
package.xml generated
View File

@ -225,6 +225,8 @@
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/hpack_parser_table.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/http2_settings.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/http2_settings.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/http_trace.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/http_trace.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/huffsyms.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/huffsyms.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/internal.h" role="src" />
@ -244,6 +246,7 @@
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/write_size_policy.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/write_size_policy.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/writing.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/inproc/inproc_plugin.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/inproc/inproc_transport.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/inproc/inproc_transport.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/inproc/legacy_inproc_transport.cc" role="src" />
@ -1088,6 +1091,8 @@
<file baseinstalldir="/" name="src/core/lib/channel/channel_stack_builder.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/channel_stack_builder_impl.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/channel_stack_builder_impl.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/channel_stack_trace.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/channel_stack_trace.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/connected_channel.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/connected_channel.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/promise_based_filter.cc" role="src" />
@ -1110,9 +1115,6 @@
<file baseinstalldir="/" name="src/core/lib/debug/event_log.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/debug/trace.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/debug/trace.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/debug/trace_flags.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/debug/trace_flags.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/debug/trace_impl.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/ares_resolver.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/ares_resolver.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/cf_engine/cf_engine.cc" role="src" />
@ -1205,6 +1207,7 @@
<file baseinstalldir="/" name="src/core/lib/event_engine/thready_event_engine/thready_event_engine.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/time_util.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/time_util.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/trace.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/trace.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/utils.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/utils.h" role="src" />
@ -1247,8 +1250,6 @@
<file baseinstalldir="/" name="src/core/lib/gprpp/examine_stack.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/fork.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/fork.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/glob.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/glob.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/host_port.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/host_port.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/if_list.h" role="src" />
@ -1338,6 +1339,7 @@
<file baseinstalldir="/" name="src/core/lib/iomgr/ev_poll_posix.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/ev_posix.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/ev_posix.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/ev_windows.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/event_engine_shims/closure.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/event_engine_shims/closure.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/event_engine_shims/endpoint.cc" role="src" />
@ -1480,6 +1482,8 @@
<file baseinstalldir="/" name="src/core/lib/promise/sleep.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/promise/sleep.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/promise/status_flag.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/promise/trace.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/promise/trace.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/promise/try_join.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/promise/try_seq.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/resource_quota/api.cc" role="src" />
@ -1496,6 +1500,8 @@
<file baseinstalldir="/" name="src/core/lib/resource_quota/resource_quota.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/resource_quota/thread_quota.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/resource_quota/thread_quota.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/resource_quota/trace.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/resource_quota/trace.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/security/authorization/audit_logging.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/security/authorization/audit_logging.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/security/authorization/authorization_engine.h" role="src" />
@ -1620,9 +1626,11 @@
<file baseinstalldir="/" name="src/core/lib/slice/slice_buffer.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/slice_buffer.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/slice_internal.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/slice_refcount.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/slice_refcount.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/slice_string_helpers.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/slice_string_helpers.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/api_trace.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/api_trace.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/byte_buffer.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/byte_buffer_reader.cc" role="src" />
@ -1631,6 +1639,7 @@
<file baseinstalldir="/" name="src/core/lib/surface/call_details.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/call_log_batch.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/call_test_only.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/call_trace.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/call_utils.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/call_utils.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/channel.cc" role="src" />
@ -1798,6 +1807,8 @@
<file baseinstalldir="/" name="src/core/resolver/xds/xds_dependency_manager.h" role="src" />
<file baseinstalldir="/" name="src/core/resolver/xds/xds_resolver.cc" role="src" />
<file baseinstalldir="/" name="src/core/resolver/xds/xds_resolver_attributes.h" role="src" />
<file baseinstalldir="/" name="src/core/resolver/xds/xds_resolver_trace.cc" role="src" />
<file baseinstalldir="/" name="src/core/resolver/xds/xds_resolver_trace.h" role="src" />
<file baseinstalldir="/" name="src/core/server/server.cc" role="src" />
<file baseinstalldir="/" name="src/core/server/server.h" role="src" />
<file baseinstalldir="/" name="src/core/server/server_call_tracer_filter.cc" role="src" />

View File

@ -547,6 +547,7 @@ grpc_cc_library(
"pipe",
"poll",
"promise_factory",
"promise_trace",
"try_seq",
"//:gpr",
"//:gpr_platform",
@ -576,11 +577,11 @@ grpc_cc_library(
"context",
"poll",
"promise_factory",
"promise_trace",
"ref_counted",
"//:event_engine_base_hdrs",
"//:exec_ctx",
"//:gpr",
"//:grpc_trace",
"//:ref_counted_ptr",
],
)
@ -795,8 +796,9 @@ grpc_cc_library(
"construct_destruct",
"poll",
"promise_like",
"promise_trace",
"//:gpr",
"//:grpc_trace",
"//:gpr_platform",
],
)
@ -885,9 +887,9 @@ grpc_cc_library(
"poll",
"promise_factory",
"promise_like",
"promise_trace",
"//:debug_location",
"//:gpr",
"//:grpc_trace",
],
)
@ -1023,8 +1025,8 @@ grpc_cc_library(
deps = [
"activity",
"poll",
"promise_trace",
"//:gpr",
"//:grpc_trace",
],
)
@ -1042,9 +1044,9 @@ grpc_cc_library(
deps = [
"activity",
"poll",
"promise_trace",
"wait_set",
"//:gpr",
"//:grpc_trace",
],
)
@ -1066,6 +1068,7 @@ grpc_cc_library(
"context",
"poll",
"promise_factory",
"promise_trace",
"//:debug_location",
"//:gpr",
],
@ -1092,6 +1095,7 @@ grpc_cc_library(
"interceptor_list",
"map",
"poll",
"promise_trace",
"seq",
"//:debug_location",
"//:gpr",
@ -1132,6 +1136,21 @@ grpc_cc_library(
],
)
grpc_cc_library(
name = "promise_trace",
srcs = [
"lib/promise/trace.cc",
],
hdrs = [
"lib/promise/trace.h",
],
language = "c++",
deps = [
"//:gpr_platform",
"//:grpc_trace",
],
)
grpc_cc_library(
name = "mpsc",
hdrs = [
@ -1186,10 +1205,10 @@ grpc_cc_library(
"poll",
"promise_factory",
"promise_status",
"promise_trace",
"status_flag",
"//:gpr",
"//:gpr_platform",
"//:grpc_trace",
],
)
@ -1426,6 +1445,7 @@ grpc_cc_library(
"periodic_update",
"poll",
"race",
"resource_quota_trace",
"seq",
"slice_refcount",
"time",
@ -1516,6 +1536,20 @@ grpc_cc_library(
],
)
grpc_cc_library(
name = "resource_quota_trace",
srcs = [
"lib/resource_quota/trace.cc",
],
hdrs = [
"lib/resource_quota/trace.h",
],
deps = [
"//:gpr_platform",
"//:grpc_trace",
],
)
grpc_cc_library(
name = "resource_quota",
srcs = [
@ -1544,6 +1578,9 @@ grpc_cc_library(
grpc_cc_library(
name = "slice_refcount",
srcs = [
"lib/slice/slice_refcount.cc",
],
hdrs = [
"lib/slice/slice_refcount.h",
],
@ -2456,7 +2493,6 @@ grpc_cc_library(
"ares_resolver",
"channel_args_endpoint_config",
"common_event_engine_closures",
"dump_args",
"error",
"event_engine_common",
"event_engine_tcp_socket_utils",
@ -2651,9 +2687,11 @@ grpc_cc_library(
],
)
# TODO(hork): delete this target when refactoring to GRPC_TRACE_LOG(flag, level)
grpc_cc_library(
name = "event_engine_trace",
srcs = [
"lib/event_engine/trace.cc",
],
hdrs = [
"lib/event_engine/trace.h",
],
@ -2694,7 +2732,6 @@ grpc_cc_library(
{
"//:windows": ["windows_event_engine"],
"//:windows_msvc": ["windows_event_engine"],
"//:windows_clang": ["windows_event_engine"],
"//:windows_other": ["windows_event_engine"],
"//:mac": [
"posix_event_engine",
@ -3068,6 +3105,21 @@ grpc_cc_library(
deps = ["//:gpr_platform"],
)
grpc_cc_library(
name = "channel_stack_trace",
srcs = [
"lib/channel/channel_stack_trace.cc",
],
hdrs = [
"lib/channel/channel_stack_trace.h",
],
language = "c++",
deps = [
"//:gpr_platform",
"//:grpc_trace",
],
)
grpc_cc_library(
name = "channel_init",
srcs = [
@ -3088,6 +3140,7 @@ grpc_cc_library(
"call_filters",
"channel_args",
"channel_fwd",
"channel_stack_trace",
"channel_stack_type",
"interception_chain",
"//:channel_stack_builder",
@ -4712,6 +4765,7 @@ grpc_cc_library(
"slice",
"slice_buffer",
"validation_errors",
"//:call_trace",
"//:channel_arg_names",
"//:config",
"//:gpr",
@ -4870,7 +4924,6 @@ grpc_cc_library(
"absl/container:inlined_vector",
"absl/functional:function_ref",
"absl/log:check",
"absl/log:globals",
"absl/log:log",
"absl/status",
"absl/status:statusor",
@ -5750,13 +5803,6 @@ grpc_cc_library(
deps = ["//:gpr"],
)
grpc_cc_library(
name = "glob",
srcs = ["lib/gprpp/glob.cc"],
hdrs = ["lib/gprpp/glob.h"],
external_deps = ["absl/strings"],
)
grpc_cc_library(
name = "status_conversion",
srcs = ["lib/transport/status_conversion.cc"],
@ -6533,6 +6579,21 @@ grpc_cc_library(
],
)
grpc_cc_library(
name = "grpc_resolver_xds_trace",
srcs = [
"resolver/xds/xds_resolver_trace.cc",
],
hdrs = [
"resolver/xds/xds_resolver_trace.h",
],
language = "c++",
deps = [
"//:gpr_platform",
"//:grpc_trace",
],
)
grpc_cc_library(
name = "xds_dependency_manager",
srcs = [
@ -6551,6 +6612,7 @@ grpc_cc_library(
language = "c++",
deps = [
"grpc_lb_xds_channel_args",
"grpc_resolver_xds_trace",
"grpc_xds_client",
"match",
"ref_counted",
@ -6592,6 +6654,7 @@ grpc_cc_library(
"experiments",
"grpc_lb_policy_ring_hash",
"grpc_resolver_xds_attributes",
"grpc_resolver_xds_trace",
"grpc_service_config",
"grpc_xds_client",
"iomgr_fwd",
@ -7001,6 +7064,7 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_transport_inproc",
srcs = [
"ext/transport/inproc/inproc_plugin.cc",
"ext/transport/inproc/inproc_transport.cc",
"ext/transport/inproc/legacy_inproc_transport.cc",
],
@ -7263,6 +7327,9 @@ grpc_cc_library(
grpc_cc_library(
name = "chaotic_good_transport",
srcs = [
"ext/transport/chaotic_good/chaotic_good_transport.cc",
],
hdrs = [
"ext/transport/chaotic_good/chaotic_good_transport.h",
],
@ -7826,7 +7893,6 @@ grpc_cc_library(
"absl/functional:function_ref",
"absl/log:check",
"absl/strings",
"absl/types:optional",
"absl/types:span",
],
language = "c++",

View File

@ -100,6 +100,12 @@ using grpc_event_engine::experimental::EventEngine;
using internal::ClientChannelMethodParsedConfig;
// Defined in legacy client channel filter.
// TODO(roth): Move these here when we remove the legacy filter.
extern TraceFlag grpc_client_channel_trace;
extern TraceFlag grpc_client_channel_call_trace;
extern TraceFlag grpc_client_channel_lb_call_trace;
//
// ClientChannel::ResolverResultHandler
//
@ -111,9 +117,10 @@ class ClientChannel::ResolverResultHandler : public Resolver::ResultHandler {
: client_channel_(std::move(client_channel)) {}
~ResolverResultHandler() override {
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << client_channel_.get()
<< ": resolver shutdown complete";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "client_channel=%p: resolver shutdown complete",
client_channel_.get());
}
}
void ReportResult(Resolver::Result result) override
@ -229,12 +236,14 @@ class ClientChannel::SubchannelWrapper::WatcherWrapper
void OnConnectivityStateChange(
RefCountedPtr<ConnectivityStateWatcherInterface> self,
grpc_connectivity_state state, const absl::Status& status) override {
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << subchannel_wrapper_->client_channel_.get()
<< ": connectivity change for subchannel wrapper "
<< subchannel_wrapper_.get() << " subchannel "
<< subchannel_wrapper_->subchannel_.get()
<< "; hopping into work_serializer";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO,
"client_channel=%p: connectivity change for subchannel "
"wrapper %p subchannel %p; hopping into work_serializer",
subchannel_wrapper_->client_channel_.get(),
subchannel_wrapper_.get(),
subchannel_wrapper_->subchannel_.get());
}
self.release(); // Held by callback.
subchannel_wrapper_->client_channel_->work_serializer_->Run(
[this, state, status]() ABSL_EXCLUSIVE_LOCKS_REQUIRED(
@ -252,14 +261,16 @@ class ClientChannel::SubchannelWrapper::WatcherWrapper
const absl::Status& status)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(
*subchannel_wrapper_->client_channel_->work_serializer_) {
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << subchannel_wrapper_->client_channel_.get()
<< ": processing connectivity change in work serializer for subchannel "
"wrapper "
<< subchannel_wrapper_.get() << " subchannel "
<< subchannel_wrapper_->subchannel_.get()
<< " watcher=" << watcher_.get()
<< "state=" << ConnectivityStateName(state) << " status=" << status;
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO,
"client_channel=%p: processing connectivity change in work "
"serializer for subchannel wrapper %p subchannel %p watcher=%p "
"state=%s status=%s",
subchannel_wrapper_->client_channel_.get(),
subchannel_wrapper_.get(), subchannel_wrapper_->subchannel_.get(),
watcher_.get(), ConnectivityStateName(state),
status.ToString().c_str());
}
absl::optional<absl::Cord> keepalive_throttling =
status.GetPayload(kKeepaliveThrottlingKey);
if (keepalive_throttling.has_value()) {
@ -270,10 +281,12 @@ class ClientChannel::SubchannelWrapper::WatcherWrapper
subchannel_wrapper_->client_channel_->keepalive_time_) {
subchannel_wrapper_->client_channel_->keepalive_time_ =
new_keepalive_time;
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << subchannel_wrapper_->client_channel_.get()
<< ": throttling keepalive time to "
<< subchannel_wrapper_->client_channel_->keepalive_time_;
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO,
"client_channel=%p: throttling keepalive time to %d",
subchannel_wrapper_->client_channel_.get(),
subchannel_wrapper_->client_channel_->keepalive_time_);
}
// Propagate the new keepalive time to all subchannels. This is so
// that new transports created by any subchannel (and not just the
// subchannel that received the GOAWAY), use the new keepalive time.
@ -307,14 +320,17 @@ ClientChannel::SubchannelWrapper::SubchannelWrapper(
WeakRefCountedPtr<ClientChannel> client_channel,
RefCountedPtr<Subchannel> subchannel)
: SubchannelInterfaceWithCallDestination(
GRPC_TRACE_FLAG_ENABLED(client_channel) ? "SubchannelWrapper"
: nullptr),
GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)
? "SubchannelWrapper"
: nullptr),
client_channel_(std::move(client_channel)),
subchannel_(std::move(subchannel)) {
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << client_channel_.get()
<< ": creating subchannel wrapper " << this << " for subchannel "
<< subchannel_.get();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(
GPR_INFO,
"client_channel=%p: creating subchannel wrapper %p for subchannel %p",
client_channel_.get(), this, subchannel_.get());
}
#ifndef NDEBUG
DCHECK(client_channel_->work_serializer_->RunningInWorkSerializer());
#endif
@ -337,10 +353,12 @@ ClientChannel::SubchannelWrapper::SubchannelWrapper(
}
ClientChannel::SubchannelWrapper::~SubchannelWrapper() {
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << client_channel_.get()
<< ": destroying subchannel wrapper " << this << " for subchannel "
<< subchannel_.get();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO,
"client_channel=%p: destroying subchannel wrapper %p "
"for subchannel %p",
client_channel_.get(), this, subchannel_.get());
}
}
void ClientChannel::SubchannelWrapper::Orphaned() {
@ -449,7 +467,7 @@ class ClientChannel::ClientChannelControlHelper
RefCountedPtr<LoadBalancingPolicy::SubchannelPicker> picker) override
ABSL_EXCLUSIVE_LOCKS_REQUIRED(*client_channel_->work_serializer_) {
if (client_channel_->resolver_ == nullptr) return; // Shutting down.
if (GRPC_TRACE_FLAG_ENABLED(client_channel)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
const char* extra = client_channel_->disconnect_error_.ok()
? ""
: " (ignoring -- channel shutting down)";
@ -468,9 +486,10 @@ class ClientChannel::ClientChannelControlHelper
void RequestReresolution() override
ABSL_EXCLUSIVE_LOCKS_REQUIRED(*client_channel_->work_serializer_) {
if (client_channel_->resolver_ == nullptr) return; // Shutting down.
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << client_channel_.get()
<< ": started name re-resolving";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "client_channel=%p: started name re-resolving",
client_channel_.get());
}
client_channel_->resolver_->RequestReresolutionLocked();
}
@ -625,8 +644,9 @@ ClientChannel::ClientChannel(
work_serializer_(std::make_shared<WorkSerializer>(event_engine_)),
state_tracker_("client_channel", GRPC_CHANNEL_IDLE),
subchannel_pool_(GetSubchannelPool(channel_args_)) {
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << this << ": creating client_channel";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "client_channel=%p: creating client_channel", this);
}
// Set initial keepalive time.
auto keepalive_arg = channel_args_.GetInt(GRPC_ARG_KEEPALIVE_TIME_MS);
if (keepalive_arg.has_value()) {
@ -642,13 +662,15 @@ ClientChannel::ClientChannel(
}
ClientChannel::~ClientChannel() {
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << this << ": destroying";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "client_channel=%p: destroying", this);
}
}
void ClientChannel::Orphaned() {
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << this << ": shutting down";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "client_channel=%p: shutting down", this);
}
// Weird capture then copy needed to satisfy thread safety analysis,
// otherwise it seems to fail to recognize the correct lock is taken in the
// lambda.
@ -836,9 +858,10 @@ void ClientChannel::StartCall(UnstartedCallHandler unstarted_handler) {
}
void ClientChannel::CreateResolverLocked() {
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << this << ": starting name resolution for "
<< uri_to_resolve_;
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "client_channel=%p: starting name resolution for %s",
this, uri_to_resolve_.c_str());
}
resolver_ = CoreConfiguration::Get().resolver_registry().CreateResolver(
uri_to_resolve_, channel_args_, nullptr, work_serializer_,
std::make_unique<ResolverResultHandler>(
@ -849,24 +872,28 @@ void ClientChannel::CreateResolverLocked() {
UpdateStateLocked(GRPC_CHANNEL_CONNECTING, absl::Status(),
"started resolving");
resolver_->StartLocked();
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << this << ": created resolver=" << resolver_.get();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "client_channel=%p: created resolver=%p", this,
resolver_.get());
}
}
void ClientChannel::DestroyResolverAndLbPolicyLocked() {
if (resolver_ != nullptr) {
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << this
<< ": shutting down resolver=" << resolver_.get();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "client_channel=%p: shutting down resolver=%p", this,
resolver_.get());
}
resolver_.reset();
saved_service_config_.reset();
saved_config_selector_.reset();
resolver_data_for_calls_.Set(ResolverDataForCalls{nullptr, nullptr});
// Clear LB policy if set.
if (lb_policy_ != nullptr) {
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << this
<< ": shutting down lb_policy=" << lb_policy_.get();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "client_channel=%p: shutting down lb_policy=%p", this,
lb_policy_.get());
}
lb_policy_.reset();
picker_.Set(MakeRefCounted<LoadBalancingPolicy::DropPicker>(
absl::UnavailableError("Channel shutdown")));
@ -948,8 +975,9 @@ RefCountedPtr<LoadBalancingPolicy::Config> ChooseLbPolicy(
void ClientChannel::OnResolverResultChangedLocked(Resolver::Result result) {
// Handle race conditions.
if (resolver_ == nullptr) return;
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << this << ": got resolver result";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "client_channel=%p: got resolver result", this);
}
// Grab resolver result health callback.
auto resolver_callback = std::move(result.result_health_callback);
absl::Status resolver_result_status;
@ -983,17 +1011,20 @@ void ClientChannel::OnResolverResultChangedLocked(Resolver::Result result) {
RefCountedPtr<ServiceConfig> service_config;
RefCountedPtr<ConfigSelector> config_selector;
if (!result.service_config.ok()) {
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << this
<< ": resolver returned service config error: "
<< result.service_config.status();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO,
"client_channel=%p: resolver returned service config error: %s",
this, result.service_config.status().ToString().c_str());
}
// If the service config was invalid, then fallback to the
// previously returned service config, if any.
if (saved_service_config_ != nullptr) {
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << this
<< ": resolver returned invalid service config; "
"continuing to use previous service config";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO,
"client_channel=%p: resolver returned invalid service config; "
"continuing to use previous service config",
this);
}
service_config = saved_service_config_;
config_selector = saved_config_selector_;
} else {
@ -1007,10 +1038,12 @@ void ClientChannel::OnResolverResultChangedLocked(Resolver::Result result) {
}
} else if (*result.service_config == nullptr) {
// Resolver did not return any service config.
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << this
<< ": resolver returned no service config; using default service "
"config for channel";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO,
"client_channel=%p: resolver returned no service config; "
"using default service config for channel",
this);
}
service_config = default_service_config_;
} else {
// Use ServiceConfig and ConfigSelector returned by resolver.
@ -1045,9 +1078,8 @@ void ClientChannel::OnResolverResultChangedLocked(Resolver::Result result) {
// TODO(ncteisen): might be worth somehow including a snippet of the
// config in the trace, at the risk of bloating the trace logs.
trace_strings.push_back("Service config changed");
} else {
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << this << ": service config not changed";
} else if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "client_channel=%p: service config not changed", this);
}
// Create or update LB policy, as needed.
resolver_result_status = CreateOrUpdateLbPolicyLocked(
@ -1078,9 +1110,10 @@ void ClientChannel::OnResolverResultChangedLocked(Resolver::Result result) {
void ClientChannel::OnResolverErrorLocked(absl::Status status) {
if (resolver_ == nullptr) return;
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << this
<< ": resolver transient failure: " << status;
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "client_channel=%p: resolver transient failure: %s", this,
status.ToString().c_str());
}
// If we already have an LB policy from a previous resolution
// result, then we continue to let it set the connectivity state.
// Otherwise, we go into TRANSIENT_FAILURE.
@ -1122,9 +1155,10 @@ absl::Status ClientChannel::CreateOrUpdateLbPolicyLocked(
lb_policy_ = CreateLbPolicyLocked(update_args.args);
}
// Update the policy.
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << this << ": Updating child policy "
<< lb_policy_.get();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "client_channel=%p: Updating child policy %p", this,
lb_policy_.get());
}
return lb_policy_->UpdateLocked(std::move(update_args));
}
@ -1147,10 +1181,11 @@ OrphanablePtr<LoadBalancingPolicy> ClientChannel::CreateLbPolicyLocked(
lb_policy_args.args = args;
OrphanablePtr<LoadBalancingPolicy> lb_policy =
MakeOrphanable<ChildPolicyHandler>(std::move(lb_policy_args),
&client_channel_trace);
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << this << ": created new LB policy "
<< lb_policy.get();
&grpc_client_channel_trace);
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "client_channel=%p: created new LB policy %p", this,
lb_policy.get());
}
return lb_policy;
}
@ -1159,14 +1194,16 @@ void ClientChannel::UpdateServiceConfigInControlPlaneLocked(
RefCountedPtr<ConfigSelector> config_selector, std::string lb_policy_name) {
std::string service_config_json(service_config->json_string());
// Update service config.
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << this << ": using service config: \""
<< service_config_json << "\"";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "client_channel=%p: using service config: \"%s\"", this,
service_config_json.c_str());
}
saved_service_config_ = std::move(service_config);
// Update config selector.
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << this << ": using ConfigSelector "
<< config_selector.get();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "client_channel=%p: using ConfigSelector %p", this,
config_selector.get());
}
saved_config_selector_ = std::move(config_selector);
// Update the data used by GetChannelInfo().
{
@ -1177,9 +1214,10 @@ void ClientChannel::UpdateServiceConfigInControlPlaneLocked(
}
void ClientChannel::UpdateServiceConfigInDataPlaneLocked() {
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << this << ": switching to ConfigSelector "
<< saved_config_selector_.get();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "client_channel=%p: switching to ConfigSelector %p", this,
saved_config_selector_.get());
}
// Use default config selector if resolver didn't supply one.
RefCountedPtr<ConfigSelector> config_selector = saved_config_selector_;
if (config_selector == nullptr) {
@ -1241,8 +1279,9 @@ void ClientChannel::UpdateStateAndPickerLocked(
}
void ClientChannel::StartIdleTimer() {
GRPC_TRACE_LOG(client_channel, INFO)
<< "client_channel=" << this << ": idle timer started";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "client_channel=%p: idle timer started", this);
}
auto self = WeakRefAsSubclass<ClientChannel>();
auto promise = Loop([self]() {
return TrySeq(Sleep(Timestamp::Now() + self->idle_timeout_),
@ -1277,9 +1316,10 @@ void ClientChannel::StartIdleTimer() {
absl::Status ClientChannel::ApplyServiceConfigToCall(
ConfigSelector& config_selector,
ClientMetadata& client_initial_metadata) const {
GRPC_TRACE_LOG(client_channel_call, INFO)
<< "client_channel=" << this << ": " << GetContext<Activity>()->DebugTag()
<< " service config to call";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
gpr_log(GPR_INFO, "client_channel=%p: %sapplying service config to call",
this, GetContext<Activity>()->DebugTag().c_str());
}
// Create a ClientChannelServiceConfigCallData for the call. This stores
// a ref to the ServiceConfig and caches the right set of parsed configs
// to use for the call. The ClientChannelServiceConfigCallData will store

View File

@ -113,6 +113,10 @@ namespace grpc_core {
using internal::ClientChannelMethodParsedConfig;
TraceFlag grpc_client_channel_trace(false, "client_channel");
TraceFlag grpc_client_channel_call_trace(false, "client_channel_call");
TraceFlag grpc_client_channel_lb_call_trace(false, "client_channel_lb_call");
//
// ClientChannelFilter::CallData definition
//
@ -407,9 +411,11 @@ class DynamicTerminationFilter::CallData final {
args, pollent, nullptr,
[service_config_call_data]() { service_config_call_data->Commit(); },
/*is_transparent_retry=*/false);
GRPC_TRACE_LOG(client_channel_call, INFO)
<< "chand=" << chand << " dynamic_termination_calld=" << client_channel
<< ": create lb_call=" << calld->lb_call_.get();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
gpr_log(GPR_INFO,
"chand=%p dynamic_termination_calld=%p: create lb_call=%p", chand,
client_channel, calld->lb_call_.get());
}
}
private:
@ -460,8 +466,9 @@ class ClientChannelFilter::ResolverResultHandler final
}
~ResolverResultHandler() override {
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << chand_ << ": resolver shutdown complete";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "chand=%p: resolver shutdown complete", chand_);
}
GRPC_CHANNEL_STACK_UNREF(chand_->owning_stack_, "ResolverResultHandler");
}
@ -491,14 +498,16 @@ class ClientChannelFilter::SubchannelWrapper final
public:
SubchannelWrapper(ClientChannelFilter* chand,
RefCountedPtr<Subchannel> subchannel)
: SubchannelInterface(GRPC_TRACE_FLAG_ENABLED(client_channel)
: SubchannelInterface(GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)
? "SubchannelWrapper"
: nullptr),
chand_(chand),
subchannel_(std::move(subchannel)) {
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << chand << ": creating subchannel wrapper " << this
<< " for subchannel " << subchannel_.get();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO,
"chand=%p: creating subchannel wrapper %p for subchannel %p",
chand, this, subchannel_.get());
}
GRPC_CHANNEL_STACK_REF(chand_->owning_stack_, "SubchannelWrapper");
#ifndef NDEBUG
DCHECK(chand_->work_serializer_->RunningInWorkSerializer());
@ -519,9 +528,11 @@ class ClientChannelFilter::SubchannelWrapper final
}
~SubchannelWrapper() override {
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << chand_ << ": destroying subchannel wrapper " << this
<< "for subchannel " << subchannel_.get();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO,
"chand=%p: destroying subchannel wrapper %p for subchannel %p",
chand_, this, subchannel_.get());
}
if (!IsWorkSerializerDispatchEnabled()) {
chand_->subchannel_wrappers_.erase(this);
if (chand_->channelz_node_ != nullptr) {
@ -654,11 +665,12 @@ class ClientChannelFilter::SubchannelWrapper final
void OnConnectivityStateChange(
RefCountedPtr<ConnectivityStateWatcherInterface> self,
grpc_connectivity_state state, const absl::Status& status) override {
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << parent_->chand_
<< ": connectivity change for subchannel wrapper " << parent_.get()
<< " subchannel " << parent_->subchannel_.get()
<< "hopping into work_serializer";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO,
"chand=%p: connectivity change for subchannel wrapper %p "
"subchannel %p; hopping into work_serializer",
parent_->chand_, parent_.get(), parent_->subchannel_.get());
}
self.release(); // Held by callback.
parent_->chand_->work_serializer_->Run(
[this, state, status]() ABSL_EXCLUSIVE_LOCKS_REQUIRED(
@ -677,13 +689,15 @@ class ClientChannelFilter::SubchannelWrapper final
void ApplyUpdateInControlPlaneWorkSerializer(grpc_connectivity_state state,
const absl::Status& status)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(*parent_->chand_->work_serializer_) {
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << parent_->chand_
<< ": processing connectivity change in work serializer for "
"subchannel wrapper "
<< parent_.get() << " subchannel " << parent_->subchannel_.get()
<< " watcher=" << watcher_.get()
<< " state=" << ConnectivityStateName(state) << " status=" << status;
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO,
"chand=%p: processing connectivity change in work serializer "
"for subchannel wrapper %p subchannel %p watcher=%p "
"state=%s status=%s",
parent_->chand_, parent_.get(), parent_->subchannel_.get(),
watcher_.get(), ConnectivityStateName(state),
status.ToString().c_str());
}
absl::optional<absl::Cord> keepalive_throttling =
status.GetPayload(kKeepaliveThrottlingKey);
if (keepalive_throttling.has_value()) {
@ -692,10 +706,10 @@ class ClientChannelFilter::SubchannelWrapper final
&new_keepalive_time)) {
if (new_keepalive_time > parent_->chand_->keepalive_time_) {
parent_->chand_->keepalive_time_ = new_keepalive_time;
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << parent_->chand_
<< ": throttling keepalive time to "
<< parent_->chand_->keepalive_time_;
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "chand=%p: throttling keepalive time to %d",
parent_->chand_, parent_->chand_->keepalive_time_);
}
// Propagate the new keepalive time to all subchannels. This is so
// that new transports created by any subchannel (and not just the
// subchannel that received the GOAWAY), use the new keepalive time.
@ -978,13 +992,14 @@ class ClientChannelFilter::ClientChannelControlHelper final
RefCountedPtr<LoadBalancingPolicy::SubchannelPicker> picker)
override ABSL_EXCLUSIVE_LOCKS_REQUIRED(*chand_->work_serializer_) {
if (chand_->resolver_ == nullptr) return; // Shutting down.
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << chand_
<< ": update: state=" << ConnectivityStateName(state) << " status=("
<< status << ") picker=" << picker.get()
<< (chand_->disconnect_error_.ok()
? ""
: " (ignoring -- channel shutting down)");
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
const char* extra = chand_->disconnect_error_.ok()
? ""
: " (ignoring -- channel shutting down)";
gpr_log(GPR_INFO, "chand=%p: update: state=%s status=(%s) picker=%p%s",
chand_, ConnectivityStateName(state), status.ToString().c_str(),
picker.get(), extra);
}
// Do update only if not shutting down.
if (chand_->disconnect_error_.ok()) {
chand_->UpdateStateAndPickerLocked(state, status, "helper",
@ -995,8 +1010,9 @@ class ClientChannelFilter::ClientChannelControlHelper final
void RequestReresolution() override
ABSL_EXCLUSIVE_LOCKS_REQUIRED(*chand_->work_serializer_) {
if (chand_->resolver_ == nullptr) return; // Shutting down.
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << chand_ << ": started name re-resolving";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "chand=%p: started name re-resolving", chand_);
}
chand_->resolver_->RequestReresolutionLocked();
}
@ -1088,9 +1104,10 @@ ClientChannelFilter::ClientChannelFilter(grpc_channel_element_args* args,
std::make_shared<WorkSerializer>(*args->channel_stack->event_engine)),
state_tracker_("client_channel", GRPC_CHANNEL_IDLE),
subchannel_pool_(GetSubchannelPool(channel_args_)) {
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << this << ": creating client_channel for channel stack "
<< owning_stack_;
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "chand=%p: creating client_channel for channel stack %p",
this, owning_stack_);
}
// Start backup polling.
grpc_client_channel_start_backup_polling(interested_parties_);
// Check client channel factory.
@ -1159,8 +1176,9 @@ ClientChannelFilter::ClientChannelFilter(grpc_channel_element_args* args,
}
ClientChannelFilter::~ClientChannelFilter() {
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << this << ": destroying channel";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "chand=%p: destroying channel", this);
}
DestroyResolverAndLbPolicyLocked();
// Stop backup polling.
grpc_client_channel_stop_backup_polling(interested_parties_);
@ -1252,8 +1270,9 @@ void ClientChannelFilter::OnResolverResultChangedLocked(
Resolver::Result result) {
// Handle race conditions.
if (resolver_ == nullptr) return;
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << this << ": got resolver result";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "chand=%p: got resolver result", this);
}
// Grab resolver result health callback.
auto resolver_callback = std::move(result.result_health_callback);
absl::Status resolver_result_status;
@ -1287,16 +1306,19 @@ void ClientChannelFilter::OnResolverResultChangedLocked(
RefCountedPtr<ServiceConfig> service_config;
RefCountedPtr<ConfigSelector> config_selector;
if (!result.service_config.ok()) {
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << this << ": resolver returned service config error: "
<< result.service_config.status();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "chand=%p: resolver returned service config error: %s",
this, result.service_config.status().ToString().c_str());
}
// If the service config was invalid, then fallback to the
// previously returned service config.
if (saved_service_config_ != nullptr) {
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << this
<< ": resolver returned invalid service config. "
"Continuing to use previous service config.";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO,
"chand=%p: resolver returned invalid service config. "
"Continuing to use previous service config.",
this);
}
service_config = saved_service_config_;
config_selector = saved_config_selector_;
} else {
@ -1310,10 +1332,12 @@ void ClientChannelFilter::OnResolverResultChangedLocked(
}
} else if (*result.service_config == nullptr) {
// Resolver did not return any service config.
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << this
<< ": resolver returned no service config. Using default service "
"config for channel.";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO,
"chand=%p: resolver returned no service config. Using default "
"service config for channel.",
this);
}
service_config = default_service_config_;
} else {
// Use ServiceConfig and ConfigSelector returned by resolver.
@ -1345,9 +1369,8 @@ void ClientChannelFilter::OnResolverResultChangedLocked(
UpdateServiceConfigInControlPlaneLocked(
std::move(service_config), std::move(config_selector),
std::string(lb_policy_config->name()));
} else {
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << this << ": service config not changed";
} else if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "chand=%p: service config not changed", this);
}
// Create or update LB policy, as needed.
resolver_result_status = CreateOrUpdateLbPolicyLocked(
@ -1381,8 +1404,10 @@ void ClientChannelFilter::OnResolverResultChangedLocked(
void ClientChannelFilter::OnResolverErrorLocked(absl::Status status) {
if (resolver_ == nullptr) return;
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << this << ": resolver transient failure: " << status;
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "chand=%p: resolver transient failure: %s", this,
status.ToString().c_str());
}
// If we already have an LB policy from a previous resolution
// result, then we continue to let it set the connectivity state.
// Otherwise, we go into TRANSIENT_FAILURE.
@ -1428,8 +1453,10 @@ absl::Status ClientChannelFilter::CreateOrUpdateLbPolicyLocked(
lb_policy_ = CreateLbPolicyLocked(update_args.args);
}
// Update the policy.
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << this << ": Updating child policy " << lb_policy_.get();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "chand=%p: Updating child policy %p", this,
lb_policy_.get());
}
return lb_policy_->UpdateLocked(std::move(update_args));
}
@ -1451,9 +1478,11 @@ OrphanablePtr<LoadBalancingPolicy> ClientChannelFilter::CreateLbPolicyLocked(
lb_policy_args.args = args;
OrphanablePtr<LoadBalancingPolicy> lb_policy =
MakeOrphanable<ChildPolicyHandler>(std::move(lb_policy_args),
&client_channel_trace);
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << this << ": created new LB policy " << lb_policy.get();
&grpc_client_channel_trace);
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "chand=%p: created new LB policy %p", this,
lb_policy.get());
}
grpc_pollset_set_add_pollset_set(lb_policy->interested_parties(),
interested_parties_);
return lb_policy;
@ -1463,9 +1492,10 @@ void ClientChannelFilter::UpdateServiceConfigInControlPlaneLocked(
RefCountedPtr<ServiceConfig> service_config,
RefCountedPtr<ConfigSelector> config_selector, std::string lb_policy_name) {
std::string service_config_json(service_config->json_string());
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << this << ": using service config: \"" << service_config_json
<< "\"";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "chand=%p: using service config: \"%s\"", this,
service_config_json.c_str());
}
// Save service config.
saved_service_config_ = std::move(service_config);
// Swap out the data used by GetChannelInfo().
@ -1476,9 +1506,10 @@ void ClientChannelFilter::UpdateServiceConfigInControlPlaneLocked(
}
// Save config selector.
saved_config_selector_ = std::move(config_selector);
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << this << ": using ConfigSelector "
<< saved_config_selector_.get();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "chand=%p: using ConfigSelector %p", this,
saved_config_selector_.get());
}
}
void ClientChannelFilter::UpdateServiceConfigInDataPlaneLocked() {
@ -1486,9 +1517,10 @@ void ClientChannelFilter::UpdateServiceConfigInDataPlaneLocked() {
RefCountedPtr<ServiceConfig> service_config = saved_service_config_;
// Grab ref to config selector. Use default if resolver didn't supply one.
RefCountedPtr<ConfigSelector> config_selector = saved_config_selector_;
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << this << ": switching to ConfigSelector "
<< saved_config_selector_.get();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "chand=%p: switching to ConfigSelector %p", this,
saved_config_selector_.get());
}
if (config_selector == nullptr) {
config_selector =
MakeRefCounted<DefaultConfigSelector>(saved_service_config_);
@ -1530,9 +1562,10 @@ void ClientChannelFilter::UpdateServiceConfigInDataPlaneLocked() {
}
void ClientChannelFilter::CreateResolverLocked() {
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << this << ": starting name resolution for "
<< uri_to_resolve_;
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "chand=%p: starting name resolution for %s", this,
uri_to_resolve_.c_str());
}
resolver_ = CoreConfiguration::Get().resolver_registry().CreateResolver(
uri_to_resolve_, channel_args_, interested_parties_, work_serializer_,
std::make_unique<ResolverResultHandler>(this));
@ -1542,14 +1575,17 @@ void ClientChannelFilter::CreateResolverLocked() {
UpdateStateLocked(GRPC_CHANNEL_CONNECTING, absl::Status(),
"started resolving");
resolver_->StartLocked();
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << this << ": created resolver=" << resolver_.get();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "chand=%p: created resolver=%p", this, resolver_.get());
}
}
void ClientChannelFilter::DestroyResolverAndLbPolicyLocked() {
if (resolver_ != nullptr) {
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << this << ": shutting down resolver=" << resolver_.get();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "chand=%p: shutting down resolver=%p", this,
resolver_.get());
}
resolver_.reset();
// Clear resolution state.
saved_service_config_.reset();
@ -1569,9 +1605,10 @@ void ClientChannelFilter::DestroyResolverAndLbPolicyLocked() {
}
// Clear LB policy if set.
if (lb_policy_ != nullptr) {
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << this
<< ": shutting down lb_policy=" << lb_policy_.get();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "chand=%p: shutting down lb_policy=%p", this,
lb_policy_.get());
}
grpc_pollset_set_del_pollset_set(lb_policy_->interested_parties(),
interested_parties_);
lb_policy_.reset();
@ -1717,9 +1754,10 @@ void ClientChannelFilter::StartTransportOpLocked(grpc_transport_op* op) {
}
// Disconnect or enter IDLE.
if (!op->disconnect_with_error.ok()) {
GRPC_TRACE_LOG(client_channel, INFO)
<< "chand=" << this << ": disconnect_with_error: "
<< StatusToString(op->disconnect_with_error);
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) {
gpr_log(GPR_INFO, "chand=%p: disconnect_with_error: %s", this,
StatusToString(op->disconnect_with_error).c_str());
}
DestroyResolverAndLbPolicyLocked();
intptr_t value;
if (grpc_error_get_int(op->disconnect_with_error,
@ -1824,9 +1862,11 @@ void ClientChannelFilter::RemoveConnectivityWatcher(
//
void ClientChannelFilter::CallData::RemoveCallFromResolverQueuedCallsLocked() {
GRPC_TRACE_LOG(client_channel_call, INFO)
<< "chand=" << chand() << " calld=" << this
<< ": removing from resolver queued picks list";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p: removing from resolver queued picks list",
chand(), this);
}
// Remove call's pollent from channel's interested_parties.
grpc_polling_entity_del_from_pollset_set(pollent(),
chand()->interested_parties_);
@ -1837,10 +1877,12 @@ void ClientChannelFilter::CallData::RemoveCallFromResolverQueuedCallsLocked() {
}
void ClientChannelFilter::CallData::AddCallToResolverQueuedCallsLocked() {
GRPC_TRACE_LOG(client_channel_call, INFO)
<< "chand=" << chand() << " calld=" << this
<< ": adding to resolver queued picks list; pollent="
<< grpc_polling_entity_string(pollent());
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
gpr_log(
GPR_INFO,
"chand=%p calld=%p: adding to resolver queued picks list; pollent=%s",
chand(), this, grpc_polling_entity_string(pollent()).c_str());
}
// Add call's pollent to channel's interested_parties, so that I/O
// can be done under the call's CQ.
grpc_polling_entity_add_to_pollset_set(pollent(),
@ -1852,9 +1894,10 @@ void ClientChannelFilter::CallData::AddCallToResolverQueuedCallsLocked() {
grpc_error_handle ClientChannelFilter::CallData::ApplyServiceConfigToCallLocked(
const absl::StatusOr<RefCountedPtr<ConfigSelector>>& config_selector) {
GRPC_TRACE_LOG(client_channel_call, INFO)
<< "chand=" << chand() << " calld=" << this
<< ": applying service config to call";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p: applying service config to call",
chand(), this);
}
if (!config_selector.ok()) return config_selector.status();
// Create a ClientChannelServiceConfigCallData for the call. This stores
// a ref to the ServiceConfig and caches the right set of parsed configs
@ -1919,9 +1962,11 @@ absl::optional<absl::Status> ClientChannelFilter::CallData::CheckResolution(
}
// Handle errors.
if (!error.ok()) {
GRPC_TRACE_LOG(client_channel_call, INFO)
<< "chand=" << chand() << " calld=" << this
<< ": error applying config to call: error=" << StatusToString(error);
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p: error applying config to call: error=%s",
chand(), this, StatusToString(error).c_str());
}
return error;
}
// If the call was queued, add trace annotation.
@ -1944,18 +1989,20 @@ bool ClientChannelFilter::CallData::CheckResolutionLocked(
absl::Status resolver_error = chand()->resolver_transient_failure_error_;
if (!resolver_error.ok() &&
!send_initial_metadata()->GetOrCreatePointer(WaitForReady())->value) {
GRPC_TRACE_LOG(client_channel_call, INFO)
<< "chand=" << chand() << " calld=" << this
<< ": resolution failed, failing call";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p: resolution failed, failing call",
chand(), this);
}
*config_selector = absl_status_to_grpc_error(resolver_error);
return true;
}
// Either the resolver has not yet returned a result, or it has
// returned transient failure but the call is wait_for_ready. In
// either case, queue the call.
GRPC_TRACE_LOG(client_channel_call, INFO)
<< "chand=" << chand() << " calld=" << this
<< ": no resolver result yet";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p: no resolver result yet", chand(),
this);
}
return false;
}
// Result found.
@ -1977,8 +2024,9 @@ ClientChannelFilter::FilterBasedCallData::FilterBasedCallData(
elem_(elem),
owning_call_(args.call_stack),
call_combiner_(args.call_combiner) {
GRPC_TRACE_LOG(client_channel_call, INFO)
<< "chand=" << chand() << " calld=" << this << ": created call";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p: created call", chand(), this);
}
}
ClientChannelFilter::FilterBasedCallData::~FilterBasedCallData() {
@ -2014,8 +2062,8 @@ void ClientChannelFilter::FilterBasedCallData::StartTransportStreamOpBatch(
grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
auto* calld = static_cast<FilterBasedCallData*>(elem->call_data);
auto* chand = static_cast<ClientChannelFilter*>(elem->channel_data);
if (GRPC_TRACE_FLAG_ENABLED(client_channel_call) &&
!GRPC_TRACE_FLAG_ENABLED(channel)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace) &&
!GRPC_TRACE_FLAG_ENABLED(grpc_trace_channel)) {
gpr_log(GPR_INFO, "chand=%p calld=%p: batch started from above: %s", chand,
calld, grpc_transport_stream_op_batch_string(batch, false).c_str());
}
@ -2034,9 +2082,10 @@ void ClientChannelFilter::FilterBasedCallData::StartTransportStreamOpBatch(
// Note that once we have done so, we do not need to acquire the channel's
// resolution mutex, which is more efficient (especially for streaming calls).
if (calld->dynamic_call_ != nullptr) {
GRPC_TRACE_LOG(client_channel_call, INFO)
<< "chand=" << chand << " calld=" << calld
<< ": starting batch on dynamic_call=" << calld->dynamic_call_.get();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p: starting batch on dynamic_call=%p",
chand, calld, calld->dynamic_call_.get());
}
calld->dynamic_call_->StartTransportStreamOpBatch(batch);
return;
}
@ -2044,10 +2093,10 @@ void ClientChannelFilter::FilterBasedCallData::StartTransportStreamOpBatch(
//
// If we've previously been cancelled, immediately fail any new batches.
if (GPR_UNLIKELY(!calld->cancel_error_.ok())) {
GRPC_TRACE_LOG(client_channel_call, INFO)
<< "chand=" << chand << " calld=" << calld
<< ": failing batch with error: "
<< StatusToString(calld->cancel_error_);
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p: failing batch with error: %s",
chand, calld, StatusToString(calld->cancel_error_).c_str());
}
// Note: This will release the call combiner.
grpc_transport_stream_op_batch_finish_with_failure(
batch, calld->cancel_error_, calld->call_combiner());
@ -2061,9 +2110,10 @@ void ClientChannelFilter::FilterBasedCallData::StartTransportStreamOpBatch(
// is in the past when the call starts), we can return the right
// error to the caller when the first batch does get passed down.
calld->cancel_error_ = batch->payload->cancel_stream.cancel_error;
GRPC_TRACE_LOG(client_channel_call, INFO)
<< "chand=" << chand << " calld=" << calld
<< ": recording cancel_error=" << StatusToString(calld->cancel_error_);
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p: recording cancel_error=%s", chand,
calld, StatusToString(calld->cancel_error_).c_str());
}
// Fail all pending batches.
calld->PendingBatchesFail(calld->cancel_error_, NoYieldCallCombiner);
// Note: This will release the call combiner.
@ -2077,15 +2127,19 @@ void ClientChannelFilter::FilterBasedCallData::StartTransportStreamOpBatch(
// channel's resolution mutex to apply the service config to the call,
// after which we will create a dynamic call.
if (GPR_LIKELY(batch->send_initial_metadata)) {
GRPC_TRACE_LOG(client_channel_call, INFO)
<< "chand=" << chand << " calld=" << calld
<< ": grabbing resolution mutex to apply service ";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p: grabbing resolution mutex to apply service "
"config",
chand, calld);
}
// If we're still in IDLE, we need to start resolving.
if (GPR_UNLIKELY(chand->CheckConnectivityState(false) ==
GRPC_CHANNEL_IDLE)) {
GRPC_TRACE_LOG(client_channel_call, INFO)
<< "chand=" << chand << " calld=" << calld
<< ": triggering exit idle";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p: triggering exit idle", chand,
calld);
}
// Bounce into the control plane work serializer to start resolving.
GRPC_CHANNEL_STACK_REF(chand->owning_stack_, "ExitIdle");
chand->work_serializer_->Run(
@ -2098,9 +2152,11 @@ void ClientChannelFilter::FilterBasedCallData::StartTransportStreamOpBatch(
calld->TryCheckResolution(/*was_queued=*/false);
} else {
// For all other batches, release the call combiner.
GRPC_TRACE_LOG(client_channel_call, INFO)
<< "chand=" << chand << " calld=" << calld
<< ": saved batch, yielding call combiner";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p: saved batch, yielding call combiner", chand,
calld);
}
GRPC_CALL_COMBINER_STOP(calld->call_combiner(),
"batch does not include send_initial_metadata");
}
@ -2129,9 +2185,11 @@ size_t ClientChannelFilter::FilterBasedCallData::GetBatchIndex(
void ClientChannelFilter::FilterBasedCallData::PendingBatchesAdd(
grpc_transport_stream_op_batch* batch) {
const size_t idx = GetBatchIndex(batch);
GRPC_TRACE_LOG(client_channel_call, INFO)
<< "chand=" << chand() << " calld=" << this
<< ": adding pending batch at index " << idx;
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p: adding pending batch at index %" PRIuPTR,
chand(), this, idx);
}
grpc_transport_stream_op_batch*& pending = pending_batches_[idx];
CHECK_EQ(pending, nullptr);
pending = batch;
@ -2154,7 +2212,7 @@ void ClientChannelFilter::FilterBasedCallData::PendingBatchesFail(
grpc_error_handle error,
YieldCallCombinerPredicate yield_call_combiner_predicate) {
CHECK(!error.ok());
if (GRPC_TRACE_FLAG_ENABLED(client_channel_call)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
size_t num_batches = 0;
for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
if (pending_batches_[i] != nullptr) ++num_batches;
@ -2197,7 +2255,7 @@ void ClientChannelFilter::FilterBasedCallData::ResumePendingBatchInCallCombiner(
// This is called via the call combiner, so access to calld is synchronized.
void ClientChannelFilter::FilterBasedCallData::PendingBatchesResume() {
// Retries not enabled; send down batches as-is.
if (GRPC_TRACE_FLAG_ENABLED(client_channel_call)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
size_t num_batches = 0;
for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
if (pending_batches_[i] != nullptr) ++num_batches;
@ -2243,13 +2301,13 @@ class ClientChannelFilter::FilterBasedCallData::ResolverQueuedCallCanceller
auto* chand = calld->chand();
{
MutexLock lock(&chand->resolution_mu_);
GRPC_TRACE_LOG(client_channel_call, INFO)
<< "chand=" << chand << " calld=" << calld
<< ": cancelling resolver queued pick: "
"error="
<< StatusToString(error) << " self=" << self
<< " calld->resolver_pick_canceller="
<< calld->resolver_call_canceller_;
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p: cancelling resolver queued pick: "
"error=%s self=%p calld->resolver_pick_canceller=%p",
chand, calld, StatusToString(error).c_str(), self,
calld->resolver_call_canceller_);
}
if (calld->resolver_call_canceller_ == self && !error.ok()) {
// Remove pick from list of queued picks.
calld->RemoveCallFromResolverQueuedCallsLocked();
@ -2302,14 +2360,19 @@ void ClientChannelFilter::FilterBasedCallData::CreateDynamicCall() {
call_combiner()};
grpc_error_handle error;
DynamicFilters* channel_stack = args.channel_stack.get();
GRPC_TRACE_LOG(client_channel_call, INFO)
<< "chand=" << chand() << " calld=" << this
<< ": creating dynamic call stack on channel_stack=" << channel_stack;
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
gpr_log(
GPR_INFO,
"chand=%p calld=%p: creating dynamic call stack on channel_stack=%p",
chand(), this, channel_stack);
}
dynamic_call_ = channel_stack->CreateCall(std::move(args), &error);
if (!error.ok()) {
GRPC_TRACE_LOG(client_channel_call, INFO)
<< "chand=" << chand() << " calld=" << this
<< ": failed to create dynamic call: error=" << StatusToString(error);
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p: failed to create dynamic call: error=%s",
chand(), this, StatusToString(error).c_str());
}
PendingBatchesFail(error, YieldCallCombiner);
return;
}
@ -2322,10 +2385,13 @@ void ClientChannelFilter::FilterBasedCallData::
auto* calld = static_cast<FilterBasedCallData*>(arg);
auto* chand = calld->chand();
auto* service_config_call_data = GetServiceConfigCallData(calld->arena());
GRPC_TRACE_LOG(client_channel_call, INFO)
<< "chand=" << chand << " calld=" << calld
<< ": got recv_trailing_metadata_ready: error=" << StatusToString(error)
<< " service_config_call_data=" << service_config_call_data;
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p: got recv_trailing_metadata_ready: error=%s "
"service_config_call_data=%p",
chand, calld, StatusToString(error).c_str(),
service_config_call_data);
}
if (service_config_call_data != nullptr) {
service_config_call_data->Commit();
}
@ -2512,15 +2578,17 @@ void CreateCallAttemptTracer(Arena* arena, bool is_transparent_retry) {
ClientChannelFilter::LoadBalancedCall::LoadBalancedCall(
ClientChannelFilter* chand, Arena* arena,
absl::AnyInvocable<void()> on_commit, bool is_transparent_retry)
: InternallyRefCounted(GRPC_TRACE_FLAG_ENABLED(client_channel_lb_call)
? "LoadBalancedCall"
: nullptr),
: InternallyRefCounted(
GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)
? "LoadBalancedCall"
: nullptr),
chand_(chand),
on_commit_(std::move(on_commit)),
arena_(arena) {
CreateCallAttemptTracer(arena, is_transparent_retry);
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "chand=" << chand_ << " lb_call=" << this << ": created";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO, "chand=%p lb_call=%p: created", chand_, this);
}
}
ClientChannelFilter::LoadBalancedCall::~LoadBalancedCall() {
@ -2561,9 +2629,10 @@ void ClientChannelFilter::LoadBalancedCall::RecordLatency() {
void ClientChannelFilter::LoadBalancedCall::
RemoveCallFromLbQueuedCallsLocked() {
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "chand=" << chand_ << " lb_call=" << this
<< ": removing from queued picks list";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO, "chand=%p lb_call=%p: removing from queued picks list",
chand_, this);
}
// Remove pollset_set linkage.
grpc_polling_entity_del_from_pollset_set(pollent(),
chand_->interested_parties_);
@ -2574,9 +2643,10 @@ void ClientChannelFilter::LoadBalancedCall::
}
void ClientChannelFilter::LoadBalancedCall::AddCallToLbQueuedCallsLocked() {
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "chand=" << chand_ << " lb_call=" << this
<< ": adding to queued picks list";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO, "chand=%p lb_call=%p: adding to queued picks list",
chand_, this);
}
// Add call's pollent to channel's interested_parties, so that I/O
// can be done under the call's CQ.
grpc_polling_entity_add_to_pollset_set(pollent(),
@ -2618,9 +2688,10 @@ ClientChannelFilter::LoadBalancedCall::PickSubchannel(bool was_queued) {
};
}
// Grab mutex and take a ref to the picker.
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "chand=" << chand_ << " lb_call=" << this
<< ": grabbing LB mutex to get picker";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO, "chand=%p lb_call=%p: grabbing LB mutex to get picker",
chand_, this);
}
RefCountedPtr<LoadBalancingPolicy::SubchannelPicker> picker;
{
MutexLock lock(&chand_->lb_mu_);
@ -2630,15 +2701,17 @@ ClientChannelFilter::LoadBalancedCall::PickSubchannel(bool was_queued) {
// TODO(roth): Fix race condition in channel_idle filter and any
// other possible causes of this.
if (pickers.back() == nullptr) {
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "chand=" << chand_ << " lb_call=" << this
<< ": picker is null, failing call";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_ERROR, "chand=%p lb_call=%p: picker is null, failing call",
chand_, this);
}
return absl::InternalError("picker is null -- shouldn't happen");
}
// Do pick.
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "chand=" << chand_ << " lb_call=" << this
<< ": performing pick with picker=" << pickers.back().get();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO, "chand=%p lb_call=%p: performing pick with picker=%p",
chand_, this, pickers.back().get());
}
grpc_error_handle error;
bool pick_complete = PickSubchannelImpl(pickers.back().get(), &error);
if (!pick_complete) {
@ -2646,9 +2719,11 @@ ClientChannelFilter::LoadBalancedCall::PickSubchannel(bool was_queued) {
MutexLock lock(&chand_->lb_mu_);
// If picker has been swapped out since we grabbed it, try again.
if (pickers.back() != chand_->picker_) {
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "chand=" << chand_ << " lb_call=" << this
<< ": pick not complete, but picker changed";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO,
"chand=%p lb_call=%p: pick not complete, but picker changed",
chand_, this);
}
if (IsWorkSerializerDispatchEnabled()) {
// Don't unref until after we release the mutex.
old_picker = std::move(pickers.back());
@ -2667,9 +2742,11 @@ ClientChannelFilter::LoadBalancedCall::PickSubchannel(bool was_queued) {
}
// If the pick failed, fail the call.
if (!error.ok()) {
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "chand=" << chand_ << " lb_call=" << this
<< ": failed to pick subchannel: error=" << StatusToString(error);
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO,
"chand=%p lb_call=%p: failed to pick subchannel: error=%s",
chand_, this, StatusToString(error).c_str());
}
return error;
}
// Pick succeeded.
@ -2695,10 +2772,11 @@ bool ClientChannelFilter::LoadBalancedCall::PickSubchannelImpl(
&result,
// CompletePick
[this](LoadBalancingPolicy::PickResult::Complete* complete_pick) {
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "chand=" << chand_ << " lb_call=" << this
<< ": LB pick succeeded: subchannel="
<< complete_pick->subchannel.get();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO,
"chand=%p lb_call=%p: LB pick succeeded: subchannel=%p",
chand_, this, complete_pick->subchannel.get());
}
CHECK(complete_pick->subchannel != nullptr);
// Grab a ref to the connected subchannel while we're still
// holding the data plane mutex.
@ -2710,10 +2788,12 @@ bool ClientChannelFilter::LoadBalancedCall::PickSubchannelImpl(
// yet seen that change and given us a new picker), then just
// queue the pick. We'll try again as soon as we get a new picker.
if (connected_subchannel_ == nullptr) {
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "chand=" << chand_ << " lb_call=" << this
<< ": subchannel returned by LB picker "
"has no connected subchannel; queueing pick";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO,
"chand=%p lb_call=%p: subchannel returned by LB picker "
"has no connected subchannel; queueing pick",
chand_, this);
}
return false;
}
lb_subchannel_call_tracker_ =
@ -2725,15 +2805,18 @@ bool ClientChannelFilter::LoadBalancedCall::PickSubchannelImpl(
},
// QueuePick
[this](LoadBalancingPolicy::PickResult::Queue* /*queue_pick*/) {
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "chand=" << chand_ << " lb_call=" << this << ": LB pick queued";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO, "chand=%p lb_call=%p: LB pick queued", chand_,
this);
}
return false;
},
// FailPick
[this, &error](LoadBalancingPolicy::PickResult::Fail* fail_pick) {
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "chand=" << chand_ << " lb_call=" << this
<< ": LB pick failed: " << fail_pick->status;
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO, "chand=%p lb_call=%p: LB pick failed: %s", chand_,
this, fail_pick->status.ToString().c_str());
}
// If wait_for_ready is false, then the error indicates the RPC
// attempt's final status.
if (!send_initial_metadata()
@ -2749,9 +2832,10 @@ bool ClientChannelFilter::LoadBalancedCall::PickSubchannelImpl(
},
// DropPick
[this, &error](LoadBalancingPolicy::PickResult::Drop* drop_pick) {
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "chand=" << chand_ << " lb_call=" << this
<< ": LB pick dropped: " << drop_pick->status;
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO, "chand=%p lb_call=%p: LB pick dropped: %s", chand_,
this, drop_pick->status.ToString().c_str());
}
*error = grpc_error_set_int(
absl_status_to_grpc_error(MaybeRewriteIllegalStatusCode(
std::move(drop_pick->status), "LB drop")),
@ -2817,9 +2901,11 @@ size_t ClientChannelFilter::FilterBasedLoadBalancedCall::GetBatchIndex(
void ClientChannelFilter::FilterBasedLoadBalancedCall::PendingBatchesAdd(
grpc_transport_stream_op_batch* batch) {
const size_t idx = GetBatchIndex(batch);
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "chand=" << chand() << " lb_call=" << this
<< ": adding pending batch at index " << idx;
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO,
"chand=%p lb_call=%p: adding pending batch at index %" PRIuPTR,
chand(), this, idx);
}
CHECK_EQ(pending_batches_[idx], nullptr);
pending_batches_[idx] = batch;
}
@ -2842,7 +2928,7 @@ void ClientChannelFilter::FilterBasedLoadBalancedCall::PendingBatchesFail(
YieldCallCombinerPredicate yield_call_combiner_predicate) {
CHECK(!error.ok());
failure_error_ = error;
if (GRPC_TRACE_FLAG_ENABLED(client_channel_lb_call)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
size_t num_batches = 0;
for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
if (pending_batches_[i] != nullptr) ++num_batches;
@ -2884,7 +2970,7 @@ void ClientChannelFilter::FilterBasedLoadBalancedCall::
// This is called via the call combiner, so access to calld is synchronized.
void ClientChannelFilter::FilterBasedLoadBalancedCall::PendingBatchesResume() {
if (GRPC_TRACE_FLAG_ENABLED(client_channel_lb_call)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
size_t num_batches = 0;
for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
if (pending_batches_[i] != nullptr) ++num_batches;
@ -2913,8 +2999,8 @@ void ClientChannelFilter::FilterBasedLoadBalancedCall::PendingBatchesResume() {
void ClientChannelFilter::FilterBasedLoadBalancedCall::
StartTransportStreamOpBatch(grpc_transport_stream_op_batch* batch) {
if (GRPC_TRACE_FLAG_ENABLED(client_channel_lb_call) ||
GRPC_TRACE_FLAG_ENABLED(channel)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace) ||
GRPC_TRACE_FLAG_ENABLED(grpc_trace_channel)) {
gpr_log(GPR_INFO,
"chand=%p lb_call=%p: batch started from above: %s, "
"call_attempt_tracer()=%p",
@ -2968,9 +3054,11 @@ void ClientChannelFilter::FilterBasedLoadBalancedCall::
// the channel's data plane mutex, which is more efficient (especially for
// streaming calls).
if (subchannel_call_ != nullptr) {
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "chand=" << chand() << " lb_call=" << this
<< ": starting batch on subchannel_call=" << subchannel_call_.get();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO,
"chand=%p lb_call=%p: starting batch on subchannel_call=%p",
chand(), this, subchannel_call_.get());
}
subchannel_call_->StartTransportStreamOpBatch(batch);
return;
}
@ -2978,9 +3066,10 @@ void ClientChannelFilter::FilterBasedLoadBalancedCall::
//
// If we've previously been cancelled, immediately fail any new batches.
if (GPR_UNLIKELY(!cancel_error_.ok())) {
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "chand=" << chand() << " lb_call=" << this
<< ": failing batch with error: " << StatusToString(cancel_error_);
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO, "chand=%p lb_call=%p: failing batch with error: %s",
chand(), this, StatusToString(cancel_error_).c_str());
}
// Note: This will release the call combiner.
grpc_transport_stream_op_batch_finish_with_failure(batch, cancel_error_,
call_combiner_);
@ -2994,9 +3083,10 @@ void ClientChannelFilter::FilterBasedLoadBalancedCall::
// is in the past when the call starts), we can return the right
// error to the caller when the first batch does get passed down.
cancel_error_ = batch->payload->cancel_stream.cancel_error;
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "chand=" << chand() << " lb_call=" << this
<< ": recording cancel_error=" << StatusToString(cancel_error_).c_str();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO, "chand=%p lb_call=%p: recording cancel_error=%s",
chand(), this, StatusToString(cancel_error_).c_str());
}
// Fail all pending batches.
PendingBatchesFail(cancel_error_, NoYieldCallCombiner);
// Note: This will release the call combiner.
@ -3012,9 +3102,11 @@ void ClientChannelFilter::FilterBasedLoadBalancedCall::
TryPick(/*was_queued=*/false);
} else {
// For all other batches, release the call combiner.
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "chand=" << chand() << " lb_call=" << this
<< ": saved batch, yielding call combiner";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO,
"chand=%p lb_call=%p: saved batch, yielding call combiner",
chand(), this);
}
GRPC_CALL_COMBINER_STOP(call_combiner_,
"batch does not include send_initial_metadata");
}
@ -3023,9 +3115,11 @@ void ClientChannelFilter::FilterBasedLoadBalancedCall::
void ClientChannelFilter::FilterBasedLoadBalancedCall::RecvInitialMetadataReady(
void* arg, grpc_error_handle error) {
auto* self = static_cast<FilterBasedLoadBalancedCall*>(arg);
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "chand=" << self->chand() << " lb_call=" << self
<< ": got recv_initial_metadata_ready: error=" << StatusToString(error);
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO,
"chand=%p lb_call=%p: got recv_initial_metadata_ready: error=%s",
self->chand(), self, StatusToString(error).c_str());
}
if (error.ok()) {
// recv_initial_metadata_flags is not populated for clients
self->call_attempt_tracer()->RecordReceivedInitialMetadata(
@ -3040,12 +3134,15 @@ void ClientChannelFilter::FilterBasedLoadBalancedCall::RecvInitialMetadataReady(
void ClientChannelFilter::FilterBasedLoadBalancedCall::
RecvTrailingMetadataReady(void* arg, grpc_error_handle error) {
auto* self = static_cast<FilterBasedLoadBalancedCall*>(arg);
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "chand=" << self->chand() << " lb_call=" << self
<< ": got recv_trailing_metadata_ready: error=" << StatusToString(error)
<< " call_attempt_tracer()=" << self->call_attempt_tracer()
<< " lb_subchannel_call_tracker_=" << self->lb_subchannel_call_tracker()
<< " failure_error_=" << StatusToString(self->failure_error_);
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO,
"chand=%p lb_call=%p: got recv_trailing_metadata_ready: error=%s "
"call_attempt_tracer()=%p lb_subchannel_call_tracker_=%p "
"failure_error_=%s",
self->chand(), self, StatusToString(error).c_str(),
self->call_attempt_tracer(), self->lb_subchannel_call_tracker(),
StatusToString(self->failure_error_).c_str());
}
// Check if we have a tracer or an LB callback to invoke.
if (self->call_attempt_tracer() != nullptr ||
self->lb_subchannel_call_tracker() != nullptr) {
@ -3113,11 +3210,13 @@ class ClientChannelFilter::FilterBasedLoadBalancedCall::LbQueuedCallCanceller
auto* chand = lb_call->chand();
{
MutexLock lock(&chand->lb_mu_);
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "chand=" << chand << " lb_call=" << lb_call
<< ": cancelling queued pick: error=" << StatusToString(error)
<< " self=" << self
<< " calld->pick_canceller=" << lb_call->lb_call_canceller_;
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO,
"chand=%p lb_call=%p: cancelling queued pick: "
"error=%s self=%p calld->pick_canceller=%p",
chand, lb_call, StatusToString(error).c_str(), self,
lb_call->lb_call_canceller_);
}
if (lb_call->lb_call_canceller_ == self && !error.ok()) {
lb_call->Commit();
// Remove pick from list of queued picks.
@ -3199,10 +3298,11 @@ void ClientChannelFilter::FilterBasedLoadBalancedCall::CreateSubchannelCall() {
arena(), call_combiner_};
grpc_error_handle error;
subchannel_call_ = SubchannelCall::Create(std::move(call_args), &error);
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "chand=" << chand() << " lb_call=" << this
<< ": create subchannel_call=" << subchannel_call_.get()
<< ": error=" << StatusToString(error);
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO,
"chand=%p lb_call=%p: create subchannel_call=%p: error=%s", chand(),
this, subchannel_call_.get(), StatusToString(error).c_str());
}
if (on_call_destruction_complete_ != nullptr) {
subchannel_call_->SetAfterCallStackDestroy(on_call_destruction_complete_);
on_call_destruction_complete_ = nullptr;

View File

@ -24,6 +24,12 @@
namespace grpc_core {
// Defined in legacy client channel filter.
// TODO(roth): Move these here when we remove the legacy filter.
extern TraceFlag grpc_client_channel_trace;
extern TraceFlag grpc_client_channel_call_trace;
extern TraceFlag grpc_client_channel_lb_call_trace;
namespace {
class LbMetadata : public LoadBalancingPolicy::MetadataInterface {
@ -179,10 +185,12 @@ LoopCtl<absl::StatusOr<RefCountedPtr<UnstartedCallDestination>>> PickSubchannel(
// CompletePick
[&](LoadBalancingPolicy::PickResult::Complete* complete_pick)
-> LoopCtl<absl::StatusOr<RefCountedPtr<UnstartedCallDestination>>> {
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "client_channel: " << GetContext<Activity>()->DebugTag()
<< " pick succeeded: subchannel="
<< complete_pick->subchannel.get();
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO,
"client_channel: %sLB pick succeeded: subchannel=%p",
GetContext<Activity>()->DebugTag().c_str(),
complete_pick->subchannel.get());
}
CHECK(complete_pick->subchannel != nullptr);
// Grab a ref to the call destination while we're still
// holding the data plane mutex.
@ -195,10 +203,12 @@ LoopCtl<absl::StatusOr<RefCountedPtr<UnstartedCallDestination>>> PickSubchannel(
// yet seen that change and given us a new picker), then just
// queue the pick. We'll try again as soon as we get a new picker.
if (call_destination == nullptr) {
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "client_channel: " << GetContext<Activity>()->DebugTag()
<< " returned by LB picker has no connected subchannel; queueing "
"pick";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO,
"client_channel: %ssubchannel returned by LB picker "
"has no connected subchannel; queueing pick",
GetContext<Activity>()->DebugTag().c_str());
}
return Continue{};
}
// If the LB policy returned a call tracker, inform it that the
@ -213,17 +223,20 @@ LoopCtl<absl::StatusOr<RefCountedPtr<UnstartedCallDestination>>> PickSubchannel(
},
// QueuePick
[&](LoadBalancingPolicy::PickResult::Queue* /*queue_pick*/) {
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "client_channel: " << GetContext<Activity>()->DebugTag()
<< " pick queued";
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO, "client_channel: %sLB pick queued",
GetContext<Activity>()->DebugTag().c_str());
}
return Continue{};
},
// FailPick
[&](LoadBalancingPolicy::PickResult::Fail* fail_pick)
-> LoopCtl<absl::StatusOr<RefCountedPtr<UnstartedCallDestination>>> {
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "client_channel: " << GetContext<Activity>()->DebugTag()
<< " pick failed: " << fail_pick->status;
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO, "client_channel: %sLB pick failed: %s",
GetContext<Activity>()->DebugTag().c_str(),
fail_pick->status.ToString().c_str());
}
// If wait_for_ready is false, then the error indicates the RPC
// attempt's final status.
if (!unstarted_handler.UnprocessedClientInitialMetadata()
@ -239,9 +252,11 @@ LoopCtl<absl::StatusOr<RefCountedPtr<UnstartedCallDestination>>> PickSubchannel(
// DropPick
[&](LoadBalancingPolicy::PickResult::Drop* drop_pick)
-> LoopCtl<absl::StatusOr<RefCountedPtr<UnstartedCallDestination>>> {
GRPC_TRACE_LOG(client_channel_lb_call, INFO)
<< "client_channel: " << GetContext<Activity>()->DebugTag()
<< " pick dropped: " << drop_pick->status;
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
gpr_log(GPR_INFO, "client_channel: %sLB pick dropped: %s",
GetContext<Activity>()->DebugTag().c_str(),
drop_pick->status.ToString().c_str());
}
return grpc_error_set_int(MaybeRewriteIllegalStatusCode(
std::move(drop_pick->status), "LB drop"),
StatusIntProperty::kLbPolicyDrop, 1);

View File

@ -89,6 +89,8 @@ using grpc_core::internal::RetryMethodConfig;
using grpc_core::internal::RetryServiceConfigParser;
using grpc_event_engine::experimental::EventEngine;
grpc_core::TraceFlag grpc_retry_trace(false, "retry");
namespace grpc_core {
//

View File

@ -38,11 +38,14 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_fwd.h"
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/transport/transport.h"
#include "src/core/util/useful.h"
extern grpc_core::TraceFlag grpc_retry_trace;
namespace grpc_core {
class RetryFilter final {

View File

@ -116,7 +116,8 @@ class RetryFilter::LegacyCallData::CallStackDestructionBarrier final
RetryFilter::LegacyCallData::CallAttempt::CallAttempt(
RetryFilter::LegacyCallData* calld, bool is_transparent_retry)
: RefCounted(GRPC_TRACE_FLAG_ENABLED(retry) ? "CallAttempt" : nullptr),
: RefCounted(GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace) ? "CallAttempt"
: nullptr),
calld_(calld),
started_send_initial_metadata_(false),
completed_send_initial_metadata_(false),
@ -140,7 +141,7 @@ RetryFilter::LegacyCallData::CallAttempt::CallAttempt(
}
},
is_transparent_retry);
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p attempt=%p: created attempt, lb_call=%p",
calld->chand_, calld, this, lb_call_.get());
@ -150,7 +151,7 @@ RetryFilter::LegacyCallData::CallAttempt::CallAttempt(
calld->retry_policy_->per_attempt_recv_timeout().has_value()) {
const Duration per_attempt_recv_timeout =
*calld->retry_policy_->per_attempt_recv_timeout();
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p attempt=%p: per-attempt timeout in %" PRId64
" ms",
@ -169,7 +170,7 @@ RetryFilter::LegacyCallData::CallAttempt::CallAttempt(
}
RetryFilter::LegacyCallData::CallAttempt::~CallAttempt() {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p attempt=%p: destroying call attempt",
calld_->chand_, calld_, this);
}
@ -236,7 +237,7 @@ void RetryFilter::LegacyCallData::CallAttempt::MaybeSwitchToFastPath() {
// yet seen that op from the surface, we can't switch yet.
if (recv_trailing_metadata_internal_batch_ != nullptr) return;
// Switch to fast path.
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p attempt=%p: retry state no longer needed; "
"moving LB call to parent and unreffing the call attempt",
@ -255,7 +256,7 @@ RetryFilter::LegacyCallData::CallAttempt::MaybeCreateBatchForReplay() {
// send_initial_metadata.
if (calld_->seen_send_initial_metadata_ && !started_send_initial_metadata_ &&
!calld_->pending_send_initial_metadata_) {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p attempt=%p: replaying previously completed "
"send_initial_metadata op",
@ -269,7 +270,7 @@ RetryFilter::LegacyCallData::CallAttempt::MaybeCreateBatchForReplay() {
if (started_send_message_count_ < calld_->send_messages_.size() &&
started_send_message_count_ == completed_send_message_count_ &&
!calld_->pending_send_message_) {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p attempt=%p: replaying previously completed "
"send_message op",
@ -288,7 +289,7 @@ RetryFilter::LegacyCallData::CallAttempt::MaybeCreateBatchForReplay() {
started_send_message_count_ == calld_->send_messages_.size() &&
!started_send_trailing_metadata_ &&
!calld_->pending_send_trailing_metadata_) {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p attempt=%p: replaying previously completed "
"send_trailing_metadata op",
@ -319,7 +320,7 @@ void StartBatchInCallCombiner(void* arg, grpc_error_handle /*ignored*/) {
void RetryFilter::LegacyCallData::CallAttempt::AddClosureForBatch(
grpc_transport_stream_op_batch* batch, const char* reason,
CallCombinerClosureList* closures) {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p attempt=%p: adding batch (%s): %s",
calld_->chand_, calld_, this, reason,
grpc_transport_stream_op_batch_string(batch, false).c_str());
@ -332,7 +333,7 @@ void RetryFilter::LegacyCallData::CallAttempt::AddClosureForBatch(
void RetryFilter::LegacyCallData::CallAttempt::
AddBatchForInternalRecvTrailingMetadata(CallCombinerClosureList* closures) {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p attempt=%p: call failed but "
"recv_trailing_metadata not started; starting it internally",
@ -522,7 +523,7 @@ void RetryFilter::LegacyCallData::CallAttempt::AddRetriableBatches(
}
void RetryFilter::LegacyCallData::CallAttempt::StartRetriableBatches() {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p attempt=%p: constructing retriable batches",
calld_->chand_, calld_, this);
@ -532,7 +533,7 @@ void RetryFilter::LegacyCallData::CallAttempt::StartRetriableBatches() {
AddRetriableBatches(&closures);
// Note: This will yield the call combiner.
// Start batches on LB call.
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p attempt=%p: starting %" PRIuPTR
" retriable batches on lb_call=%p",
@ -560,7 +561,7 @@ bool RetryFilter::LegacyCallData::CallAttempt::ShouldRetry(
if (calld_->retry_throttle_data_ != nullptr) {
calld_->retry_throttle_data_->RecordSuccess();
}
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p attempt=%p: call succeeded",
calld_->chand_, calld_, this);
}
@ -568,7 +569,7 @@ bool RetryFilter::LegacyCallData::CallAttempt::ShouldRetry(
}
// Status is not OK. Check whether the status is retryable.
if (!calld_->retry_policy_->retryable_status_codes().Contains(*status)) {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p attempt=%p: status %s not configured as "
"retryable",
@ -587,7 +588,7 @@ bool RetryFilter::LegacyCallData::CallAttempt::ShouldRetry(
// checks, so that we don't fail to record failures due to other factors.
if (calld_->retry_throttle_data_ != nullptr &&
!calld_->retry_throttle_data_->RecordFailure()) {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p attempt=%p: retries throttled",
calld_->chand_, calld_, this);
}
@ -595,7 +596,7 @@ bool RetryFilter::LegacyCallData::CallAttempt::ShouldRetry(
}
// Check whether the call is committed.
if (calld_->retry_committed_) {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p attempt=%p: retries already committed",
calld_->chand_, calld_, this);
@ -606,7 +607,7 @@ bool RetryFilter::LegacyCallData::CallAttempt::ShouldRetry(
++calld_->num_attempts_completed_;
if (calld_->num_attempts_completed_ >=
calld_->retry_policy_->max_attempts()) {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(
GPR_INFO, "chand=%p calld=%p attempt=%p: exceeded %d retry attempts",
calld_->chand_, calld_, this, calld_->retry_policy_->max_attempts());
@ -616,7 +617,7 @@ bool RetryFilter::LegacyCallData::CallAttempt::ShouldRetry(
// Check server push-back.
if (server_pushback.has_value()) {
if (*server_pushback < Duration::Zero()) {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p attempt=%p: not retrying due to server "
"push-back",
@ -624,7 +625,7 @@ bool RetryFilter::LegacyCallData::CallAttempt::ShouldRetry(
}
return false;
} else {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(
GPR_INFO,
"chand=%p calld=%p attempt=%p: server push-back: retry in %" PRIu64
@ -674,7 +675,7 @@ void RetryFilter::LegacyCallData::CallAttempt::OnPerAttemptRecvTimerLocked(
void* arg, grpc_error_handle error) {
auto* call_attempt = static_cast<CallAttempt*>(arg);
auto* calld = call_attempt->calld_;
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p attempt=%p: perAttemptRecvTimeout timer fired: "
"error=%s, per_attempt_recv_timer_handle_.has_value()=%d",
@ -713,7 +714,7 @@ void RetryFilter::LegacyCallData::CallAttempt::OnPerAttemptRecvTimerLocked(
void RetryFilter::LegacyCallData::CallAttempt::
MaybeCancelPerAttemptRecvTimer() {
if (per_attempt_recv_timer_handle_.has_value()) {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p attempt=%p: cancelling "
"perAttemptRecvTimeout timer",
@ -734,10 +735,11 @@ void RetryFilter::LegacyCallData::CallAttempt::
RetryFilter::LegacyCallData::CallAttempt::BatchData::BatchData(
RefCountedPtr<CallAttempt> attempt, int refcount, bool set_on_complete)
: RefCounted(GRPC_TRACE_FLAG_ENABLED(retry) ? "BatchData" : nullptr,
refcount),
: RefCounted(
GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace) ? "BatchData" : nullptr,
refcount),
call_attempt_(attempt.release()) {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p attempt=%p: creating batch %p",
call_attempt_->calld_->chand_, call_attempt_->calld_, call_attempt_,
this);
@ -758,7 +760,7 @@ RetryFilter::LegacyCallData::CallAttempt::BatchData::BatchData(
}
RetryFilter::LegacyCallData::CallAttempt::BatchData::~BatchData() {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p attempt=%p: destroying batch %p",
call_attempt_->calld_->chand_, call_attempt_->calld_, call_attempt_,
this);
@ -831,7 +833,7 @@ void RetryFilter::LegacyCallData::CallAttempt::BatchData::
RefCountedPtr<BatchData> batch_data(static_cast<BatchData*>(arg));
CallAttempt* call_attempt = batch_data->call_attempt_;
RetryFilter::LegacyCallData* calld = call_attempt->calld_;
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p attempt=%p batch_data=%p: "
"got recv_initial_metadata_ready, error=%s",
@ -858,7 +860,7 @@ void RetryFilter::LegacyCallData::CallAttempt::BatchData::
if (GPR_UNLIKELY(
(call_attempt->trailing_metadata_available_ || !error.ok()) &&
!call_attempt->completed_recv_trailing_metadata_)) {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p attempt=%p: deferring "
"recv_initial_metadata_ready (Trailers-Only)",
@ -930,7 +932,7 @@ void RetryFilter::LegacyCallData::CallAttempt::BatchData::RecvMessageReady(
RefCountedPtr<BatchData> batch_data(static_cast<BatchData*>(arg));
CallAttempt* call_attempt = batch_data->call_attempt_;
RetryFilter::LegacyCallData* calld = call_attempt->calld_;
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p attempt=%p batch_data=%p: "
"got recv_message_ready, error=%s",
@ -960,7 +962,7 @@ void RetryFilter::LegacyCallData::CallAttempt::BatchData::RecvMessageReady(
if (GPR_UNLIKELY(
(!call_attempt->recv_message_.has_value() || !error.ok()) &&
!call_attempt->completed_recv_trailing_metadata_)) {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p attempt=%p: deferring recv_message_ready "
"(nullptr message and recv_trailing_metadata pending)",
@ -1124,7 +1126,7 @@ void RetryFilter::LegacyCallData::CallAttempt::BatchData::
RefCountedPtr<BatchData> batch_data(static_cast<BatchData*>(arg));
CallAttempt* call_attempt = batch_data->call_attempt_;
RetryFilter::LegacyCallData* calld = call_attempt->calld_;
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p attempt=%p batch_data=%p: "
"got recv_trailing_metadata_ready, error=%s",
@ -1151,7 +1153,7 @@ void RetryFilter::LegacyCallData::CallAttempt::BatchData::
batch_data->batch_.payload->recv_trailing_metadata.recv_trailing_metadata;
GetCallStatus(calld->deadline_, md_batch, error, &status, &server_pushback,
&is_lb_drop, &stream_network_state);
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p attempt=%p: call finished, status=%s "
"server_pushback=%s is_lb_drop=%d stream_network_state=%s",
@ -1272,7 +1274,7 @@ void RetryFilter::LegacyCallData::CallAttempt::BatchData::
}
}
if (have_pending_send_ops) {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p attempt=%p: starting next batch for pending "
"send op(s)",
@ -1287,7 +1289,7 @@ void RetryFilter::LegacyCallData::CallAttempt::BatchData::OnComplete(
RefCountedPtr<BatchData> batch_data(static_cast<BatchData*>(arg));
CallAttempt* call_attempt = batch_data->call_attempt_;
RetryFilter::LegacyCallData* calld = call_attempt->calld_;
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p attempt=%p batch_data=%p: "
"got on_complete, error=%s, batch=%s",
@ -1309,7 +1311,7 @@ void RetryFilter::LegacyCallData::CallAttempt::BatchData::OnComplete(
// recv_trailing_metadata comes back.
if (GPR_UNLIKELY(!calld->retry_committed_ && !error.ok() &&
!call_attempt->completed_recv_trailing_metadata_)) {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p attempt=%p: deferring on_complete",
calld->chand_, calld, call_attempt);
}
@ -1363,7 +1365,7 @@ void RetryFilter::LegacyCallData::CallAttempt::BatchData::OnCompleteForCancelOp(
RefCountedPtr<BatchData> batch_data(static_cast<BatchData*>(arg));
CallAttempt* call_attempt = batch_data->call_attempt_;
RetryFilter::LegacyCallData* calld = call_attempt->calld_;
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p attempt=%p batch_data=%p: "
"got on_complete for cancel_stream batch, error=%s, batch=%s",
@ -1407,7 +1409,7 @@ void RetryFilter::LegacyCallData::CallAttempt::BatchData::
void RetryFilter::LegacyCallData::CallAttempt::BatchData::
AddRetriableSendMessageOp() {
auto* calld = call_attempt_->calld_;
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(
GPR_INFO,
"chand=%p calld=%p attempt=%p: starting calld->send_messages[%" PRIuPTR
@ -1496,7 +1498,7 @@ grpc_error_handle RetryFilter::LegacyCallData::Init(
grpc_call_element* elem, const grpc_call_element_args* args) {
auto* chand = static_cast<RetryFilter*>(elem->channel_data);
new (elem->call_data) RetryFilter::LegacyCallData(chand, *args);
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p: created call", chand,
elem->call_data);
}
@ -1578,7 +1580,8 @@ RetryFilter::LegacyCallData::~LegacyCallData() {
void RetryFilter::LegacyCallData::StartTransportStreamOpBatch(
grpc_transport_stream_op_batch* batch) {
if (GRPC_TRACE_FLAG_ENABLED(retry) && !GRPC_TRACE_FLAG_ENABLED(channel)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace) &&
!GRPC_TRACE_FLAG_ENABLED(grpc_trace_channel)) {
gpr_log(GPR_INFO, "chand=%p calld=%p: batch started from surface: %s",
chand_, this,
grpc_transport_stream_op_batch_string(batch, false).c_str());
@ -1601,7 +1604,7 @@ void RetryFilter::LegacyCallData::StartTransportStreamOpBatch(
if (GPR_UNLIKELY(batch->cancel_stream)) {
// Save cancel_error in case subsequent batches are started.
cancelled_from_surface_ = batch->payload->cancel_stream.cancel_error;
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p: cancelled from surface: %s", chand_,
this, StatusToString(cancelled_from_surface_).c_str());
}
@ -1624,7 +1627,7 @@ void RetryFilter::LegacyCallData::StartTransportStreamOpBatch(
}
// Cancel retry timer if needed.
if (retry_timer_handle_.has_value()) {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p: cancelling retry timer", chand_,
this);
}
@ -1670,7 +1673,7 @@ void RetryFilter::LegacyCallData::StartTransportStreamOpBatch(
if (!retry_codepath_started_ && retry_committed_ &&
(retry_policy_ == nullptr ||
!retry_policy_->per_attempt_recv_timeout().has_value())) {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p: retry committed before first attempt; "
"creating LB call",
@ -1689,7 +1692,7 @@ void RetryFilter::LegacyCallData::StartTransportStreamOpBatch(
// Otherwise, create a call attempt.
// The attempt will automatically start any necessary replays or
// pending batches.
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p: creating call attempt", chand_,
this);
}
@ -1698,7 +1701,7 @@ void RetryFilter::LegacyCallData::StartTransportStreamOpBatch(
return;
}
// Send batches to call attempt.
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p: starting batch on attempt=%p", chand_,
this, call_attempt_.get());
}
@ -1756,7 +1759,7 @@ void RetryFilter::LegacyCallData::MaybeCacheSendOpsForBatch(
}
void RetryFilter::LegacyCallData::FreeCachedSendInitialMetadata() {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p: destroying send_initial_metadata",
chand_, this);
}
@ -1765,7 +1768,7 @@ void RetryFilter::LegacyCallData::FreeCachedSendInitialMetadata() {
void RetryFilter::LegacyCallData::FreeCachedSendMessage(size_t idx) {
if (send_messages_[idx].slices != nullptr) {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p: destroying send_messages[%" PRIuPTR "]",
chand_, this, idx);
@ -1775,7 +1778,7 @@ void RetryFilter::LegacyCallData::FreeCachedSendMessage(size_t idx) {
}
void RetryFilter::LegacyCallData::FreeCachedSendTrailingMetadata() {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p: destroying send_trailing_metadata",
chand_, this);
}
@ -1814,7 +1817,7 @@ RetryFilter::LegacyCallData::PendingBatch*
RetryFilter::LegacyCallData::PendingBatchesAdd(
grpc_transport_stream_op_batch* batch) {
const size_t idx = GetBatchIndex(batch);
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p: adding pending batch at index %" PRIuPTR,
chand_, this, idx);
@ -1845,7 +1848,7 @@ RetryFilter::LegacyCallData::PendingBatchesAdd(
// ops have already been sent, and we commit to that attempt.
if (GPR_UNLIKELY(bytes_buffered_for_retry_ >
chand_->per_rpc_retry_buffer_size())) {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p: exceeded retry buffer size, committing",
chand_, this);
@ -1882,7 +1885,7 @@ void RetryFilter::LegacyCallData::MaybeClearPendingBatch(
(!batch->recv_trailing_metadata ||
batch->payload->recv_trailing_metadata.recv_trailing_metadata_ready ==
nullptr)) {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p: clearing pending batch", chand_,
this);
}
@ -1905,7 +1908,7 @@ void RetryFilter::LegacyCallData::FailPendingBatchInCallCombiner(
// This is called via the call combiner, so access to calld is synchronized.
void RetryFilter::LegacyCallData::PendingBatchesFail(grpc_error_handle error) {
CHECK(!error.ok());
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
size_t num_batches = 0;
for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
if (pending_batches_[i].batch != nullptr) ++num_batches;
@ -1939,7 +1942,7 @@ RetryFilter::LegacyCallData::PendingBatchFind(const char* log_message,
PendingBatch* pending = &pending_batches_[i];
grpc_transport_stream_op_batch* batch = pending->batch;
if (batch != nullptr && predicate(batch)) {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p: %s pending batch at index %" PRIuPTR,
chand_, this, log_message, i);
@ -1957,7 +1960,7 @@ RetryFilter::LegacyCallData::PendingBatchFind(const char* log_message,
void RetryFilter::LegacyCallData::RetryCommit(CallAttempt* call_attempt) {
if (retry_committed_) return;
retry_committed_ = true;
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p: committing retries", chand_, this);
}
if (call_attempt != nullptr) {
@ -1991,7 +1994,7 @@ void RetryFilter::LegacyCallData::StartRetryTimer(
} else {
next_attempt_timeout = retry_backoff_.NextAttemptTime() - Timestamp::Now();
}
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO,
"chand=%p calld=%p: retrying failed call in %" PRId64 " ms", chand_,
this, next_attempt_timeout.millis());
@ -2024,7 +2027,7 @@ void RetryFilter::LegacyCallData::OnRetryTimerLocked(
void RetryFilter::LegacyCallData::AddClosureToStartTransparentRetry(
CallCombinerClosureList* closures) {
if (GRPC_TRACE_FLAG_ENABLED(retry)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_retry_trace)) {
gpr_log(GPR_INFO, "chand=%p calld=%p: scheduling transparent retry", chand_,
this);
}

View File

@ -94,6 +94,9 @@ namespace grpc_core {
using ::grpc_event_engine::experimental::EventEngine;
TraceFlag grpc_trace_subchannel(false, "subchannel");
DebugOnlyTraceFlag grpc_trace_subchannel_refcount(false, "subchannel_refcount");
//
// ConnectedSubchannel
//
@ -102,8 +105,9 @@ ConnectedSubchannel::ConnectedSubchannel(
const ChannelArgs& args,
RefCountedPtr<channelz::SubchannelNode> channelz_subchannel)
: RefCounted<ConnectedSubchannel>(
GRPC_TRACE_FLAG_ENABLED(subchannel_refcount) ? "ConnectedSubchannel"
: nullptr),
GRPC_TRACE_FLAG_ENABLED(grpc_trace_subchannel_refcount)
? "ConnectedSubchannel"
: nullptr),
args_(args),
channelz_subchannel_(std::move(channelz_subchannel)) {}
@ -417,7 +421,7 @@ class Subchannel::ConnectedSubchannelStateWatcher final
if (c->connected_subchannel_ == nullptr) return;
if (new_state == GRPC_CHANNEL_TRANSIENT_FAILURE ||
new_state == GRPC_CHANNEL_SHUTDOWN) {
if (GRPC_TRACE_FLAG_ENABLED(subchannel)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_subchannel)) {
gpr_log(GPR_INFO,
"subchannel %p %s: Connected subchannel %p reports %s: %s", c,
c->key_.ToString().c_str(), c->connected_subchannel_.get(),
@ -516,9 +520,9 @@ BackOff::Options ParseArgsForBackoffValues(const ChannelArgs& args,
Subchannel::Subchannel(SubchannelKey key,
OrphanablePtr<SubchannelConnector> connector,
const ChannelArgs& args)
: DualRefCounted<Subchannel>(GRPC_TRACE_FLAG_ENABLED(subchannel_refcount)
? "Subchannel"
: nullptr),
: DualRefCounted<Subchannel>(
GRPC_TRACE_FLAG_ENABLED(grpc_trace_subchannel_refcount) ? "Subchannel"
: nullptr),
key_(std::move(key)),
args_(args),
pollset_set_(grpc_pollset_set_create()),
@ -602,7 +606,7 @@ void Subchannel::ThrottleKeepaliveTime(int new_keepalive_time) {
// Only update the value if the new keepalive time is larger.
if (new_keepalive_time > keepalive_time_) {
keepalive_time_ = new_keepalive_time;
if (GRPC_TRACE_FLAG_ENABLED(subchannel)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_subchannel)) {
gpr_log(GPR_INFO, "subchannel %p %s: throttling keepalive time to %d",
this, key_.ToString().c_str(), new_keepalive_time);
}
@ -877,7 +881,7 @@ bool Subchannel::PublishTransportLocked() {
}
connecting_result_.Reset();
// Publish.
if (GRPC_TRACE_FLAG_ENABLED(subchannel)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_subchannel)) {
gpr_log(GPR_INFO, "subchannel %p %s: new connected subchannel at %p", this,
key_.ToString().c_str(), connected_subchannel_.get());
}

View File

@ -36,6 +36,8 @@
namespace grpc_core {
TraceFlag grpc_subchannel_pool_trace(false, "subchannel_pool");
SubchannelKey::SubchannelKey(const grpc_resolved_address& address,
const ChannelArgs& args)
: address_(address), args_(args) {}

View File

@ -36,6 +36,8 @@ namespace grpc_core {
class Subchannel;
extern TraceFlag grpc_subchannel_pool_trace;
// A key that can uniquely identify a subchannel.
class SubchannelKey final {
public:
@ -66,7 +68,7 @@ class SubchannelKey final {
class SubchannelPoolInterface : public RefCounted<SubchannelPoolInterface> {
public:
SubchannelPoolInterface()
: RefCounted(GRPC_TRACE_FLAG_ENABLED(subchannel_pool)
: RefCounted(GRPC_TRACE_FLAG_ENABLED(grpc_subchannel_pool_trace)
? "SubchannelPoolInterface"
: nullptr) {}
~SubchannelPoolInterface() override {}

View File

@ -46,6 +46,8 @@
namespace grpc_core {
TraceFlag grpc_backend_metric_filter_trace(false, "backend_metric_filter");
const NoInterceptor BackendMetricFilter::Call::OnClientInitialMetadata;
const NoInterceptor BackendMetricFilter::Call::OnServerInitialMetadata;
const NoInterceptor BackendMetricFilter::Call::OnClientToServerMessage;
@ -129,20 +131,20 @@ void BackendMetricFilter::Call::OnServerTrailingMetadata(ServerMetadata& md) {
if (md.get(GrpcCallWasCancelled()).value_or(false)) return;
auto* ctx = MaybeGetContext<BackendMetricProvider>();
if (ctx == nullptr) {
if (GRPC_TRACE_FLAG_ENABLED(backend_metric_filter)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_backend_metric_filter_trace)) {
gpr_log(GPR_INFO, "[%p] No BackendMetricProvider.", this);
}
return;
}
absl::optional<std::string> serialized = MaybeSerializeBackendMetrics(ctx);
if (serialized.has_value() && !serialized->empty()) {
if (GRPC_TRACE_FLAG_ENABLED(backend_metric_filter)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_backend_metric_filter_trace)) {
gpr_log(GPR_INFO, "[%p] Backend metrics serialized. size: %" PRIuPTR,
this, serialized->size());
}
md.Set(EndpointLoadMetricsBinMetadata(),
Slice::FromCopiedString(std::move(*serialized)));
} else if (GRPC_TRACE_FLAG_ENABLED(backend_metric_filter)) {
} else if (GRPC_TRACE_FLAG_ENABLED(grpc_backend_metric_filter_trace)) {
gpr_log(GPR_INFO, "[%p] No backend metrics.", this);
}
}

View File

@ -68,11 +68,12 @@ const auto kDefaultMaxConnectionAgeGrace = Duration::Infinity();
const auto kDefaultMaxConnectionIdle = Duration::Infinity();
const auto kMaxConnectionAgeJitter = 0.1;
TraceFlag grpc_trace_client_idle_filter(false, "client_idle_filter");
} // namespace
#define GRPC_IDLE_FILTER_LOG(format, ...) \
do { \
if (GRPC_TRACE_FLAG_ENABLED(client_idle_filter)) { \
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_client_idle_filter)) { \
gpr_log(GPR_INFO, "(client idle filter) " format, ##__VA_ARGS__); \
} \
} while (0)

View File

@ -53,6 +53,7 @@
namespace grpc_core {
TraceFlag grpc_fault_injection_filter_trace(false, "fault_injection_filter");
const NoInterceptor FaultInjectionFilter::Call::OnServerInitialMetadata;
const NoInterceptor FaultInjectionFilter::Call::OnServerTrailingMetadata;
const NoInterceptor FaultInjectionFilter::Call::OnClientToServerMessage;
@ -150,7 +151,7 @@ FaultInjectionFilter::FaultInjectionFilter(ChannelFilter::Args filter_args)
ArenaPromise<absl::Status> FaultInjectionFilter::Call::OnClientInitialMetadata(
ClientMetadata& md, FaultInjectionFilter* filter) {
auto decision = filter->MakeInjectionDecision(md);
if (GRPC_TRACE_FLAG_ENABLED(fault_injection_filter)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_fault_injection_filter_trace)) {
gpr_log(GPR_INFO, "chand=%p: Fault injection triggered %s", this,
decision.ToString().c_str());
}

View File

@ -49,6 +49,7 @@
#include "src/core/lib/resource_quota/arena.h"
#include "src/core/lib/slice/slice_buffer.h"
#include "src/core/lib/surface/call.h"
#include "src/core/lib/surface/call_trace.h"
#include "src/core/lib/transport/metadata_batch.h"
#include "src/core/lib/transport/transport.h"
#include "src/core/telemetry/call_tracer.h"
@ -113,7 +114,7 @@ ChannelCompression::ChannelCompression(const ChannelArgs& args)
MessageHandle ChannelCompression::CompressMessage(
MessageHandle message, grpc_compression_algorithm algorithm) const {
if (GRPC_TRACE_FLAG_ENABLED(compression)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_compression_trace)) {
gpr_log(GPR_INFO, "CompressMessage: len=%" PRIdPTR " alg=%d flags=%d",
message->payload()->Length(), algorithm, message->flags());
}
@ -137,7 +138,7 @@ MessageHandle ChannelCompression::CompressMessage(
// If we achieved compression send it as compressed, otherwise send it as (to
// avoid spending cycles on the receiver decompressing).
if (did_compress) {
if (GRPC_TRACE_FLAG_ENABLED(compression)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_compression_trace)) {
const char* algo_name;
const size_t before_size = payload->Length();
const size_t after_size = tmp.Length();
@ -155,7 +156,7 @@ MessageHandle ChannelCompression::CompressMessage(
call_tracer->RecordSendCompressedMessage(*message->payload());
}
} else {
if (GRPC_TRACE_FLAG_ENABLED(compression)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_compression_trace)) {
const char* algo_name;
CHECK(grpc_compression_algorithm_name(algorithm, &algo_name));
gpr_log(GPR_INFO,
@ -169,7 +170,7 @@ MessageHandle ChannelCompression::CompressMessage(
absl::StatusOr<MessageHandle> ChannelCompression::DecompressMessage(
bool is_client, MessageHandle message, DecompressArgs args) const {
if (GRPC_TRACE_FLAG_ENABLED(compression)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_compression_trace)) {
gpr_log(GPR_INFO, "DecompressMessage: len=%" PRIdPTR " max=%d alg=%d",
message->payload()->Length(),
args.max_recv_message_length.value_or(-1), args.algorithm);

View File

@ -44,6 +44,7 @@
#include "src/core/lib/resource_quota/arena.h"
#include "src/core/lib/slice/percent_encoding.h"
#include "src/core/lib/slice/slice.h"
#include "src/core/lib/surface/call_trace.h"
#include "src/core/lib/transport/metadata_batch.h"
namespace grpc_core {
@ -139,7 +140,7 @@ ServerMetadataHandle HttpServerFilter::Call::OnClientInitialMetadata(
}
void HttpServerFilter::Call::OnServerInitialMetadata(ServerMetadata& md) {
if (GRPC_TRACE_FLAG_ENABLED(call)) {
if (grpc_call_trace.enabled()) {
gpr_log(GPR_INFO, "%s[http-server] Write metadata",
GetContext<Activity>()->DebugTag().c_str());
}

View File

@ -40,6 +40,7 @@
#include "src/core/lib/resource_quota/arena.h"
#include "src/core/lib/slice/slice.h"
#include "src/core/lib/slice/slice_buffer.h"
#include "src/core/lib/surface/call_trace.h"
#include "src/core/lib/surface/channel_stack_type.h"
#include "src/core/lib/transport/metadata_batch.h"
#include "src/core/lib/transport/transport.h"
@ -159,7 +160,7 @@ ServerMetadataHandle CheckPayload(const Message& msg,
absl::optional<uint32_t> max_length,
bool is_client, bool is_send) {
if (!max_length.has_value()) return nullptr;
if (GRPC_TRACE_FLAG_ENABLED(call)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_call_trace)) {
gpr_log(GPR_INFO, "%s[message_size] %s len:%" PRIdPTR " max:%d",
GetContext<Activity>()->DebugTag().c_str(),
is_send ? "send" : "recv", msg.payload()->Length(), *max_length);

View File

@ -57,6 +57,7 @@
namespace grpc_core {
TraceFlag grpc_stateful_session_filter_trace(false, "stateful_session_filter");
const NoInterceptor StatefulSessionFilter::Call::OnClientToServerMessage;
const NoInterceptor StatefulSessionFilter::Call::OnClientToServerHalfClose;
const NoInterceptor StatefulSessionFilter::Call::OnServerToClientMessage;

View File

@ -0,0 +1,21 @@
// Copyright 2023 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/core/ext/transport/chaotic_good/chaotic_good_transport.h"
#include <grpc/support/port_platform.h>
grpc_core::TraceFlag grpc_chaotic_good_trace(false, "chaotic_good");
namespace grpc_core {} // namespace grpc_core

View File

@ -33,6 +33,8 @@
#include "src/core/lib/promise/try_seq.h"
#include "src/core/lib/transport/promise_endpoint.h"
extern grpc_core::TraceFlag grpc_chaotic_good_trace;
namespace grpc_core {
namespace chaotic_good {
@ -52,10 +54,8 @@ class ChaoticGoodTransport : public RefCounted<ChaoticGoodTransport> {
}
auto WriteFrame(const FrameInterface& frame) {
bool saw_encoding_errors = false;
auto buffers = frame.Serialize(&encoder_, saw_encoding_errors);
// ignore encoding errors: they will be logged separately already
if (GRPC_TRACE_FLAG_ENABLED(chaotic_good)) {
auto buffers = frame.Serialize(&encoder_);
if (grpc_chaotic_good_trace.enabled()) {
gpr_log(GPR_INFO, "CHAOTIC_GOOD: WriteFrame to:%s %s",
ResolvedAddressToString(control_endpoint_.GetPeerAddress())
.value_or("<<unknown peer address>>")
@ -76,7 +76,7 @@ class ChaoticGoodTransport : public RefCounted<ChaoticGoodTransport> {
auto frame_header =
FrameHeader::Parse(reinterpret_cast<const uint8_t*>(
GRPC_SLICE_START_PTR(read_buffer.c_slice())));
if (GRPC_TRACE_FLAG_ENABLED(chaotic_good)) {
if (grpc_chaotic_good_trace.enabled()) {
gpr_log(GPR_INFO, "CHAOTIC_GOOD: ReadHeader from:%s %s",
ResolvedAddressToString(control_endpoint_.GetPeerAddress())
.value_or("<<unknown peer address>>")
@ -125,7 +125,7 @@ class ChaoticGoodTransport : public RefCounted<ChaoticGoodTransport> {
FrameLimits limits) {
auto s = frame.Deserialize(&parser_, header, bitgen_, arena,
std::move(buffers), limits);
if (GRPC_TRACE_FLAG_ENABLED(chaotic_good)) {
if (grpc_chaotic_good_trace.enabled()) {
gpr_log(GPR_INFO, "CHAOTIC_GOOD: DeserializeFrame %s",
s.ok() ? frame.ToString().c_str() : s.ToString().c_str());
}

View File

@ -114,10 +114,7 @@ auto ChaoticGoodConnector::DataEndpointWriteSettingsFrame(
frame.headers = SettingsMetadata{SettingsMetadata::ConnectionType::kData,
self->connection_id_, kDataAlignmentBytes}
.ToMetadataBatch();
bool saw_encoding_errors = false;
auto write_buffer =
frame.Serialize(&self->hpack_compressor_, saw_encoding_errors);
// ignore encoding errors: they will be logged separately already
auto write_buffer = frame.Serialize(&self->hpack_compressor_);
return self->data_endpoint_.Write(std::move(write_buffer.control));
}
@ -218,10 +215,7 @@ auto ChaoticGoodConnector::ControlEndpointWriteSettingsFrame(
frame.headers = SettingsMetadata{SettingsMetadata::ConnectionType::kControl,
absl::nullopt, absl::nullopt}
.ToMetadataBatch();
bool saw_encoding_errors = false;
auto write_buffer =
frame.Serialize(&self->hpack_compressor_, saw_encoding_errors);
// ignore encoding errors: they will be logged separately already
auto write_buffer = frame.Serialize(&self->hpack_compressor_);
return self->control_endpoint_.Write(std::move(write_buffer.control));
}
@ -319,7 +313,7 @@ void ChaoticGoodConnector::OnHandshakeDone(void* arg, grpc_error_handle error) {
},
EventEngineWakeupScheduler(self->event_engine_),
[self](absl::Status status) {
if (GRPC_TRACE_FLAG_ENABLED(chaotic_good)) {
if (grpc_chaotic_good_trace.enabled()) {
gpr_log(GPR_INFO, "ChaoticGoodConnector::OnHandshakeDone: %s",
status.ToString().c_str());
}

View File

@ -259,7 +259,7 @@ auto ChaoticGoodClientTransport::CallOutboundLoop(uint32_t stream_id,
// Wait for initial metadata then send it out.
call_handler.PullClientInitialMetadata(),
[send_fragment](ClientMetadataHandle md) mutable {
if (GRPC_TRACE_FLAG_ENABLED(chaotic_good)) {
if (grpc_chaotic_good_trace.enabled()) {
gpr_log(GPR_INFO, "CHAOTIC_GOOD: Sending initial metadata: %s",
md->DebugString().c_str());
}
@ -298,7 +298,7 @@ void ChaoticGoodClientTransport::StartCall(CallHandler call_handler) {
const uint32_t stream_id = MakeStream(call_handler);
return Map(CallOutboundLoop(stream_id, call_handler),
[stream_id, this](absl::Status result) {
if (GRPC_TRACE_FLAG_ENABLED(chaotic_good)) {
if (grpc_chaotic_good_trace.enabled()) {
gpr_log(GPR_INFO, "CHAOTIC_GOOD: Call %d finished with %s",
stream_id, result.ToString().c_str());
}

View File

@ -218,12 +218,10 @@ absl::Status SettingsFrame::Deserialize(HPackParser* parser,
return deserializer.Finish();
}
BufferPair SettingsFrame::Serialize(HPackCompressor* encoder,
bool& saw_encoding_errors) const {
BufferPair SettingsFrame::Serialize(HPackCompressor* encoder) const {
FrameSerializer serializer(FrameType::kSettings, 0);
if (headers.get() != nullptr) {
saw_encoding_errors |=
!encoder->EncodeRawHeaders(*headers.get(), serializer.AddHeaders());
encoder->EncodeRawHeaders(*headers.get(), serializer.AddHeaders());
}
return serializer.Finish();
}
@ -277,13 +275,11 @@ absl::Status ClientFragmentFrame::Deserialize(HPackParser* parser,
return deserializer.Finish();
}
BufferPair ClientFragmentFrame::Serialize(HPackCompressor* encoder,
bool& saw_encoding_errors) const {
BufferPair ClientFragmentFrame::Serialize(HPackCompressor* encoder) const {
CHECK_NE(stream_id, 0u);
FrameSerializer serializer(FrameType::kFragment, stream_id);
if (headers.get() != nullptr) {
saw_encoding_errors |=
!encoder->EncodeRawHeaders(*headers.get(), serializer.AddHeaders());
encoder->EncodeRawHeaders(*headers.get(), serializer.AddHeaders());
}
if (message.has_value()) {
serializer.AddMessage(message.value());
@ -358,20 +354,17 @@ absl::Status ServerFragmentFrame::Deserialize(HPackParser* parser,
return deserializer.Finish();
}
BufferPair ServerFragmentFrame::Serialize(HPackCompressor* encoder,
bool& saw_encoding_errors) const {
BufferPair ServerFragmentFrame::Serialize(HPackCompressor* encoder) const {
CHECK_NE(stream_id, 0u);
FrameSerializer serializer(FrameType::kFragment, stream_id);
if (headers.get() != nullptr) {
saw_encoding_errors |=
!encoder->EncodeRawHeaders(*headers.get(), serializer.AddHeaders());
encoder->EncodeRawHeaders(*headers.get(), serializer.AddHeaders());
}
if (message.has_value()) {
serializer.AddMessage(message.value());
}
if (trailers.get() != nullptr) {
saw_encoding_errors |=
!encoder->EncodeRawHeaders(*trailers.get(), serializer.AddTrailers());
encoder->EncodeRawHeaders(*trailers.get(), serializer.AddTrailers());
}
return serializer.Finish();
}
@ -406,7 +399,7 @@ absl::Status CancelFrame::Deserialize(HPackParser*, const FrameHeader& header,
return deserializer.Finish();
}
BufferPair CancelFrame::Serialize(HPackCompressor*, bool&) const {
BufferPair CancelFrame::Serialize(HPackCompressor*) const {
CHECK_NE(stream_id, 0u);
FrameSerializer serializer(FrameType::kCancel, stream_id);
return serializer.Finish();

View File

@ -55,15 +55,9 @@ class FrameInterface {
const FrameHeader& header,
absl::BitGenRef bitsrc, Arena* arena,
BufferPair buffers, FrameLimits limits) = 0;
virtual BufferPair Serialize(HPackCompressor* encoder,
bool& saw_encoding_errors) const = 0;
virtual BufferPair Serialize(HPackCompressor* encoder) const = 0;
virtual std::string ToString() const = 0;
template <typename Sink>
friend void AbslStringify(Sink& sink, const FrameInterface& frame) {
sink.Append(frame.ToString());
}
protected:
static bool EqVal(const grpc_metadata_batch& a,
const grpc_metadata_batch& b) {
@ -78,16 +72,11 @@ class FrameInterface {
~FrameInterface() = default;
};
inline std::ostream& operator<<(std::ostream& os, const FrameInterface& frame) {
return os << frame.ToString();
}
struct SettingsFrame final : public FrameInterface {
absl::Status Deserialize(HPackParser* parser, const FrameHeader& header,
absl::BitGenRef bitsrc, Arena* arena,
BufferPair buffers, FrameLimits limits) override;
BufferPair Serialize(HPackCompressor* encoder,
bool& saw_encoding_errors) const override;
BufferPair Serialize(HPackCompressor* encoder) const override;
ClientMetadataHandle headers;
std::string ToString() const override;
@ -121,8 +110,7 @@ struct ClientFragmentFrame final : public FrameInterface {
absl::Status Deserialize(HPackParser* parser, const FrameHeader& header,
absl::BitGenRef bitsrc, Arena* arena,
BufferPair buffers, FrameLimits limits) override;
BufferPair Serialize(HPackCompressor* encoder,
bool& saw_encoding_errors) const override;
BufferPair Serialize(HPackCompressor* encoder) const override;
std::string ToString() const override;
uint32_t stream_id;
@ -140,8 +128,7 @@ struct ServerFragmentFrame final : public FrameInterface {
absl::Status Deserialize(HPackParser* parser, const FrameHeader& header,
absl::BitGenRef bitsrc, Arena* arena,
BufferPair buffers, FrameLimits limits) override;
BufferPair Serialize(HPackCompressor* encoder,
bool& saw_encoding_errors) const override;
BufferPair Serialize(HPackCompressor* encoder) const override;
std::string ToString() const override;
uint32_t stream_id;
@ -159,8 +146,7 @@ struct CancelFrame final : public FrameInterface {
absl::Status Deserialize(HPackParser* parser, const FrameHeader& header,
absl::BitGenRef bitsrc, Arena* arena,
BufferPair buffers, FrameLimits limits) override;
BufferPair Serialize(HPackCompressor* encoder,
bool& saw_encoding_errors) const override;
BufferPair Serialize(HPackCompressor* encoder) const override;
std::string ToString() const override;
uint32_t stream_id;

View File

@ -34,19 +34,6 @@ enum class FrameType : uint8_t {
kCancel = 0x81,
};
inline std::ostream& operator<<(std::ostream& out, FrameType type) {
switch (type) {
case FrameType::kSettings:
return out << "Settings";
case FrameType::kFragment:
return out << "Fragment";
case FrameType::kCancel:
return out << "Cancel";
default:
return out << "Unknown[" << static_cast<int>(type) << "]";
}
}
struct FrameHeader {
FrameType type = FrameType::kCancel;
BitSet<3> flags;

View File

@ -98,7 +98,7 @@ ChaoticGoodServerListener::~ChaoticGoodServerListener() {
absl::StatusOr<int> ChaoticGoodServerListener::Bind(
grpc_event_engine::experimental::EventEngine::ResolvedAddress addr) {
if (GRPC_TRACE_FLAG_ENABLED(chaotic_good)) {
if (grpc_chaotic_good_trace.enabled()) {
auto str = grpc_event_engine::experimental::ResolvedAddressToString(addr);
LOG(INFO) << "CHAOTIC_GOOD: Listen on "
<< (str.ok() ? str->c_str() : str.status().ToString());
@ -139,9 +139,9 @@ absl::Status ChaoticGoodServerListener::StartListening() {
CHECK(ee_listener_ != nullptr);
auto status = ee_listener_->Start();
if (!status.ok()) {
LOG(ERROR) << "Start listening failed: " << status;
} else {
GRPC_TRACE_LOG(chaotic_good, INFO) << "CHAOTIC_GOOD: Started listening";
LOG(ERROR) << "Start listening failed: " << status.ToString();
} else if (grpc_chaotic_good_trace.enabled()) {
LOG(INFO) << "CHAOTIC_GOOD: Started listening";
}
return status;
}
@ -159,7 +159,9 @@ ChaoticGoodServerListener::ActiveConnection::~ActiveConnection() {
}
void ChaoticGoodServerListener::ActiveConnection::Orphan() {
GRPC_TRACE_LOG(chaotic_good, INFO) << "ActiveConnection::Orphan() " << this;
if (grpc_chaotic_good_trace.enabled()) {
LOG(INFO) << "ActiveConnection::Orphan() " << this;
}
if (handshaking_state_ != nullptr) {
handshaking_state_->Shutdown();
handshaking_state_.reset();
@ -297,7 +299,7 @@ auto ChaoticGoodServerListener::ActiveConnection::HandshakingState::
},
[self](PromiseEndpoint ret) -> absl::Status {
MutexLock lock(&self->connection_->listener_->mu_);
if (GRPC_TRACE_FLAG_ENABLED(chaotic_good)) {
if (grpc_chaotic_good_trace.enabled()) {
gpr_log(
GPR_INFO, "%p Data endpoint setup done: shutdown=%s",
self->connection_.get(),
@ -336,10 +338,7 @@ auto ChaoticGoodServerListener::ActiveConnection::HandshakingState::
SettingsMetadata{absl::nullopt, self->connection_->connection_id_,
absl::nullopt}
.ToMetadataBatch();
bool saw_encoding_errors = false;
auto write_buffer = frame.Serialize(&self->connection_->hpack_compressor_,
saw_encoding_errors);
// ignore encoding errors: they will be logged separately already
auto write_buffer = frame.Serialize(&self->connection_->hpack_compressor_);
return TrySeq(
self->connection_->endpoint_.Write(std::move(write_buffer.control)),
WaitForDataEndpointSetup(self));
@ -353,10 +352,7 @@ auto ChaoticGoodServerListener::ActiveConnection::HandshakingState::
SettingsMetadata{absl::nullopt, self->connection_->connection_id_,
self->connection_->data_alignment_}
.ToMetadataBatch();
bool saw_encoding_errors = false;
auto write_buffer = frame.Serialize(&self->connection_->hpack_compressor_,
saw_encoding_errors);
// ignore encoding errors: they will be logged separately already
auto write_buffer = frame.Serialize(&self->connection_->hpack_compressor_);
return TrySeq(
self->connection_->endpoint_.Write(std::move(write_buffer.control)),
[self]() mutable {
@ -449,14 +445,19 @@ void ChaoticGoodServerListener::ActiveConnection::HandshakingState::
Timestamp ChaoticGoodServerListener::ActiveConnection::HandshakingState::
GetConnectionDeadline() {
return Timestamp::Now() +
connection_->args()
.GetDurationFromIntMillis(GRPC_ARG_SERVER_HANDSHAKE_TIMEOUT_MS)
.value_or(kConnectionDeadline);
if (connection_->args().Contains(GRPC_ARG_SERVER_HANDSHAKE_TIMEOUT_MS)) {
return Timestamp::Now() +
connection_->args()
.GetDurationFromIntMillis(GRPC_ARG_SERVER_HANDSHAKE_TIMEOUT_MS)
.value();
}
return Timestamp::Now() + kConnectionDeadline;
}
void ChaoticGoodServerListener::Orphan() {
GRPC_TRACE_LOG(chaotic_good, INFO) << "ChaoticGoodServerListener::Orphan()";
if (grpc_chaotic_good_trace.enabled()) {
LOG(INFO) << "ChaoticGoodServerListener::Orphan()";
}
{
absl::flat_hash_set<OrphanablePtr<ActiveConnection>> connection_list;
MutexLock lock(&mu_);

View File

@ -74,7 +74,7 @@ auto ChaoticGoodServerTransport::PushFragmentIntoCall(
CallInitiator call_initiator, ClientFragmentFrame frame,
uint32_t stream_id) {
DCHECK(frame.headers == nullptr);
if (GRPC_TRACE_FLAG_ENABLED(chaotic_good)) {
if (grpc_chaotic_good_trace.enabled()) {
gpr_log(GPR_INFO, "CHAOTIC_GOOD: PushFragmentIntoCall: frame=%s",
frame.ToString().c_str());
}
@ -87,7 +87,7 @@ auto ChaoticGoodServerTransport::PushFragmentIntoCall(
[]() -> StatusFlag { return Success{}; }),
[this, call_initiator, end_of_stream = frame.end_of_stream,
stream_id](StatusFlag status) mutable -> StatusFlag {
if (!status.ok() && GRPC_TRACE_FLAG_ENABLED(chaotic_good)) {
if (!status.ok() && grpc_chaotic_good_trace.enabled()) {
gpr_log(GPR_INFO, "CHAOTIC_GOOD: Failed PushFragmentIntoCall");
}
if (end_of_stream || !status.ok()) {
@ -135,7 +135,7 @@ auto ChaoticGoodServerTransport::MaybePushFragmentIntoCall(
auto ChaoticGoodServerTransport::SendFragment(
ServerFragmentFrame frame, MpscSender<ServerFrame> outgoing_frames,
CallInitiator call_initiator) {
if (GRPC_TRACE_FLAG_ENABLED(chaotic_good)) {
if (grpc_chaotic_good_trace.enabled()) {
gpr_log(GPR_INFO, "CHAOTIC_GOOD: SendFragment: frame=%s",
frame.ToString().c_str());
}
@ -187,7 +187,7 @@ auto ChaoticGoodServerTransport::SendCallInitialMetadataAndBody(
call_initiator.PullServerInitialMetadata(),
[stream_id, outgoing_frames, call_initiator,
this](absl::optional<ServerMetadataHandle> md) mutable {
if (GRPC_TRACE_FLAG_ENABLED(chaotic_good)) {
if (grpc_chaotic_good_trace.enabled()) {
gpr_log(GPR_INFO,
"CHAOTIC_GOOD: SendCallInitialMetadataAndBody: md=%s",
md.has_value() ? (*md)->DebugString().c_str() : "null");
@ -213,7 +213,7 @@ auto ChaoticGoodServerTransport::CallOutboundLoop(
return Seq(Map(SendCallInitialMetadataAndBody(stream_id, outgoing_frames,
call_initiator),
[stream_id](absl::Status main_body_result) {
if (GRPC_TRACE_FLAG_ENABLED(chaotic_good)) {
if (grpc_chaotic_good_trace.enabled()) {
gpr_log(GPR_DEBUG,
"CHAOTIC_GOOD: CallOutboundLoop: stream_id=%d "
"main_body_result=%s",
@ -345,7 +345,7 @@ auto ChaoticGoodServerTransport::OnTransportActivityDone(
absl::string_view activity) {
return [self = RefAsSubclass<ChaoticGoodServerTransport>(),
activity](absl::Status status) {
if (GRPC_TRACE_FLAG_ENABLED(chaotic_good)) {
if (grpc_chaotic_good_trace.enabled()) {
gpr_log(GPR_INFO,
"CHAOTIC_GOOD: OnTransportActivityDone: activity=%s status=%s",
std::string(activity).c_str(), status.ToString().c_str());

View File

@ -64,6 +64,7 @@
#include "src/core/ext/transport/chttp2/transport/frame_rst_stream.h"
#include "src/core/ext/transport/chttp2/transport/hpack_encoder.h"
#include "src/core/ext/transport/chttp2/transport/http2_settings.h"
#include "src/core/ext/transport/chttp2/transport/http_trace.h"
#include "src/core/ext/transport/chttp2/transport/internal.h"
#include "src/core/ext/transport/chttp2/transport/legacy_frame.h"
#include "src/core/ext/transport/chttp2/transport/max_concurrent_streams_policy.h"
@ -94,6 +95,7 @@
#include "src/core/lib/resource_quota/arena.h"
#include "src/core/lib/resource_quota/memory_quota.h"
#include "src/core/lib/resource_quota/resource_quota.h"
#include "src/core/lib/resource_quota/trace.h"
#include "src/core/lib/slice/slice.h"
#include "src/core/lib/slice/slice_buffer.h"
#include "src/core/lib/slice/slice_internal.h"
@ -141,6 +143,7 @@ static bool g_default_server_keepalive_permit_without_calls = false;
#define GRPC_ARG_HTTP_TARPIT_MAX_DURATION_MS "grpc.http.tarpit_max_duration_ms"
#define MAX_CLIENT_STREAM_ID 0x7fffffffu
grpc_core::TraceFlag grpc_keepalive_trace(false, "http_keepalive");
// forward declarations of various callbacks that we'll build closures around
static void write_action_begin_locked(
@ -824,9 +827,10 @@ grpc_chttp2_stream::grpc_chttp2_stream(grpc_chttp2_transport* t,
t->streams_allocated.fetch_add(1, std::memory_order_relaxed);
if (server_data) {
id = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(server_data));
GRPC_TRACE_VLOG(http, 2)
<< "HTTP:" << t << "/" << this << " creating accept stream " << id
<< " [from " << server_data << "]";
if (grpc_http_trace.enabled()) {
VLOG(2) << "HTTP:" << t << "/" << this << " creating accept stream " << id
<< " [from " << server_data << "]";
}
*t->accepting_stream = this;
t->stream_map.emplace(id, this);
post_destructive_reclaimer(t);
@ -1057,9 +1061,10 @@ static void write_action(grpc_chttp2_transport* t) {
if (max_frame_size == 0) {
max_frame_size = INT_MAX;
}
GRPC_TRACE_LOG(http2_ping, INFO)
<< (t->is_client ? "CLIENT" : "SERVER") << "[" << t << "]: Write "
<< t->outbuf.Length() << " bytes";
if (GRPC_TRACE_FLAG_ENABLED(grpc_ping_trace)) {
LOG(INFO) << (t->is_client ? "CLIENT" : "SERVER") << "[" << t << "]: Write "
<< t->outbuf.Length() << " bytes";
}
t->write_size_policy.BeginWrite(t->outbuf.Length());
grpc_endpoint_write(t->ep, t->outbuf.c_slice_buffer(),
grpc_core::InitTransportClosure<write_action_end>(
@ -1070,8 +1075,10 @@ static void write_action(grpc_chttp2_transport* t) {
static void write_action_end(grpc_core::RefCountedPtr<grpc_chttp2_transport> t,
grpc_error_handle error) {
auto* tp = t.get();
GRPC_TRACE_LOG(http2_ping, INFO) << (t->is_client ? "CLIENT" : "SERVER")
<< "[" << t.get() << "]: Finish write";
if (GRPC_TRACE_FLAG_ENABLED(grpc_ping_trace)) {
LOG(INFO) << (t->is_client ? "CLIENT" : "SERVER") << "[" << t.get()
<< "]: Finish write";
}
tp->combiner->Run(grpc_core::InitTransportClosure<write_action_end_locked>(
std::move(t), &tp->write_action_end_locked),
error);
@ -1288,7 +1295,7 @@ void grpc_chttp2_complete_closure_step(grpc_chttp2_transport* t,
return;
}
closure->next_data.scratch -= CLOSURE_BARRIER_FIRST_REF_BIT;
if (GRPC_TRACE_FLAG_ENABLED(http)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) {
gpr_log(
GPR_INFO,
"complete_closure_step: t=%p %p refs=%d flags=0x%04x desc=%s err=%s "
@ -1358,7 +1365,7 @@ static void perform_stream_op_locked(void* stream_op,
s->traced = op->is_traced;
s->call_tracer = CallTracerIfSampled(s);
s->tcp_tracer = TcpTracerIfSampled(s);
if (GRPC_TRACE_FLAG_ENABLED(http)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) {
gpr_log(GPR_INFO,
"perform_stream_op_locked[s=%p; op=%p]: %s; on_complete = %p", s,
op, grpc_transport_stream_op_batch_string(op, false).c_str(),
@ -1625,7 +1632,7 @@ void grpc_chttp2_transport::PerformStreamOp(
}
}
if (GRPC_TRACE_FLAG_ENABLED(http)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) {
gpr_log(GPR_INFO, "perform_stream_op[s=%p; op=%p]: %s", s, op,
grpc_transport_stream_op_batch_string(op, false).c_str());
}
@ -1969,7 +1976,7 @@ static void perform_transport_op_locked(void* stream_op,
}
void grpc_chttp2_transport::PerformOp(grpc_transport_op* op) {
if (GRPC_TRACE_FLAG_ENABLED(http)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) {
gpr_log(GPR_INFO, "perform_transport_op[t=%p]: %s", this,
grpc_transport_op_string(op).c_str());
}
@ -2022,7 +2029,7 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_chttp2_transport* t,
// Lambda is immediately invoked as a big scoped section that can be
// exited out of at any point by returning.
[&]() {
if (GRPC_TRACE_FLAG_ENABLED(http)) {
if (grpc_http_trace.enabled()) {
gpr_log(GPR_DEBUG,
"maybe_complete_recv_message %p final_metadata_requested=%d "
"seen_error=%d",
@ -2038,7 +2045,7 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_chttp2_transport* t,
int64_t min_progress_size;
auto r = grpc_deframe_unprocessed_incoming_frames(
s, &min_progress_size, &**s->recv_message, s->recv_message_flags);
if (GRPC_TRACE_FLAG_ENABLED(http)) {
if (grpc_http_trace.enabled()) {
gpr_log(GPR_DEBUG, "Deframe data frame: %s",
grpc_core::PollToString(r, [](absl::Status r) {
return r.ToString();
@ -2094,7 +2101,7 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_chttp2_transport* t,
void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_chttp2_transport* t,
grpc_chttp2_stream* s) {
grpc_chttp2_maybe_complete_recv_message(t, s);
if (GRPC_TRACE_FLAG_ENABLED(http)) {
if (grpc_http_trace.enabled()) {
gpr_log(GPR_DEBUG,
"maybe_complete_recv_trailing_metadata cli=%d s=%p closure=%p "
"read_closed=%d "
@ -2305,7 +2312,7 @@ grpc_chttp2_transport::RemovedStreamHandle grpc_chttp2_mark_stream_closed(
grpc_chttp2_transport* t, grpc_chttp2_stream* s, int close_reads,
int close_writes, grpc_error_handle error) {
grpc_chttp2_transport::RemovedStreamHandle rsh;
if (GRPC_TRACE_FLAG_ENABLED(http)) {
if (grpc_http_trace.enabled()) {
gpr_log(
GPR_DEBUG, "MARK_STREAM_CLOSED: t=%p s=%p(id=%d) %s [%s]", t, s, s->id,
(close_reads && close_writes)
@ -2736,8 +2743,8 @@ static void read_action_locked(
// got an incoming read, cancel any pending keepalive timers
t->keepalive_incoming_data_wanted = false;
if (t->keepalive_ping_timeout_handle != TaskHandle::kInvalid) {
if (GRPC_TRACE_FLAG_ENABLED(http2_ping) ||
GRPC_TRACE_FLAG_ENABLED(http_keepalive)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_ping_trace) ||
GRPC_TRACE_FLAG_ENABLED(grpc_keepalive_trace)) {
gpr_log(GPR_INFO,
"%s[%p]: Clear keepalive timer because data was received",
t->is_client ? "CLIENT" : "SERVER", t.get());
@ -2790,7 +2797,7 @@ static void start_bdp_ping(grpc_core::RefCountedPtr<grpc_chttp2_transport> t,
static void start_bdp_ping_locked(
grpc_core::RefCountedPtr<grpc_chttp2_transport> t,
grpc_error_handle error) {
if (GRPC_TRACE_FLAG_ENABLED(http)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) {
gpr_log(GPR_INFO, "%s: Start BDP ping err=%s",
std::string(t->peer_string.as_string_view()).c_str(),
grpc_core::StatusToString(error).c_str());
@ -2817,7 +2824,7 @@ static void finish_bdp_ping(grpc_core::RefCountedPtr<grpc_chttp2_transport> t,
static void finish_bdp_ping_locked(
grpc_core::RefCountedPtr<grpc_chttp2_transport> t,
grpc_error_handle error) {
if (GRPC_TRACE_FLAG_ENABLED(http)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) {
gpr_log(GPR_INFO, "%s: Complete BDP ping err=%s",
std::string(t->peer_string.as_string_view()).c_str(),
grpc_core::StatusToString(error).c_str());
@ -2961,8 +2968,8 @@ static void finish_keepalive_ping_locked(
grpc_error_handle error) {
if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_PINGING) {
if (error.ok()) {
if (GRPC_TRACE_FLAG_ENABLED(http) ||
GRPC_TRACE_FLAG_ENABLED(http_keepalive)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) ||
GRPC_TRACE_FLAG_ENABLED(grpc_keepalive_trace)) {
gpr_log(GPR_INFO, "%s: Finish keepalive ping",
std::string(t->peer_string.as_string_view()).c_str());
}
@ -2983,8 +2990,8 @@ static void maybe_reset_keepalive_ping_timer_locked(grpc_chttp2_transport* t) {
t->event_engine->Cancel(t->keepalive_ping_timer_handle)) {
// Cancel succeeds, resets the keepalive ping timer. Note that we don't
// need to Ref or Unref here since we still hold the Ref.
if (GRPC_TRACE_FLAG_ENABLED(http) ||
GRPC_TRACE_FLAG_ENABLED(http_keepalive)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) ||
GRPC_TRACE_FLAG_ENABLED(grpc_keepalive_trace)) {
gpr_log(GPR_INFO, "%s: Keepalive ping cancelled. Resetting timer.",
std::string(t->peer_string.as_string_view()).c_str());
}
@ -3083,7 +3090,7 @@ static void benign_reclaimer_locked(
if (error.ok() && t->stream_map.empty()) {
// Channel with no active streams: send a goaway to try and make it
// disconnect cleanly
if (GRPC_TRACE_FLAG_ENABLED(resource_quota)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_resource_quota_trace)) {
gpr_log(GPR_INFO, "HTTP2: %s - send goaway to free memory",
std::string(t->peer_string.as_string_view()).c_str());
}
@ -3092,7 +3099,7 @@ static void benign_reclaimer_locked(
grpc_core::StatusIntProperty::kHttp2Error,
GRPC_HTTP2_ENHANCE_YOUR_CALM),
/*immediate_disconnect_hint=*/true);
} else if (error.ok() && GRPC_TRACE_FLAG_ENABLED(resource_quota)) {
} else if (error.ok() && GRPC_TRACE_FLAG_ENABLED(grpc_resource_quota_trace)) {
gpr_log(GPR_INFO,
"HTTP2: %s - skip benign reclamation, there are still %" PRIdPTR
" streams",
@ -3112,7 +3119,7 @@ static void destructive_reclaimer_locked(
if (error.ok() && !t->stream_map.empty()) {
// As stream_map is a hash map, this selects effectively a random stream.
grpc_chttp2_stream* s = t->stream_map.begin()->second;
if (GRPC_TRACE_FLAG_ENABLED(resource_quota)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_resource_quota_trace)) {
gpr_log(GPR_INFO, "HTTP2: %s - abandon stream id %d",
std::string(t->peer_string.as_string_view()).c_str(), s->id);
}

View File

@ -40,6 +40,11 @@
#include "src/core/lib/transport/transport.h"
#include "src/core/telemetry/call_tracer.h"
extern grpc_core::TraceFlag grpc_keepalive_trace;
extern grpc_core::TraceFlag grpc_trace_http2_stream_state;
extern grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_refcount;
extern grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_hpack_parser;
/// Creates a CHTTP2 Transport. This takes ownership of a \a resource_user ref
/// from the caller; if the caller still needs the resource_user after creating
/// a transport, the caller must take another ref.

View File

@ -40,6 +40,8 @@
#include "src/core/lib/resource_quota/memory_quota.h"
#include "src/core/util/useful.h"
grpc_core::TraceFlag grpc_flowctl_trace(false, "flowctl");
namespace grpc_core {
namespace chttp2 {
@ -233,7 +235,7 @@ void TransportFlowControl::UpdateSetting(
FlowControlAction& (FlowControlAction::*set)(FlowControlAction::Urgency,
uint32_t)) {
if (new_desired_value != *desired_value) {
if (GRPC_TRACE_FLAG_ENABLED(flowctl)) {
if (grpc_flowctl_trace.enabled()) {
gpr_log(GPR_INFO, "[flowctl] UPDATE SETTING %s from %" PRId64 " to %d",
std::string(name).c_str(), *desired_value, new_desired_value);
}

View File

@ -41,6 +41,8 @@
#include "src/core/lib/resource_quota/memory_quota.h"
#include "src/core/lib/transport/bdp_estimator.h"
extern grpc_core::TraceFlag grpc_flowctl_trace;
namespace grpc {
namespace testing {
class TrickledCHTTP2; // to make this a friend

View File

@ -37,6 +37,9 @@
#include "src/core/ext/transport/chttp2/transport/ping_callbacks.h"
#include "src/core/lib/debug/trace.h"
extern grpc_core::TraceFlag grpc_keepalive_trace;
extern grpc_core::TraceFlag grpc_http_trace;
grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint64_t opaque_8bytes) {
grpc_slice slice = GRPC_SLICE_MALLOC(9 + 8);
uint8_t* p = GRPC_SLICE_START_PTR(slice);
@ -93,7 +96,7 @@ grpc_error_handle grpc_chttp2_ping_parser_parse(void* parser,
if (p->byte == 8) {
CHECK(is_last);
if (p->is_ack) {
if (GRPC_TRACE_FLAG_ENABLED(http2_ping)) {
if (grpc_ping_trace.enabled()) {
gpr_log(GPR_INFO, "%s[%p]: received ping ack %" PRIx64,
t->is_client ? "CLIENT" : "SERVER", t, p->opaque_8bytes);
}
@ -102,8 +105,7 @@ grpc_error_handle grpc_chttp2_ping_parser_parse(void* parser,
if (!t->is_client) {
const bool transport_idle =
t->keepalive_permit_without_calls == 0 && t->stream_map.empty();
if (GRPC_TRACE_FLAG_ENABLED(http_keepalive) ||
GRPC_TRACE_FLAG_ENABLED(http)) {
if (grpc_keepalive_trace.enabled() || grpc_http_trace.enabled()) {
gpr_log(GPR_INFO, "SERVER[%p]: received ping %" PRIx64 ": %s", t,
p->opaque_8bytes,
t->ping_abuse_policy.GetDebugString(transport_idle).c_str());
@ -111,7 +113,7 @@ grpc_error_handle grpc_chttp2_ping_parser_parse(void* parser,
if (t->ping_abuse_policy.ReceivedOnePing(transport_idle)) {
grpc_chttp2_exceeded_ping_strikes(t);
}
} else if (GRPC_TRACE_FLAG_ENABLED(http2_ping)) {
} else if (grpc_ping_trace.enabled()) {
gpr_log(GPR_INFO, "CLIENT[%p]: received ping %" PRIx64, t,
p->opaque_8bytes);
}

View File

@ -30,6 +30,7 @@
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include "src/core/ext/transport/chttp2/transport/http_trace.h"
#include "src/core/ext/transport/chttp2/transport/internal.h"
#include "src/core/ext/transport/chttp2/transport/legacy_frame.h"
#include "src/core/ext/transport/chttp2/transport/ping_callbacks.h"
@ -110,7 +111,7 @@ grpc_error_handle grpc_chttp2_rst_stream_parser_parse(void* parser,
((static_cast<uint32_t>(p->reason_bytes[1])) << 16) |
((static_cast<uint32_t>(p->reason_bytes[2])) << 8) |
((static_cast<uint32_t>(p->reason_bytes[3])));
if (GRPC_TRACE_FLAG_ENABLED(http)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) {
gpr_log(GPR_INFO,
"[chttp2 transport=%p stream=%p] received RST_STREAM(reason=%d)",
t, s, reason);

View File

@ -33,6 +33,7 @@
#include "src/core/ext/transport/chttp2/transport/flow_control.h"
#include "src/core/ext/transport/chttp2/transport/frame_goaway.h"
#include "src/core/ext/transport/chttp2/transport/http2_settings.h"
#include "src/core/ext/transport/chttp2/transport/http_trace.h"
#include "src/core/ext/transport/chttp2/transport/internal.h"
#include "src/core/ext/transport/chttp2/transport/legacy_frame.h"
#include "src/core/lib/debug/trace.h"
@ -170,8 +171,8 @@ grpc_error_handle grpc_chttp2_settings_parser_parse(void* p,
t->initial_window_update +=
static_cast<int64_t>(parser->value) -
parser->incoming_settings->initial_window_size();
if (GRPC_TRACE_FLAG_ENABLED(http) ||
GRPC_TRACE_FLAG_ENABLED(flowctl)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) ||
GRPC_TRACE_FLAG_ENABLED(grpc_flowctl_trace)) {
gpr_log(GPR_INFO, "%p[%s] adding %d for initial_window change", t,
t->is_client ? "cli" : "svr",
static_cast<int>(t->initial_window_update));
@ -187,7 +188,7 @@ grpc_error_handle grpc_chttp2_settings_parser_parse(void* p,
"invalid value %u passed for %s", parser->value,
grpc_core::Http2Settings::WireIdToName(parser->id).c_str()));
}
if (GRPC_TRACE_FLAG_ENABLED(http)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) {
gpr_log(GPR_INFO, "CHTTP2:%s:%s: got setting %s = %d",
t->is_client ? "CLI" : "SVR",
std::string(t->peer_string.as_string_view()).c_str(),

View File

@ -31,6 +31,7 @@
#include "src/core/ext/transport/chttp2/transport/bin_encoder.h"
#include "src/core/ext/transport/chttp2/transport/hpack_constants.h"
#include "src/core/ext/transport/chttp2/transport/hpack_encoder_table.h"
#include "src/core/ext/transport/chttp2/transport/http_trace.h"
#include "src/core/ext/transport/chttp2/transport/legacy_frame.h"
#include "src/core/ext/transport/chttp2/transport/varint.h"
#include "src/core/lib/debug/trace.h"
@ -117,7 +118,7 @@ void HPackCompressor::SetMaxUsableSize(uint32_t max_table_size) {
void HPackCompressor::SetMaxTableSize(uint32_t max_table_size) {
if (table_.SetMaxSize(std::min(max_usable_size_, max_table_size))) {
advertise_table_size_change_ = true;
if (GRPC_TRACE_FLAG_ENABLED(http)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) {
gpr_log(GPR_INFO, "set max table size from encoder to %d",
max_table_size);
}
@ -377,8 +378,7 @@ void Compressor<HttpSchemeMetadata, HttpSchemeCompressor>::EncodeWith(
encoder->EmitIndexed(7); // :scheme: https
break;
case HttpSchemeMetadata::ValueType::kInvalid:
LOG(ERROR) << "Not encoding bad http scheme";
encoder->NoteEncodingError();
Crash("invalid http scheme encoding");
break;
}
}
@ -435,8 +435,7 @@ void Compressor<HttpMethodMetadata, HttpMethodCompressor>::EncodeWith(
Slice::FromStaticString(":method"), Slice::FromStaticString("PUT"));
break;
case HttpMethodMetadata::ValueType::kInvalid:
LOG(ERROR) << "Not encoding bad http method";
encoder->NoteEncodingError();
Crash("invalid http method encoding");
break;
}
}

View File

@ -82,14 +82,10 @@ class Encoder {
const Slice& slice, uint32_t* index,
size_t max_compression_size);
void NoteEncodingError() { saw_encoding_errors_ = true; }
bool saw_encoding_errors() const { return saw_encoding_errors_; }
HPackEncoderTable& hpack_table();
private:
const bool use_true_binary_metadata_;
bool saw_encoding_errors_ = false;
HPackCompressor* const compressor_;
SliceBuffer& output_;
};
@ -211,7 +207,6 @@ class Compressor<
gpr_log(GPR_ERROR, "%s",
absl::StrCat("Not encoding bad ", MetadataTrait::key(), " header")
.c_str());
encoder->NoteEncodingError();
return;
}
Slice encoded(MetadataTrait::Encode(known_value));
@ -359,21 +354,19 @@ class HPackCompressor {
};
template <typename HeaderSet>
bool EncodeHeaders(const EncodeHeaderOptions& options,
void EncodeHeaders(const EncodeHeaderOptions& options,
const HeaderSet& headers, grpc_slice_buffer* output) {
SliceBuffer raw;
hpack_encoder_detail::Encoder encoder(
this, options.use_true_binary_metadata, raw);
headers.Encode(&encoder);
Frame(options, raw, output);
return !encoder.saw_encoding_errors();
}
template <typename HeaderSet>
bool EncodeRawHeaders(const HeaderSet& headers, SliceBuffer& output) {
void EncodeRawHeaders(const HeaderSet& headers, SliceBuffer& output) {
hpack_encoder_detail::Encoder encoder(this, true, output);
headers.Encode(&encoder);
return !encoder.saw_encoding_errors();
}
private:

View File

@ -59,6 +59,8 @@
namespace grpc_core {
TraceFlag grpc_trace_chttp2_hpack_parser(false, "chttp2_hpack_parser");
namespace {
// The alphabet used for base64 encoding binary metadata.
constexpr char kBase64Alphabet[] =
@ -731,7 +733,7 @@ class HPackParser::Parser {
bool FinishHeaderAndAddToTable(HPackTable::Memento md) {
// Log if desired
if (GRPC_TRACE_FLAG_ENABLED(chttp2_hpack_parser)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_chttp2_hpack_parser)) {
LogHeader(md);
}
// Emit whilst we own the metadata.
@ -756,7 +758,7 @@ class HPackParser::Parser {
void FinishHeaderOmitFromTable(const HPackTable::Memento& md) {
// Log if desired
if (GRPC_TRACE_FLAG_ENABLED(chttp2_hpack_parser)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_chttp2_hpack_parser)) {
LogHeader(md);
}
EmitHeader(md);

View File

@ -35,6 +35,7 @@
#include "src/core/ext/transport/chttp2/transport/hpack_constants.h"
#include "src/core/ext/transport/chttp2/transport/hpack_parse_result.h"
#include "src/core/ext/transport/chttp2/transport/http_trace.h"
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/slice/slice.h"
@ -98,7 +99,9 @@ void HPackTable::SetMaxBytes(uint32_t max_bytes) {
if (max_bytes_ == max_bytes) {
return;
}
GRPC_TRACE_LOG(http, INFO) << "Update hpack parser max size to " << max_bytes;
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) {
LOG(INFO) << "Update hpack parser max size to " << max_bytes;
}
while (mem_used_ > max_bytes) {
EvictOne();
}
@ -108,7 +111,9 @@ void HPackTable::SetMaxBytes(uint32_t max_bytes) {
bool HPackTable::SetCurrentTableSize(uint32_t bytes) {
if (current_table_bytes_ == bytes) return true;
if (bytes > max_bytes_) return false;
GRPC_TRACE_LOG(http, INFO) << "Update hpack parser table size to " << bytes;
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) {
LOG(INFO) << "Update hpack parser table size to " << bytes;
}
while (mem_used_ > bytes) {
EvictOne();
}

View File

@ -0,0 +1,19 @@
// Copyright 2022 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/core/ext/transport/chttp2/transport/http_trace.h"
#include <grpc/support/port_platform.h>
grpc_core::TraceFlag grpc_http_trace(false, "http");

View File

@ -0,0 +1,24 @@
// Copyright 2022 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP_TRACE_H
#define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP_TRACE_H
#include <grpc/support/port_platform.h>
#include "src/core/lib/debug/trace.h"
extern grpc_core::TraceFlag grpc_http_trace;
#endif // GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP_TRACE_H

View File

@ -807,12 +807,13 @@ void grpc_chttp2_settings_timeout(
#define GRPC_CHTTP2_CLIENT_CONNECT_STRLEN \
(sizeof(GRPC_CHTTP2_CLIENT_CONNECT_STRING) - 1)
//
#define GRPC_CHTTP2_IF_TRACING(stmt) \
do { \
if (GRPC_TRACE_FLAG_ENABLED(http)) { \
(stmt); \
} \
// extern grpc_core::TraceFlag grpc_flowctl_trace;
#define GRPC_CHTTP2_IF_TRACING(stmt) \
do { \
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) { \
(stmt); \
} \
} while (0)
void grpc_chttp2_fake_status(grpc_chttp2_transport* t,

View File

@ -54,6 +54,7 @@
#include "src/core/ext/transport/chttp2/transport/hpack_parser.h"
#include "src/core/ext/transport/chttp2/transport/hpack_parser_table.h"
#include "src/core/ext/transport/chttp2/transport/http2_settings.h"
#include "src/core/ext/transport/chttp2/transport/http_trace.h"
#include "src/core/ext/transport/chttp2/transport/internal.h"
#include "src/core/ext/transport/chttp2/transport/legacy_frame.h"
#include "src/core/ext/transport/chttp2/transport/max_concurrent_streams_policy.h"
@ -77,6 +78,8 @@
using grpc_core::HPackParser;
grpc_core::TraceFlag grpc_trace_chttp2_new_stream(false, "chttp2_new_stream");
static grpc_error_handle init_frame_parser(grpc_chttp2_transport* t,
size_t& requests_started);
static grpc_error_handle init_header_frame_parser(grpc_chttp2_transport* t,
@ -331,7 +334,7 @@ absl::variant<size_t, absl::Status> grpc_chttp2_perform_read(
case GRPC_DTS_FH_8:
DCHECK_LT(cur, end);
t->incoming_stream_id |= (static_cast<uint32_t>(*cur));
if (GRPC_TRACE_FLAG_ENABLED(http)) {
if (grpc_http_trace.enabled()) {
gpr_log(GPR_INFO, "INCOMING[%p]: %s len:%d id:0x%08x", t,
FrameTypeString(t->incoming_frame_type, t->incoming_frame_flags)
.c_str(),
@ -452,7 +455,7 @@ static grpc_error_handle init_frame_parser(grpc_chttp2_transport* t,
case GRPC_CHTTP2_FRAME_GOAWAY:
return init_goaway_parser(t);
default:
if (GRPC_TRACE_FLAG_ENABLED(http)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) {
gpr_log(GPR_ERROR, "Unknown frame type %02x", t->incoming_frame_type);
}
return init_non_header_skip_frame_parser(t);
@ -712,8 +715,8 @@ static grpc_error_handle init_header_frame_parser(grpc_chttp2_transport* t,
gpr_log(GPR_ERROR, "grpc_chttp2_stream not accepted"));
return init_header_skip_frame_parser(t, priority_type, is_eoh);
}
if (GRPC_TRACE_FLAG_ENABLED(http) ||
GRPC_TRACE_FLAG_ENABLED(chttp2_new_stream)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) ||
GRPC_TRACE_FLAG_ENABLED(grpc_trace_chttp2_new_stream)) {
gpr_log(GPR_INFO,
"[t:%p fd:%d peer:%s] Accepting new stream; "
"num_incoming_streams_before_settings_ack=%u",
@ -793,7 +796,7 @@ static grpc_error_handle init_window_update_frame_parser(
grpc_chttp2_stream* s = t->incoming_stream =
grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id);
if (s == nullptr) {
if (GRPC_TRACE_FLAG_ENABLED(http)) {
if (grpc_http_trace.enabled()) {
gpr_log(GPR_ERROR, "Stream %d not found, ignoring WINDOW_UPDATE",
t->incoming_stream_id);
}
@ -885,17 +888,18 @@ static grpc_error_handle parse_frame_slice(grpc_chttp2_transport* t,
const grpc_slice& slice,
int is_last) {
grpc_chttp2_stream* s = t->incoming_stream;
GRPC_TRACE_VLOG(http, 2) << "INCOMING[" << t << ";" << s << "]: Parse "
<< GRPC_SLICE_LENGTH(slice) << "b "
<< (is_last ? "last " : "") << "frame fragment with "
<< t->parser.name;
if (grpc_http_trace.enabled()) {
VLOG(2) << "INCOMING[" << t << ";" << s << "]: Parse "
<< GRPC_SLICE_LENGTH(slice) << "b " << (is_last ? "last " : "")
<< "frame fragment with " << t->parser.name;
}
grpc_error_handle err =
t->parser.parser(t->parser.user_data, t, s, slice, is_last);
intptr_t unused;
if (GPR_LIKELY(err.ok())) {
return err;
}
if (GRPC_TRACE_FLAG_ENABLED(http)) {
if (grpc_http_trace.enabled()) {
gpr_log(GPR_ERROR, "INCOMING[%p;%p]: Parse failed with %s", t, s,
err.ToString().c_str());
}

View File

@ -23,6 +23,8 @@
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
grpc_core::TraceFlag grpc_ping_trace(false, "http2_ping");
namespace grpc_core {
void Chttp2PingCallbacks::OnPing(Callback on_start, Callback on_ack) {

View File

@ -33,6 +33,8 @@
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/gprpp/time.h"
extern grpc_core::TraceFlag grpc_ping_trace;
namespace grpc_core {
class Chttp2PingCallbacks {

View File

@ -44,6 +44,8 @@ static const char* stream_list_id_string(grpc_chttp2_stream_list_id id) {
GPR_UNREACHABLE_CODE(return "unknown");
}
grpc_core::TraceFlag grpc_trace_http2_stream_state(false, "http2_stream_state");
// core list management
static bool stream_list_empty(grpc_chttp2_transport* t,
@ -68,7 +70,7 @@ static bool stream_list_pop(grpc_chttp2_transport* t,
s->included.clear(id);
}
*stream = s;
if (s && GRPC_TRACE_FLAG_ENABLED(http2_stream_state)) {
if (s && GRPC_TRACE_FLAG_ENABLED(grpc_trace_http2_stream_state)) {
gpr_log(GPR_INFO, "%p[%d][%s]: pop from %s", t, s->id,
t->is_client ? "cli" : "svr", stream_list_id_string(id));
}
@ -90,7 +92,7 @@ static void stream_list_remove(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
} else {
t->lists[id].tail = s->links[id].prev;
}
if (GRPC_TRACE_FLAG_ENABLED(http2_stream_state)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_http2_stream_state)) {
gpr_log(GPR_INFO, "%p[%d][%s]: remove from %s", t, s->id,
t->is_client ? "cli" : "svr", stream_list_id_string(id));
}
@ -122,7 +124,7 @@ static void stream_list_add_tail(grpc_chttp2_transport* t,
}
t->lists[id].tail = s;
s->included.set(id);
if (GRPC_TRACE_FLAG_ENABLED(http2_stream_state)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_http2_stream_state)) {
gpr_log(GPR_INFO, "%p[%d][%s]: add to %s", t, s->id,
t->is_client ? "cli" : "svr", stream_list_id_string(id));
}

View File

@ -47,6 +47,7 @@
#include "src/core/ext/transport/chttp2/transport/frame_window_update.h"
#include "src/core/ext/transport/chttp2/transport/hpack_encoder.h"
#include "src/core/ext/transport/chttp2/transport/http2_settings.h"
#include "src/core/ext/transport/chttp2/transport/http_trace.h"
#include "src/core/ext/transport/chttp2/transport/internal.h"
#include "src/core/ext/transport/chttp2/transport/legacy_frame.h"
#include "src/core/ext/transport/chttp2/transport/max_concurrent_streams_policy.h"
@ -132,10 +133,10 @@ static void maybe_initiate_ping(grpc_chttp2_transport* t) {
t->channelz_socket->RecordKeepaliveSent();
}
grpc_core::global_stats().IncrementHttp2PingsSent();
if (GRPC_TRACE_FLAG_ENABLED(http) ||
GRPC_TRACE_FLAG_ENABLED(bdp_estimator) ||
GRPC_TRACE_FLAG_ENABLED(http_keepalive) ||
GRPC_TRACE_FLAG_ENABLED(http2_ping)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) ||
GRPC_TRACE_FLAG_ENABLED(grpc_bdp_estimator_trace) ||
GRPC_TRACE_FLAG_ENABLED(grpc_keepalive_trace) ||
GRPC_TRACE_FLAG_ENABLED(grpc_ping_trace)) {
gpr_log(GPR_INFO, "%s[%p]: Ping %" PRIx64 " sent [%s]: %s",
t->is_client ? "CLIENT" : "SERVER", t, id,
std::string(t->peer_string.as_string_view()).c_str(),
@ -144,10 +145,10 @@ static void maybe_initiate_ping(grpc_chttp2_transport* t) {
},
[t](grpc_core::Chttp2PingRatePolicy::TooManyRecentPings) {
// need to receive something of substance before sending a ping again
if (GRPC_TRACE_FLAG_ENABLED(http) ||
GRPC_TRACE_FLAG_ENABLED(bdp_estimator) ||
GRPC_TRACE_FLAG_ENABLED(http_keepalive) ||
GRPC_TRACE_FLAG_ENABLED(http2_ping)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) ||
GRPC_TRACE_FLAG_ENABLED(grpc_bdp_estimator_trace) ||
GRPC_TRACE_FLAG_ENABLED(grpc_keepalive_trace) ||
GRPC_TRACE_FLAG_ENABLED(grpc_ping_trace)) {
gpr_log(GPR_INFO,
"%s[%p]: Ping delayed [%s]: too many recent pings: %s",
t->is_client ? "CLIENT" : "SERVER", t,
@ -157,10 +158,10 @@ static void maybe_initiate_ping(grpc_chttp2_transport* t) {
},
[t](grpc_core::Chttp2PingRatePolicy::TooSoon too_soon) {
// not enough elapsed time between successive pings
if (GRPC_TRACE_FLAG_ENABLED(http) ||
GRPC_TRACE_FLAG_ENABLED(bdp_estimator) ||
GRPC_TRACE_FLAG_ENABLED(http_keepalive) ||
GRPC_TRACE_FLAG_ENABLED(http2_ping)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) ||
GRPC_TRACE_FLAG_ENABLED(grpc_bdp_estimator_trace) ||
GRPC_TRACE_FLAG_ENABLED(grpc_keepalive_trace) ||
GRPC_TRACE_FLAG_ENABLED(grpc_ping_trace)) {
gpr_log(
GPR_INFO,
"%s[%p]: Ping delayed [%s]: not enough time elapsed since last "
@ -206,7 +207,7 @@ static bool update_list(grpc_chttp2_transport* t, int64_t send_bytes,
static void report_stall(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
const char* staller) {
if (GRPC_TRACE_FLAG_ENABLED(flowctl)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_flowctl_trace)) {
gpr_log(
GPR_DEBUG,
"%s:%p stream %d moved to stalled list by %s. This is FULLY expected "
@ -727,7 +728,7 @@ void grpc_chttp2_end_write(grpc_chttp2_transport* t, grpc_error_handle error) {
grpc_core::ExecCtx exec_ctx;
grpc_chttp2_ping_timeout(t);
});
if (GRPC_TRACE_FLAG_ENABLED(http2_ping) && id.has_value()) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_ping_trace) && id.has_value()) {
gpr_log(GPR_INFO,
"%s[%p]: Set ping timeout timer of %s for ping id %" PRIx64,
t->is_client ? "CLIENT" : "SERVER", t, timeout.ToString().c_str(),
@ -739,8 +740,8 @@ void grpc_chttp2_end_write(grpc_chttp2_transport* t, grpc_error_handle error) {
t->keepalive_ping_timeout_handle !=
grpc_event_engine::experimental::EventEngine::TaskHandle::
kInvalid) {
if (GRPC_TRACE_FLAG_ENABLED(http2_ping) ||
GRPC_TRACE_FLAG_ENABLED(http_keepalive)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_ping_trace) ||
GRPC_TRACE_FLAG_ENABLED(grpc_keepalive_trace)) {
gpr_log(GPR_INFO, "%s[%p]: Set keepalive ping timeout timer of %s",
t->is_client ? "CLIENT" : "SERVER", t,
t->keepalive_timeout.ToString().c_str());

View File

@ -67,9 +67,10 @@
#define GRPC_HEADER_SIZE_IN_BYTES 5
#define GRPC_FLUSH_READ_SIZE 4096
#define CRONET_LOG(...) \
do { \
if (GRPC_TRACE_FLAG_ENABLED(cronet)) gpr_log(__VA_ARGS__); \
grpc_core::TraceFlag grpc_cronet_trace(false, "cronet");
#define CRONET_LOG(...) \
do { \
if (grpc_cronet_trace.enabled()) gpr_log(__VA_ARGS__); \
} while (0)
enum e_op_result {

View File

@ -0,0 +1,23 @@
//
//
// Copyright 2017 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
#include <grpc/support/port_platform.h>
#include "src/core/lib/debug/trace.h"
grpc_core::TraceFlag grpc_inproc_trace(false, "inproc");

View File

@ -25,6 +25,8 @@ grpc_channel* grpc_inproc_channel_create(grpc_server* server,
const grpc_channel_args* args,
void* reserved);
extern grpc_core::TraceFlag grpc_inproc_trace;
namespace grpc_core {
std::pair<OrphanablePtr<Transport>, OrphanablePtr<Transport>>

View File

@ -69,11 +69,11 @@
#include "src/core/lib/transport/transport.h"
#include "src/core/server/server.h"
#define INPROC_LOG(...) \
do { \
if (GRPC_TRACE_FLAG_ENABLED(inproc)) { \
gpr_log(__VA_ARGS__); \
} \
#define INPROC_LOG(...) \
do { \
if (GRPC_TRACE_FLAG_ENABLED(grpc_inproc_trace)) { \
gpr_log(__VA_ARGS__); \
} \
} while (0)
namespace {
@ -352,7 +352,7 @@ class CopySink {
void fill_in_metadata(inproc_stream* s, const grpc_metadata_batch* metadata,
grpc_metadata_batch* out_md, bool* markfilled) {
if (GRPC_TRACE_FLAG_ENABLED(inproc)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_inproc_trace)) {
log_metadata(metadata, s->t->is_client,
metadata->get_pointer(grpc_core::WaitForReady()) != nullptr);
}
@ -949,7 +949,7 @@ void inproc_transport::PerformStreamOp(grpc_stream* gs,
gpr_mu* mu = &s->t->mu->mu; // save aside in case s gets closed
gpr_mu_lock(mu);
if (GRPC_TRACE_FLAG_ENABLED(inproc)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_inproc_trace)) {
if (op->send_initial_metadata) {
log_metadata(op->payload->send_initial_metadata.send_initial_metadata,
s->t->is_client, true);

View File

@ -24,4 +24,6 @@ grpc_channel* grpc_legacy_inproc_channel_create(grpc_server* server,
const grpc_channel_args* args,
void* reserved);
extern grpc_core::TraceFlag grpc_inproc_trace;
#endif // GRPC_SRC_CORE_EXT_TRANSPORT_INPROC_LEGACY_INPROC_TRANSPORT_H

View File

@ -43,6 +43,8 @@
namespace grpc_core {
TraceFlag grpc_handshaker_trace(false, "handshaker");
namespace {
using ::grpc_event_engine::experimental::EventEngine;
@ -60,12 +62,13 @@ std::string HandshakerArgsString(HandshakerArgs* args) {
} // namespace
HandshakeManager::HandshakeManager()
: RefCounted(GRPC_TRACE_FLAG_ENABLED(handshaker) ? "HandshakeManager"
: nullptr) {}
: RefCounted(GRPC_TRACE_FLAG_ENABLED(grpc_handshaker_trace)
? "HandshakeManager"
: nullptr) {}
void HandshakeManager::Add(RefCountedPtr<Handshaker> handshaker) {
MutexLock lock(&mu_);
if (GRPC_TRACE_FLAG_ENABLED(handshaker)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_handshaker_trace)) {
gpr_log(
GPR_INFO,
"handshake_manager %p: adding handshaker %s [%p] at index %" PRIuPTR,
@ -91,7 +94,7 @@ void HandshakeManager::Shutdown(grpc_error_handle why) {
// on_handshake_done callback.
// Returns true if we've scheduled the on_handshake_done callback.
bool HandshakeManager::CallNextHandshakerLocked(grpc_error_handle error) {
if (GRPC_TRACE_FLAG_ENABLED(handshaker)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_handshaker_trace)) {
gpr_log(GPR_INFO,
"handshake_manager %p: error=%s shutdown=%d index=%" PRIuPTR
", args=%s",
@ -120,7 +123,7 @@ bool HandshakeManager::CallNextHandshakerLocked(grpc_error_handle error) {
}
args_.args = ChannelArgs();
}
if (GRPC_TRACE_FLAG_ENABLED(handshaker)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_handshaker_trace)) {
gpr_log(GPR_INFO,
"handshake_manager %p: handshaking complete -- scheduling "
"on_handshake_done with error=%s",
@ -133,7 +136,7 @@ bool HandshakeManager::CallNextHandshakerLocked(grpc_error_handle error) {
is_shutdown_ = true;
} else {
auto handshaker = handshakers_[index_];
if (GRPC_TRACE_FLAG_ENABLED(handshaker)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_handshaker_trace)) {
gpr_log(
GPR_INFO,
"handshake_manager %p: calling handshaker %s [%p] at index %" PRIuPTR,

View File

@ -26,7 +26,6 @@
#include "absl/base/thread_annotations.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
@ -52,6 +51,7 @@
#include "src/core/lib/resource_quota/api.h"
#include "src/core/lib/resource_quota/memory_quota.h"
#include "src/core/lib/resource_quota/resource_quota.h"
#include "src/core/lib/resource_quota/trace.h"
#include "src/core/lib/slice/slice.h"
#include "src/core/lib/slice/slice_string_helpers.h"
#include "src/core/tsi/transport_security_grpc.h"
@ -146,6 +146,8 @@ struct secure_endpoint {
};
} // namespace
grpc_core::TraceFlag grpc_trace_secure_endpoint(false, "secure_endpoint");
static void destroy(secure_endpoint* ep) { delete ep; }
#ifndef NDEBUG
@ -155,7 +157,7 @@ static void destroy(secure_endpoint* ep) { delete ep; }
secure_endpoint_ref((ep), (reason), __FILE__, __LINE__)
static void secure_endpoint_unref(secure_endpoint* ep, const char* reason,
const char* file, int line) {
if (GRPC_TRACE_FLAG_ENABLED(secure_endpoint)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_secure_endpoint)) {
gpr_atm val = gpr_atm_no_barrier_load(&ep->ref.count);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
"SECENDP unref %p : %s %" PRIdPTR " -> %" PRIdPTR, ep, reason, val,
@ -168,7 +170,7 @@ static void secure_endpoint_unref(secure_endpoint* ep, const char* reason,
static void secure_endpoint_ref(secure_endpoint* ep, const char* reason,
const char* file, int line) {
if (GRPC_TRACE_FLAG_ENABLED(secure_endpoint)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_secure_endpoint)) {
gpr_atm val = gpr_atm_no_barrier_load(&ep->ref.count);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
"SECENDP ref %p : %s %" PRIdPTR " -> %" PRIdPTR, ep, reason, val,
@ -196,7 +198,7 @@ static void maybe_post_reclaimer(secure_endpoint* ep) {
grpc_core::ReclamationPass::kBenign,
[ep](absl::optional<grpc_core::ReclamationSweep> sweep) {
if (sweep.has_value()) {
if (GRPC_TRACE_FLAG_ENABLED(resource_quota)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_resource_quota_trace)) {
gpr_log(GPR_INFO,
"secure endpoint: benign reclamation to free memory");
}
@ -233,12 +235,13 @@ static void flush_read_staging_buffer(secure_endpoint* ep, uint8_t** cur,
}
static void call_read_cb(secure_endpoint* ep, grpc_error_handle error) {
if (GRPC_TRACE_FLAG_ENABLED(secure_endpoint) && ABSL_VLOG_IS_ON(2)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_secure_endpoint) &&
gpr_should_log(GPR_LOG_SEVERITY_INFO)) {
size_t i;
for (i = 0; i < ep->read_buffer->count; i++) {
char* data = grpc_dump_slice(ep->read_buffer->slices[i],
GPR_DUMP_HEX | GPR_DUMP_ASCII);
VLOG(2) << "READ " << ep << ": " << data;
gpr_log(GPR_INFO, "READ %p: %s", ep, data);
gpr_free(data);
}
}
@ -400,11 +403,12 @@ static void endpoint_write(grpc_endpoint* secure_ep, grpc_slice_buffer* slices,
grpc_slice_buffer_reset_and_unref(&ep->output_buffer);
if (GRPC_TRACE_FLAG_ENABLED(secure_endpoint) && ABSL_VLOG_IS_ON(2)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_secure_endpoint) &&
gpr_should_log(GPR_LOG_SEVERITY_INFO)) {
for (i = 0; i < slices->count; i++) {
char* data =
grpc_dump_slice(slices->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII);
VLOG(2) << "WRITE " << ep << ": " << data;
gpr_log(GPR_INFO, "WRITE %p: %s", ep, data);
gpr_free(data);
}
}

View File

@ -28,6 +28,8 @@
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/iomgr/endpoint.h"
extern grpc_core::TraceFlag grpc_trace_secure_endpoint;
// Takes ownership of protector, zero_copy_protector, and to_wrap, and refs
// leftover_slices. If zero_copy_protector is not NULL, protector will never be
// used.

Some files were not shown because too many files have changed in this diff Show More