aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--BUILD8
-rw-r--r--CMakeLists.txt80
-rw-r--r--Makefile114
-rw-r--r--build.yaml35
-rw-r--r--config.m44
-rw-r--r--config.w324
-rw-r--r--gRPC-C++.podspec7
-rw-r--r--gRPC-Core.podspec12
-rw-r--r--grpc.def2
-rw-r--r--grpc.gemspec8
-rw-r--r--grpc.gyp18
-rw-r--r--include/grpc/grpc.h8
-rw-r--r--include/grpc/impl/codegen/grpc_types.h4
-rw-r--r--package.xml8
-rw-r--r--src/core/ext/filters/client_channel/client_channel.cc2
-rw-r--r--src/core/ext/filters/client_channel/method_params.cc2
-rw-r--r--src/core/ext/filters/client_channel/method_params.h2
-rw-r--r--src/core/ext/filters/client_channel/subchannel.cc1
-rw-r--r--src/core/lib/channel/channel_trace.cc239
-rw-r--r--src/core/lib/channel/channel_trace.h133
-rw-r--r--src/core/lib/channel/channel_trace_registry.cc80
-rw-r--r--src/core/lib/channel/channel_trace_registry.h43
-rw-r--r--src/core/lib/channel/status_util.cc (renamed from src/core/ext/filters/client_channel/status_util.cc)2
-rw-r--r--src/core/lib/channel/status_util.h (renamed from src/core/ext/filters/client_channel/status_util.h)6
-rw-r--r--src/core/lib/json/json.cc36
-rw-r--r--src/core/lib/json/json.h21
-rw-r--r--src/core/lib/surface/channel.cc33
-rw-r--r--src/core/lib/surface/init.cc3
-rw-r--r--src/proto/grpc/channelz/BUILD26
-rw-r--r--src/proto/grpc/channelz/channelz.proto456
-rw-r--r--src/python/grpcio/grpc_core_dependencies.py4
-rw-r--r--src/ruby/ext/grpc/rb_grpc_imports.generated.c4
-rw-r--r--src/ruby/ext/grpc/rb_grpc_imports.generated.h6
-rw-r--r--test/core/channel/BUILD29
-rw-r--r--test/core/channel/channel_trace_test.cc240
-rw-r--r--test/core/channel/status_util_test.cc (renamed from test/core/client_channel/status_util_test.cc)2
-rw-r--r--test/core/client_channel/BUILD12
-rw-r--r--test/core/surface/public_headers_must_be_c89.c2
-rw-r--r--test/cpp/util/BUILD19
-rw-r--r--test/cpp/util/channel_trace_proto_helper.cc56
-rw-r--r--test/cpp/util/channel_trace_proto_helper.h30
-rw-r--r--tools/doxygen/Doxyfile.c++.internal3
-rw-r--r--tools/doxygen/Doxyfile.core.internal8
-rw-r--r--tools/run_tests/generated/sources_and_headers.json55
-rw-r--r--tools/run_tests/generated/tests.json24
45 files changed, 1820 insertions, 71 deletions
diff --git a/BUILD b/BUILD
index 6e479fb0d4..c12337ecac 100644
--- a/BUILD
+++ b/BUILD
@@ -680,6 +680,9 @@ grpc_cc_library(
"src/core/lib/channel/channel_args.cc",
"src/core/lib/channel/channel_stack.cc",
"src/core/lib/channel/channel_stack_builder.cc",
+ "src/core/lib/channel/channel_trace.cc",
+ "src/core/lib/channel/channel_trace_registry.cc",
+ "src/core/lib/channel/status_util.cc",
"src/core/lib/channel/connected_channel.cc",
"src/core/lib/channel/handshaker.cc",
"src/core/lib/channel/handshaker_factory.cc",
@@ -824,6 +827,9 @@ grpc_cc_library(
"src/core/lib/channel/channel_args.h",
"src/core/lib/channel/channel_stack.h",
"src/core/lib/channel/channel_stack_builder.h",
+ "src/core/lib/channel/channel_trace.h",
+ "src/core/lib/channel/channel_trace_registry.h",
+ "src/core/lib/channel/status_util.h",
"src/core/lib/channel/connected_channel.h",
"src/core/lib/channel/context.h",
"src/core/lib/channel/handshaker.h",
@@ -1020,7 +1026,6 @@ grpc_cc_library(
"src/core/ext/filters/client_channel/resolver.cc",
"src/core/ext/filters/client_channel/resolver_registry.cc",
"src/core/ext/filters/client_channel/retry_throttle.cc",
- "src/core/ext/filters/client_channel/status_util.cc",
"src/core/ext/filters/client_channel/subchannel.cc",
"src/core/ext/filters/client_channel/subchannel_index.cc",
"src/core/ext/filters/client_channel/uri_parser.cc",
@@ -1043,7 +1048,6 @@ grpc_cc_library(
"src/core/ext/filters/client_channel/resolver_factory.h",
"src/core/ext/filters/client_channel/resolver_registry.h",
"src/core/ext/filters/client_channel/retry_throttle.h",
- "src/core/ext/filters/client_channel/status_util.h",
"src/core/ext/filters/client_channel/subchannel.h",
"src/core/ext/filters/client_channel/subchannel_index.h",
"src/core/ext/filters/client_channel/uri_parser.h",
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7a9f1447a0..ad8548ebfd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -532,6 +532,7 @@ endif()
add_dependencies(buildtests_cxx byte_stream_test)
add_dependencies(buildtests_cxx channel_arguments_test)
add_dependencies(buildtests_cxx channel_filter_test)
+add_dependencies(buildtests_cxx channel_trace_test)
add_dependencies(buildtests_cxx check_gcp_environment_linux_test)
add_dependencies(buildtests_cxx check_gcp_environment_windows_test)
add_dependencies(buildtests_cxx chttp2_settings_timeout_test)
@@ -856,10 +857,13 @@ add_library(grpc
src/core/lib/channel/channel_args.cc
src/core/lib/channel/channel_stack.cc
src/core/lib/channel/channel_stack_builder.cc
+ src/core/lib/channel/channel_trace.cc
+ src/core/lib/channel/channel_trace_registry.cc
src/core/lib/channel/connected_channel.cc
src/core/lib/channel/handshaker.cc
src/core/lib/channel/handshaker_factory.cc
src/core/lib/channel/handshaker_registry.cc
+ src/core/lib/channel/status_util.cc
src/core/lib/compression/compression.cc
src/core/lib/compression/compression_internal.cc
src/core/lib/compression/message_compress.cc
@@ -1108,7 +1112,6 @@ add_library(grpc
src/core/ext/filters/client_channel/resolver.cc
src/core/ext/filters/client_channel/resolver_registry.cc
src/core/ext/filters/client_channel/retry_throttle.cc
- src/core/ext/filters/client_channel/status_util.cc
src/core/ext/filters/client_channel/subchannel.cc
src/core/ext/filters/client_channel/subchannel_index.cc
src/core/ext/filters/client_channel/uri_parser.cc
@@ -1245,10 +1248,13 @@ add_library(grpc_cronet
src/core/lib/channel/channel_args.cc
src/core/lib/channel/channel_stack.cc
src/core/lib/channel/channel_stack_builder.cc
+ src/core/lib/channel/channel_trace.cc
+ src/core/lib/channel/channel_trace_registry.cc
src/core/lib/channel/connected_channel.cc
src/core/lib/channel/handshaker.cc
src/core/lib/channel/handshaker_factory.cc
src/core/lib/channel/handshaker_registry.cc
+ src/core/lib/channel/status_util.cc
src/core/lib/compression/compression.cc
src/core/lib/compression/compression_internal.cc
src/core/lib/compression/message_compress.cc
@@ -1439,7 +1445,6 @@ add_library(grpc_cronet
src/core/ext/filters/client_channel/resolver.cc
src/core/ext/filters/client_channel/resolver_registry.cc
src/core/ext/filters/client_channel/retry_throttle.cc
- src/core/ext/filters/client_channel/status_util.cc
src/core/ext/filters/client_channel/subchannel.cc
src/core/ext/filters/client_channel/subchannel_index.cc
src/core/ext/filters/client_channel/uri_parser.cc
@@ -1639,10 +1644,13 @@ add_library(grpc_test_util
src/core/lib/channel/channel_args.cc
src/core/lib/channel/channel_stack.cc
src/core/lib/channel/channel_stack_builder.cc
+ src/core/lib/channel/channel_trace.cc
+ src/core/lib/channel/channel_trace_registry.cc
src/core/lib/channel/connected_channel.cc
src/core/lib/channel/handshaker.cc
src/core/lib/channel/handshaker_factory.cc
src/core/lib/channel/handshaker_registry.cc
+ src/core/lib/channel/status_util.cc
src/core/lib/compression/compression.cc
src/core/lib/compression/compression_internal.cc
src/core/lib/compression/message_compress.cc
@@ -1798,7 +1806,6 @@ add_library(grpc_test_util
src/core/ext/filters/client_channel/resolver.cc
src/core/ext/filters/client_channel/resolver_registry.cc
src/core/ext/filters/client_channel/retry_throttle.cc
- src/core/ext/filters/client_channel/status_util.cc
src/core/ext/filters/client_channel/subchannel.cc
src/core/ext/filters/client_channel/subchannel_index.cc
src/core/ext/filters/client_channel/uri_parser.cc
@@ -1939,10 +1946,13 @@ add_library(grpc_test_util_unsecure
src/core/lib/channel/channel_args.cc
src/core/lib/channel/channel_stack.cc
src/core/lib/channel/channel_stack_builder.cc
+ src/core/lib/channel/channel_trace.cc
+ src/core/lib/channel/channel_trace_registry.cc
src/core/lib/channel/connected_channel.cc
src/core/lib/channel/handshaker.cc
src/core/lib/channel/handshaker_factory.cc
src/core/lib/channel/handshaker_registry.cc
+ src/core/lib/channel/status_util.cc
src/core/lib/compression/compression.cc
src/core/lib/compression/compression_internal.cc
src/core/lib/compression/message_compress.cc
@@ -2098,7 +2108,6 @@ add_library(grpc_test_util_unsecure
src/core/ext/filters/client_channel/resolver.cc
src/core/ext/filters/client_channel/resolver_registry.cc
src/core/ext/filters/client_channel/retry_throttle.cc
- src/core/ext/filters/client_channel/status_util.cc
src/core/ext/filters/client_channel/subchannel.cc
src/core/ext/filters/client_channel/subchannel_index.cc
src/core/ext/filters/client_channel/uri_parser.cc
@@ -2219,10 +2228,13 @@ add_library(grpc_unsecure
src/core/lib/channel/channel_args.cc
src/core/lib/channel/channel_stack.cc
src/core/lib/channel/channel_stack_builder.cc
+ src/core/lib/channel/channel_trace.cc
+ src/core/lib/channel/channel_trace_registry.cc
src/core/lib/channel/connected_channel.cc
src/core/lib/channel/handshaker.cc
src/core/lib/channel/handshaker_factory.cc
src/core/lib/channel/handshaker_registry.cc
+ src/core/lib/channel/status_util.cc
src/core/lib/compression/compression.cc
src/core/lib/compression/compression_internal.cc
src/core/lib/compression/message_compress.cc
@@ -2411,7 +2423,6 @@ add_library(grpc_unsecure
src/core/ext/filters/client_channel/resolver.cc
src/core/ext/filters/client_channel/resolver_registry.cc
src/core/ext/filters/client_channel/retry_throttle.cc
- src/core/ext/filters/client_channel/status_util.cc
src/core/ext/filters/client_channel/subchannel.cc
src/core/ext/filters/client_channel/subchannel_index.cc
src/core/ext/filters/client_channel/uri_parser.cc
@@ -3033,10 +3044,13 @@ add_library(grpc++_cronet
src/core/lib/channel/channel_args.cc
src/core/lib/channel/channel_stack.cc
src/core/lib/channel/channel_stack_builder.cc
+ src/core/lib/channel/channel_trace.cc
+ src/core/lib/channel/channel_trace_registry.cc
src/core/lib/channel/connected_channel.cc
src/core/lib/channel/handshaker.cc
src/core/lib/channel/handshaker_factory.cc
src/core/lib/channel/handshaker_registry.cc
+ src/core/lib/channel/status_util.cc
src/core/lib/compression/compression.cc
src/core/lib/compression/compression_internal.cc
src/core/lib/compression/message_compress.cc
@@ -3197,7 +3211,6 @@ add_library(grpc++_cronet
src/core/ext/filters/client_channel/resolver.cc
src/core/ext/filters/client_channel/resolver_registry.cc
src/core/ext/filters/client_channel/retry_throttle.cc
- src/core/ext/filters/client_channel/status_util.cc
src/core/ext/filters/client_channel/subchannel.cc
src/core/ext/filters/client_channel/subchannel_index.cc
src/core/ext/filters/client_channel/uri_parser.cc
@@ -3702,6 +3715,10 @@ if (gRPC_BUILD_TESTS)
if (gRPC_BUILD_CODEGEN)
add_library(grpc++_test_util
+ ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.cc
+ ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.cc
+ ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.h
+ ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.h
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/health/v1/health.pb.cc
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/health/v1/health.grpc.pb.cc
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/health/v1/health.pb.h
@@ -3721,6 +3738,7 @@ add_library(grpc++_test_util
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h
test/cpp/end2end/test_service_impl.cc
test/cpp/util/byte_buffer_proto_helper.cc
+ test/cpp/util/channel_trace_proto_helper.cc
test/cpp/util/create_test_channel.cc
test/cpp/util/string_ref_helper.cc
test/cpp/util/subprocess.cc
@@ -3740,6 +3758,9 @@ if(WIN32 AND MSVC)
endif()
protobuf_generate_grpc_cpp(
+ src/proto/grpc/channelz/channelz.proto
+)
+protobuf_generate_grpc_cpp(
src/proto/grpc/health/v1/health.proto
)
protobuf_generate_grpc_cpp(
@@ -10149,6 +10170,51 @@ target_link_libraries(channel_filter_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
+add_executable(channel_trace_test
+ test/core/channel/channel_trace_test.cc
+ ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.cc
+ ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.cc
+ ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.h
+ ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.h
+ third_party/googletest/googletest/src/gtest-all.cc
+ third_party/googletest/googlemock/src/gmock-all.cc
+)
+
+protobuf_generate_grpc_cpp(
+ src/proto/grpc/channelz/channelz.proto
+)
+
+target_include_directories(channel_trace_test
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
+ PRIVATE third_party/googletest/googletest/include
+ PRIVATE third_party/googletest/googletest
+ PRIVATE third_party/googletest/googlemock/include
+ PRIVATE third_party/googletest/googlemock
+ PRIVATE ${_gRPC_PROTO_GENS_DIR}
+)
+
+target_link_libraries(channel_trace_test
+ ${_gRPC_PROTOBUF_LIBRARIES}
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+ grpc_test_util
+ grpc++_test_util
+ grpc++
+ grpc
+ gpr_test_util
+ gpr
+ ${_gRPC_GFLAGS_LIBRARIES}
+)
+
+endif (gRPC_BUILD_TESTS)
+if (gRPC_BUILD_TESTS)
+
add_executable(check_gcp_environment_linux_test
test/core/security/check_gcp_environment_linux_test.cc
third_party/googletest/googletest/src/gtest-all.cc
@@ -13131,7 +13197,7 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(status_util_test
- test/core/client_channel/status_util_test.cc
+ test/core/channel/status_util_test.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
diff --git a/Makefile b/Makefile
index ae0d3e2a4f..134c524eb9 100644
--- a/Makefile
+++ b/Makefile
@@ -1129,6 +1129,7 @@ bm_pollset: $(BINDIR)/$(CONFIG)/bm_pollset
byte_stream_test: $(BINDIR)/$(CONFIG)/byte_stream_test
channel_arguments_test: $(BINDIR)/$(CONFIG)/channel_arguments_test
channel_filter_test: $(BINDIR)/$(CONFIG)/channel_filter_test
+channel_trace_test: $(BINDIR)/$(CONFIG)/channel_trace_test
check_gcp_environment_linux_test: $(BINDIR)/$(CONFIG)/check_gcp_environment_linux_test
check_gcp_environment_windows_test: $(BINDIR)/$(CONFIG)/check_gcp_environment_windows_test
chttp2_settings_timeout_test: $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test
@@ -1615,6 +1616,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/byte_stream_test \
$(BINDIR)/$(CONFIG)/channel_arguments_test \
$(BINDIR)/$(CONFIG)/channel_filter_test \
+ $(BINDIR)/$(CONFIG)/channel_trace_test \
$(BINDIR)/$(CONFIG)/check_gcp_environment_linux_test \
$(BINDIR)/$(CONFIG)/check_gcp_environment_windows_test \
$(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test \
@@ -1782,6 +1784,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/byte_stream_test \
$(BINDIR)/$(CONFIG)/channel_arguments_test \
$(BINDIR)/$(CONFIG)/channel_filter_test \
+ $(BINDIR)/$(CONFIG)/channel_trace_test \
$(BINDIR)/$(CONFIG)/check_gcp_environment_linux_test \
$(BINDIR)/$(CONFIG)/check_gcp_environment_windows_test \
$(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test \
@@ -2208,6 +2211,8 @@ test_cxx: buildtests_cxx
$(Q) $(BINDIR)/$(CONFIG)/channel_arguments_test || ( echo test channel_arguments_test failed ; exit 1 )
$(E) "[RUN] Testing channel_filter_test"
$(Q) $(BINDIR)/$(CONFIG)/channel_filter_test || ( echo test channel_filter_test failed ; exit 1 )
+ $(E) "[RUN] Testing channel_trace_test"
+ $(Q) $(BINDIR)/$(CONFIG)/channel_trace_test || ( echo test channel_trace_test failed ; exit 1 )
$(E) "[RUN] Testing check_gcp_environment_linux_test"
$(Q) $(BINDIR)/$(CONFIG)/check_gcp_environment_linux_test || ( echo test check_gcp_environment_linux_test failed ; exit 1 )
$(E) "[RUN] Testing check_gcp_environment_windows_test"
@@ -2449,6 +2454,22 @@ $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc:
$(Q) echo "$(GRPCXX_UNSECURE_PC_FILE)" | tr , '\n' >$@
ifeq ($(NO_PROTOC),true)
+$(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc: protoc_dep_error
+$(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc: protoc_dep_error
+else
+
+$(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc: src/proto/grpc/channelz/channelz.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
+ $(E) "[PROTOC] Generating protobuf CC file from $<"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --cpp_out=$(GENDIR) $<
+
+$(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc: src/proto/grpc/channelz/channelz.proto $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
+ $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(PROTOC_PLUGINS_DIR)/grpc_cpp_plugin$(EXECUTABLE_SUFFIX) $<
+endif
+
+ifeq ($(NO_PROTOC),true)
$(GENDIR)/src/proto/grpc/core/stats.pb.cc: protoc_dep_error
$(GENDIR)/src/proto/grpc/core/stats.grpc.pb.cc: protoc_dep_error
else
@@ -3165,10 +3186,13 @@ LIBGRPC_SRC = \
src/core/lib/channel/channel_args.cc \
src/core/lib/channel/channel_stack.cc \
src/core/lib/channel/channel_stack_builder.cc \
+ src/core/lib/channel/channel_trace.cc \
+ src/core/lib/channel/channel_trace_registry.cc \
src/core/lib/channel/connected_channel.cc \
src/core/lib/channel/handshaker.cc \
src/core/lib/channel/handshaker_factory.cc \
src/core/lib/channel/handshaker_registry.cc \
+ src/core/lib/channel/status_util.cc \
src/core/lib/compression/compression.cc \
src/core/lib/compression/compression_internal.cc \
src/core/lib/compression/message_compress.cc \
@@ -3417,7 +3441,6 @@ LIBGRPC_SRC = \
src/core/ext/filters/client_channel/resolver.cc \
src/core/ext/filters/client_channel/resolver_registry.cc \
src/core/ext/filters/client_channel/retry_throttle.cc \
- src/core/ext/filters/client_channel/status_util.cc \
src/core/ext/filters/client_channel/subchannel.cc \
src/core/ext/filters/client_channel/subchannel_index.cc \
src/core/ext/filters/client_channel/uri_parser.cc \
@@ -3556,10 +3579,13 @@ LIBGRPC_CRONET_SRC = \
src/core/lib/channel/channel_args.cc \
src/core/lib/channel/channel_stack.cc \
src/core/lib/channel/channel_stack_builder.cc \
+ src/core/lib/channel/channel_trace.cc \
+ src/core/lib/channel/channel_trace_registry.cc \
src/core/lib/channel/connected_channel.cc \
src/core/lib/channel/handshaker.cc \
src/core/lib/channel/handshaker_factory.cc \
src/core/lib/channel/handshaker_registry.cc \
+ src/core/lib/channel/status_util.cc \
src/core/lib/compression/compression.cc \
src/core/lib/compression/compression_internal.cc \
src/core/lib/compression/message_compress.cc \
@@ -3750,7 +3776,6 @@ LIBGRPC_CRONET_SRC = \
src/core/ext/filters/client_channel/resolver.cc \
src/core/ext/filters/client_channel/resolver_registry.cc \
src/core/ext/filters/client_channel/retry_throttle.cc \
- src/core/ext/filters/client_channel/status_util.cc \
src/core/ext/filters/client_channel/subchannel.cc \
src/core/ext/filters/client_channel/subchannel_index.cc \
src/core/ext/filters/client_channel/uri_parser.cc \
@@ -3951,10 +3976,13 @@ LIBGRPC_TEST_UTIL_SRC = \
src/core/lib/channel/channel_args.cc \
src/core/lib/channel/channel_stack.cc \
src/core/lib/channel/channel_stack_builder.cc \
+ src/core/lib/channel/channel_trace.cc \
+ src/core/lib/channel/channel_trace_registry.cc \
src/core/lib/channel/connected_channel.cc \
src/core/lib/channel/handshaker.cc \
src/core/lib/channel/handshaker_factory.cc \
src/core/lib/channel/handshaker_registry.cc \
+ src/core/lib/channel/status_util.cc \
src/core/lib/compression/compression.cc \
src/core/lib/compression/compression_internal.cc \
src/core/lib/compression/message_compress.cc \
@@ -4110,7 +4138,6 @@ LIBGRPC_TEST_UTIL_SRC = \
src/core/ext/filters/client_channel/resolver.cc \
src/core/ext/filters/client_channel/resolver_registry.cc \
src/core/ext/filters/client_channel/retry_throttle.cc \
- src/core/ext/filters/client_channel/status_util.cc \
src/core/ext/filters/client_channel/subchannel.cc \
src/core/ext/filters/client_channel/subchannel_index.cc \
src/core/ext/filters/client_channel/uri_parser.cc \
@@ -4244,10 +4271,13 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \
src/core/lib/channel/channel_args.cc \
src/core/lib/channel/channel_stack.cc \
src/core/lib/channel/channel_stack_builder.cc \
+ src/core/lib/channel/channel_trace.cc \
+ src/core/lib/channel/channel_trace_registry.cc \
src/core/lib/channel/connected_channel.cc \
src/core/lib/channel/handshaker.cc \
src/core/lib/channel/handshaker_factory.cc \
src/core/lib/channel/handshaker_registry.cc \
+ src/core/lib/channel/status_util.cc \
src/core/lib/compression/compression.cc \
src/core/lib/compression/compression_internal.cc \
src/core/lib/compression/message_compress.cc \
@@ -4403,7 +4433,6 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \
src/core/ext/filters/client_channel/resolver.cc \
src/core/ext/filters/client_channel/resolver_registry.cc \
src/core/ext/filters/client_channel/retry_throttle.cc \
- src/core/ext/filters/client_channel/status_util.cc \
src/core/ext/filters/client_channel/subchannel.cc \
src/core/ext/filters/client_channel/subchannel_index.cc \
src/core/ext/filters/client_channel/uri_parser.cc \
@@ -4504,10 +4533,13 @@ LIBGRPC_UNSECURE_SRC = \
src/core/lib/channel/channel_args.cc \
src/core/lib/channel/channel_stack.cc \
src/core/lib/channel/channel_stack_builder.cc \
+ src/core/lib/channel/channel_trace.cc \
+ src/core/lib/channel/channel_trace_registry.cc \
src/core/lib/channel/connected_channel.cc \
src/core/lib/channel/handshaker.cc \
src/core/lib/channel/handshaker_factory.cc \
src/core/lib/channel/handshaker_registry.cc \
+ src/core/lib/channel/status_util.cc \
src/core/lib/compression/compression.cc \
src/core/lib/compression/compression_internal.cc \
src/core/lib/compression/message_compress.cc \
@@ -4696,7 +4728,6 @@ LIBGRPC_UNSECURE_SRC = \
src/core/ext/filters/client_channel/resolver.cc \
src/core/ext/filters/client_channel/resolver_registry.cc \
src/core/ext/filters/client_channel/retry_throttle.cc \
- src/core/ext/filters/client_channel/status_util.cc \
src/core/ext/filters/client_channel/subchannel.cc \
src/core/ext/filters/client_channel/subchannel_index.cc \
src/core/ext/filters/client_channel/uri_parser.cc \
@@ -5317,10 +5348,13 @@ LIBGRPC++_CRONET_SRC = \
src/core/lib/channel/channel_args.cc \
src/core/lib/channel/channel_stack.cc \
src/core/lib/channel/channel_stack_builder.cc \
+ src/core/lib/channel/channel_trace.cc \
+ src/core/lib/channel/channel_trace_registry.cc \
src/core/lib/channel/connected_channel.cc \
src/core/lib/channel/handshaker.cc \
src/core/lib/channel/handshaker_factory.cc \
src/core/lib/channel/handshaker_registry.cc \
+ src/core/lib/channel/status_util.cc \
src/core/lib/compression/compression.cc \
src/core/lib/compression/compression_internal.cc \
src/core/lib/compression/message_compress.cc \
@@ -5481,7 +5515,6 @@ LIBGRPC++_CRONET_SRC = \
src/core/ext/filters/client_channel/resolver.cc \
src/core/ext/filters/client_channel/resolver_registry.cc \
src/core/ext/filters/client_channel/retry_throttle.cc \
- src/core/ext/filters/client_channel/status_util.cc \
src/core/ext/filters/client_channel/subchannel.cc \
src/core/ext/filters/client_channel/subchannel_index.cc \
src/core/ext/filters/client_channel/uri_parser.cc \
@@ -6009,12 +6042,14 @@ endif
LIBGRPC++_TEST_UTIL_SRC = \
+ $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc \
$(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc \
$(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc \
$(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc \
$(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc \
test/cpp/end2end/test_service_impl.cc \
test/cpp/util/byte_buffer_proto_helper.cc \
+ test/cpp/util/channel_trace_proto_helper.cc \
test/cpp/util/create_test_channel.cc \
test/cpp/util/string_ref_helper.cc \
test/cpp/util/subprocess.cc \
@@ -6150,13 +6185,14 @@ ifneq ($(NO_DEPS),true)
-include $(LIBGRPC++_TEST_UTIL_OBJS:.o=.dep)
endif
endif
-$(OBJDIR)/$(CONFIG)/test/cpp/end2end/test_service_impl.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc
-$(OBJDIR)/$(CONFIG)/test/cpp/util/byte_buffer_proto_helper.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc
-$(OBJDIR)/$(CONFIG)/test/cpp/util/create_test_channel.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc
-$(OBJDIR)/$(CONFIG)/test/cpp/util/string_ref_helper.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc
-$(OBJDIR)/$(CONFIG)/test/cpp/util/subprocess.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc
-$(OBJDIR)/$(CONFIG)/test/cpp/util/test_credentials_provider.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc
-$(OBJDIR)/$(CONFIG)/src/cpp/codegen/codegen_init.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc
+$(OBJDIR)/$(CONFIG)/test/cpp/end2end/test_service_impl.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc
+$(OBJDIR)/$(CONFIG)/test/cpp/util/byte_buffer_proto_helper.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc
+$(OBJDIR)/$(CONFIG)/test/cpp/util/channel_trace_proto_helper.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc
+$(OBJDIR)/$(CONFIG)/test/cpp/util/create_test_channel.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc
+$(OBJDIR)/$(CONFIG)/test/cpp/util/string_ref_helper.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc
+$(OBJDIR)/$(CONFIG)/test/cpp/util/subprocess.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc
+$(OBJDIR)/$(CONFIG)/test/cpp/util/test_credentials_provider.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc
+$(OBJDIR)/$(CONFIG)/src/cpp/codegen/codegen_init.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc
LIBGRPC++_TEST_UTIL_UNSECURE_SRC = \
@@ -16014,6 +16050,53 @@ endif
endif
+CHANNEL_TRACE_TEST_SRC = \
+ test/core/channel/channel_trace_test.cc \
+ $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc \
+
+CHANNEL_TRACE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CHANNEL_TRACE_TEST_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/channel_trace_test: openssl_dep_error
+
+else
+
+
+
+
+ifeq ($(NO_PROTOBUF),true)
+
+# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.
+
+$(BINDIR)/$(CONFIG)/channel_trace_test: protobuf_dep_error
+
+else
+
+$(BINDIR)/$(CONFIG)/channel_trace_test: $(PROTOBUF_DEP) $(CHANNEL_TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LDXX) $(LDFLAGS) $(CHANNEL_TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/channel_trace_test
+
+endif
+
+endif
+
+$(OBJDIR)/$(CONFIG)/test/core/channel/channel_trace_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+$(OBJDIR)/$(CONFIG)/src/proto/grpc/channelz/channelz.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+deps_channel_trace_test: $(CHANNEL_TRACE_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(CHANNEL_TRACE_TEST_OBJS:.o=.dep)
+endif
+endif
+$(OBJDIR)/$(CONFIG)/test/core/channel/channel_trace_test.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc
+
+
CHECK_GCP_ENVIRONMENT_LINUX_TEST_SRC = \
test/core/security/check_gcp_environment_linux_test.cc \
@@ -19179,7 +19262,7 @@ endif
STATUS_UTIL_TEST_SRC = \
- test/core/client_channel/status_util_test.cc \
+ test/core/channel/status_util_test.cc \
STATUS_UTIL_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(STATUS_UTIL_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@@ -19210,7 +19293,7 @@ endif
endif
-$(OBJDIR)/$(CONFIG)/test/core/client_channel/status_util_test.o: $(LIBDIR)/$(CONFIG)/libgrpc.a
+$(OBJDIR)/$(CONFIG)/test/core/channel/status_util_test.o: $(LIBDIR)/$(CONFIG)/libgrpc.a
deps_status_util_test: $(STATUS_UTIL_TEST_OBJS:.o=.dep)
@@ -23625,6 +23708,7 @@ test/cpp/qps/server_async.cc: $(OPENSSL_DEP)
test/cpp/qps/server_sync.cc: $(OPENSSL_DEP)
test/cpp/qps/usage_timer.cc: $(OPENSSL_DEP)
test/cpp/util/byte_buffer_proto_helper.cc: $(OPENSSL_DEP)
+test/cpp/util/channel_trace_proto_helper.cc: $(OPENSSL_DEP)
test/cpp/util/cli_call.cc: $(OPENSSL_DEP)
test/cpp/util/cli_credentials.cc: $(OPENSSL_DEP)
test/cpp/util/create_test_channel.cc: $(OPENSSL_DEP)
diff --git a/build.yaml b/build.yaml
index 7263af87ca..71fd59c85b 100644
--- a/build.yaml
+++ b/build.yaml
@@ -232,10 +232,13 @@ filegroups:
- src/core/lib/channel/channel_args.cc
- src/core/lib/channel/channel_stack.cc
- src/core/lib/channel/channel_stack_builder.cc
+ - src/core/lib/channel/channel_trace.cc
+ - src/core/lib/channel/channel_trace_registry.cc
- src/core/lib/channel/connected_channel.cc
- src/core/lib/channel/handshaker.cc
- src/core/lib/channel/handshaker_factory.cc
- src/core/lib/channel/handshaker_registry.cc
+ - src/core/lib/channel/status_util.cc
- src/core/lib/compression/compression.cc
- src/core/lib/compression/compression_internal.cc
- src/core/lib/compression/message_compress.cc
@@ -399,11 +402,14 @@ filegroups:
- src/core/lib/channel/channel_args.h
- src/core/lib/channel/channel_stack.h
- src/core/lib/channel/channel_stack_builder.h
+ - src/core/lib/channel/channel_trace.h
+ - src/core/lib/channel/channel_trace_registry.h
- src/core/lib/channel/connected_channel.h
- src/core/lib/channel/context.h
- src/core/lib/channel/handshaker.h
- src/core/lib/channel/handshaker_factory.h
- src/core/lib/channel/handshaker_registry.h
+ - src/core/lib/channel/status_util.h
- src/core/lib/compression/algorithm_metadata.h
- src/core/lib/compression/compression_internal.h
- src/core/lib/compression/message_compress.h
@@ -547,7 +553,6 @@ filegroups:
- src/core/ext/filters/client_channel/resolver_factory.h
- src/core/ext/filters/client_channel/resolver_registry.h
- src/core/ext/filters/client_channel/retry_throttle.h
- - src/core/ext/filters/client_channel/status_util.h
- src/core/ext/filters/client_channel/subchannel.h
- src/core/ext/filters/client_channel/subchannel_index.h
- src/core/ext/filters/client_channel/uri_parser.h
@@ -570,7 +575,6 @@ filegroups:
- src/core/ext/filters/client_channel/resolver.cc
- src/core/ext/filters/client_channel/resolver_registry.cc
- src/core/ext/filters/client_channel/retry_throttle.cc
- - src/core/ext/filters/client_channel/status_util.cc
- src/core/ext/filters/client_channel/subchannel.cc
- src/core/ext/filters/client_channel/subchannel_index.cc
- src/core/ext/filters/client_channel/uri_parser.cc
@@ -1071,6 +1075,10 @@ filegroups:
secure: true
uses:
- grpc_trace
+- name: grpc++_channelz_proto
+ language: c++
+ src:
+ - src/proto/grpc/channelz/channelz.proto
- name: grpc++_codegen_base
language: c++
public_headers:
@@ -1623,17 +1631,20 @@ libs:
headers:
- test/cpp/end2end/test_service_impl.h
- test/cpp/util/byte_buffer_proto_helper.h
+ - test/cpp/util/channel_trace_proto_helper.h
- test/cpp/util/create_test_channel.h
- test/cpp/util/string_ref_helper.h
- test/cpp/util/subprocess.h
- test/cpp/util/test_credentials_provider.h
src:
+ - src/proto/grpc/channelz/channelz.proto
- src/proto/grpc/health/v1/health.proto
- src/proto/grpc/testing/echo_messages.proto
- src/proto/grpc/testing/echo.proto
- src/proto/grpc/testing/duplicate/echo_duplicate.proto
- test/cpp/end2end/test_service_impl.cc
- test/cpp/util/byte_buffer_proto_helper.cc
+ - test/cpp/util/channel_trace_proto_helper.cc
- test/cpp/util/create_test_channel.cc
- test/cpp/util/string_ref_helper.cc
- test/cpp/util/subprocess.cc
@@ -4116,6 +4127,24 @@ targets:
- grpc
- gpr
uses_polling: false
+- name: channel_trace_test
+ gtest: true
+ build: test
+ language: c++
+ src:
+ - test/core/channel/channel_trace_test.cc
+ deps:
+ - grpc_test_util
+ - grpc++_test_util
+ - grpc++
+ - grpc
+ - gpr_test_util
+ - gpr
+ filegroups:
+ - grpc++_channelz_proto
+ uses:
+ - grpc++_test
+ uses_polling: false
- name: check_gcp_environment_linux_test
build: test
language: c++
@@ -5153,7 +5182,7 @@ targets:
build: test
language: c++
src:
- - test/core/client_channel/status_util_test.cc
+ - test/core/channel/status_util_test.cc
deps:
- grpc
uses_polling: false
diff --git a/config.m4 b/config.m4
index 9b7b6bbc1b..43fac8bc12 100644
--- a/config.m4
+++ b/config.m4
@@ -84,10 +84,13 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/channel/channel_args.cc \
src/core/lib/channel/channel_stack.cc \
src/core/lib/channel/channel_stack_builder.cc \
+ src/core/lib/channel/channel_trace.cc \
+ src/core/lib/channel/channel_trace_registry.cc \
src/core/lib/channel/connected_channel.cc \
src/core/lib/channel/handshaker.cc \
src/core/lib/channel/handshaker_factory.cc \
src/core/lib/channel/handshaker_registry.cc \
+ src/core/lib/channel/status_util.cc \
src/core/lib/compression/compression.cc \
src/core/lib/compression/compression_internal.cc \
src/core/lib/compression/message_compress.cc \
@@ -336,7 +339,6 @@ if test "$PHP_GRPC" != "no"; then
src/core/ext/filters/client_channel/resolver.cc \
src/core/ext/filters/client_channel/resolver_registry.cc \
src/core/ext/filters/client_channel/retry_throttle.cc \
- src/core/ext/filters/client_channel/status_util.cc \
src/core/ext/filters/client_channel/subchannel.cc \
src/core/ext/filters/client_channel/subchannel_index.cc \
src/core/ext/filters/client_channel/uri_parser.cc \
diff --git a/config.w32 b/config.w32
index 85c5a5f3fe..eb0529886d 100644
--- a/config.w32
+++ b/config.w32
@@ -61,10 +61,13 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\channel\\channel_args.cc " +
"src\\core\\lib\\channel\\channel_stack.cc " +
"src\\core\\lib\\channel\\channel_stack_builder.cc " +
+ "src\\core\\lib\\channel\\channel_trace.cc " +
+ "src\\core\\lib\\channel\\channel_trace_registry.cc " +
"src\\core\\lib\\channel\\connected_channel.cc " +
"src\\core\\lib\\channel\\handshaker.cc " +
"src\\core\\lib\\channel\\handshaker_factory.cc " +
"src\\core\\lib\\channel\\handshaker_registry.cc " +
+ "src\\core\\lib\\channel\\status_util.cc " +
"src\\core\\lib\\compression\\compression.cc " +
"src\\core\\lib\\compression\\compression_internal.cc " +
"src\\core\\lib\\compression\\message_compress.cc " +
@@ -313,7 +316,6 @@ if (PHP_GRPC != "no") {
"src\\core\\ext\\filters\\client_channel\\resolver.cc " +
"src\\core\\ext\\filters\\client_channel\\resolver_registry.cc " +
"src\\core\\ext\\filters\\client_channel\\retry_throttle.cc " +
- "src\\core\\ext\\filters\\client_channel\\status_util.cc " +
"src\\core\\ext\\filters\\client_channel\\subchannel.cc " +
"src\\core\\ext\\filters\\client_channel\\subchannel_index.cc " +
"src\\core\\ext\\filters\\client_channel\\uri_parser.cc " +
diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec
index 6dd67f5134..f53e9db478 100644
--- a/gRPC-C++.podspec
+++ b/gRPC-C++.podspec
@@ -326,7 +326,6 @@ Pod::Spec.new do |s|
'src/core/ext/filters/client_channel/resolver_factory.h',
'src/core/ext/filters/client_channel/resolver_registry.h',
'src/core/ext/filters/client_channel/retry_throttle.h',
- 'src/core/ext/filters/client_channel/status_util.h',
'src/core/ext/filters/client_channel/subchannel.h',
'src/core/ext/filters/client_channel/subchannel_index.h',
'src/core/ext/filters/client_channel/uri_parser.h',
@@ -345,11 +344,14 @@ Pod::Spec.new do |s|
'src/core/lib/channel/channel_args.h',
'src/core/lib/channel/channel_stack.h',
'src/core/lib/channel/channel_stack_builder.h',
+ 'src/core/lib/channel/channel_trace.h',
+ 'src/core/lib/channel/channel_trace_registry.h',
'src/core/lib/channel/connected_channel.h',
'src/core/lib/channel/context.h',
'src/core/lib/channel/handshaker.h',
'src/core/lib/channel/handshaker_factory.h',
'src/core/lib/channel/handshaker_registry.h',
+ 'src/core/lib/channel/status_util.h',
'src/core/lib/compression/algorithm_metadata.h',
'src/core/lib/compression/compression_internal.h',
'src/core/lib/compression/message_compress.h',
@@ -526,11 +528,14 @@ Pod::Spec.new do |s|
'src/core/lib/channel/channel_args.h',
'src/core/lib/channel/channel_stack.h',
'src/core/lib/channel/channel_stack_builder.h',
+ 'src/core/lib/channel/channel_trace.h',
+ 'src/core/lib/channel/channel_trace_registry.h',
'src/core/lib/channel/connected_channel.h',
'src/core/lib/channel/context.h',
'src/core/lib/channel/handshaker.h',
'src/core/lib/channel/handshaker_factory.h',
'src/core/lib/channel/handshaker_registry.h',
+ 'src/core/lib/channel/status_util.h',
'src/core/lib/compression/algorithm_metadata.h',
'src/core/lib/compression/compression_internal.h',
'src/core/lib/compression/message_compress.h',
diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec
index b48120c336..bc9ee3c8bb 100644
--- a/gRPC-Core.podspec
+++ b/gRPC-Core.podspec
@@ -336,7 +336,6 @@ Pod::Spec.new do |s|
'src/core/ext/filters/client_channel/resolver_factory.h',
'src/core/ext/filters/client_channel/resolver_registry.h',
'src/core/ext/filters/client_channel/retry_throttle.h',
- 'src/core/ext/filters/client_channel/status_util.h',
'src/core/ext/filters/client_channel/subchannel.h',
'src/core/ext/filters/client_channel/subchannel_index.h',
'src/core/ext/filters/client_channel/uri_parser.h',
@@ -355,11 +354,14 @@ Pod::Spec.new do |s|
'src/core/lib/channel/channel_args.h',
'src/core/lib/channel/channel_stack.h',
'src/core/lib/channel/channel_stack_builder.h',
+ 'src/core/lib/channel/channel_trace.h',
+ 'src/core/lib/channel/channel_trace_registry.h',
'src/core/lib/channel/connected_channel.h',
'src/core/lib/channel/context.h',
'src/core/lib/channel/handshaker.h',
'src/core/lib/channel/handshaker_factory.h',
'src/core/lib/channel/handshaker_registry.h',
+ 'src/core/lib/channel/status_util.h',
'src/core/lib/compression/algorithm_metadata.h',
'src/core/lib/compression/compression_internal.h',
'src/core/lib/compression/message_compress.h',
@@ -501,10 +503,13 @@ Pod::Spec.new do |s|
'src/core/lib/channel/channel_args.cc',
'src/core/lib/channel/channel_stack.cc',
'src/core/lib/channel/channel_stack_builder.cc',
+ 'src/core/lib/channel/channel_trace.cc',
+ 'src/core/lib/channel/channel_trace_registry.cc',
'src/core/lib/channel/connected_channel.cc',
'src/core/lib/channel/handshaker.cc',
'src/core/lib/channel/handshaker_factory.cc',
'src/core/lib/channel/handshaker_registry.cc',
+ 'src/core/lib/channel/status_util.cc',
'src/core/lib/compression/compression.cc',
'src/core/lib/compression/compression_internal.cc',
'src/core/lib/compression/message_compress.cc',
@@ -750,7 +755,6 @@ Pod::Spec.new do |s|
'src/core/ext/filters/client_channel/resolver.cc',
'src/core/ext/filters/client_channel/resolver_registry.cc',
'src/core/ext/filters/client_channel/retry_throttle.cc',
- 'src/core/ext/filters/client_channel/status_util.cc',
'src/core/ext/filters/client_channel/subchannel.cc',
'src/core/ext/filters/client_channel/subchannel_index.cc',
'src/core/ext/filters/client_channel/uri_parser.cc',
@@ -908,7 +912,6 @@ Pod::Spec.new do |s|
'src/core/ext/filters/client_channel/resolver_factory.h',
'src/core/ext/filters/client_channel/resolver_registry.h',
'src/core/ext/filters/client_channel/retry_throttle.h',
- 'src/core/ext/filters/client_channel/status_util.h',
'src/core/ext/filters/client_channel/subchannel.h',
'src/core/ext/filters/client_channel/subchannel_index.h',
'src/core/ext/filters/client_channel/uri_parser.h',
@@ -927,11 +930,14 @@ Pod::Spec.new do |s|
'src/core/lib/channel/channel_args.h',
'src/core/lib/channel/channel_stack.h',
'src/core/lib/channel/channel_stack_builder.h',
+ 'src/core/lib/channel/channel_trace.h',
+ 'src/core/lib/channel/channel_trace_registry.h',
'src/core/lib/channel/connected_channel.h',
'src/core/lib/channel/context.h',
'src/core/lib/channel/handshaker.h',
'src/core/lib/channel/handshaker_factory.h',
'src/core/lib/channel/handshaker_registry.h',
+ 'src/core/lib/channel/status_util.h',
'src/core/lib/compression/algorithm_metadata.h',
'src/core/lib/compression/compression_internal.h',
'src/core/lib/compression/message_compress.h',
diff --git a/grpc.def b/grpc.def
index cc19005e68..d64629f129 100644
--- a/grpc.def
+++ b/grpc.def
@@ -45,6 +45,8 @@ EXPORTS
grpc_insecure_channel_create
grpc_lame_client_channel_create
grpc_channel_destroy
+ grpc_channel_get_trace
+ grpc_channel_get_uuid
grpc_call_cancel
grpc_call_cancel_with_status
grpc_call_ref
diff --git a/grpc.gemspec b/grpc.gemspec
index e1106bc9a1..6562f3647b 100644
--- a/grpc.gemspec
+++ b/grpc.gemspec
@@ -267,7 +267,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/filters/client_channel/resolver_factory.h )
s.files += %w( src/core/ext/filters/client_channel/resolver_registry.h )
s.files += %w( src/core/ext/filters/client_channel/retry_throttle.h )
- s.files += %w( src/core/ext/filters/client_channel/status_util.h )
s.files += %w( src/core/ext/filters/client_channel/subchannel.h )
s.files += %w( src/core/ext/filters/client_channel/subchannel_index.h )
s.files += %w( src/core/ext/filters/client_channel/uri_parser.h )
@@ -286,11 +285,14 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/channel/channel_args.h )
s.files += %w( src/core/lib/channel/channel_stack.h )
s.files += %w( src/core/lib/channel/channel_stack_builder.h )
+ s.files += %w( src/core/lib/channel/channel_trace.h )
+ s.files += %w( src/core/lib/channel/channel_trace_registry.h )
s.files += %w( src/core/lib/channel/connected_channel.h )
s.files += %w( src/core/lib/channel/context.h )
s.files += %w( src/core/lib/channel/handshaker.h )
s.files += %w( src/core/lib/channel/handshaker_factory.h )
s.files += %w( src/core/lib/channel/handshaker_registry.h )
+ s.files += %w( src/core/lib/channel/status_util.h )
s.files += %w( src/core/lib/compression/algorithm_metadata.h )
s.files += %w( src/core/lib/compression/compression_internal.h )
s.files += %w( src/core/lib/compression/message_compress.h )
@@ -432,10 +434,13 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/channel/channel_args.cc )
s.files += %w( src/core/lib/channel/channel_stack.cc )
s.files += %w( src/core/lib/channel/channel_stack_builder.cc )
+ s.files += %w( src/core/lib/channel/channel_trace.cc )
+ s.files += %w( src/core/lib/channel/channel_trace_registry.cc )
s.files += %w( src/core/lib/channel/connected_channel.cc )
s.files += %w( src/core/lib/channel/handshaker.cc )
s.files += %w( src/core/lib/channel/handshaker_factory.cc )
s.files += %w( src/core/lib/channel/handshaker_registry.cc )
+ s.files += %w( src/core/lib/channel/status_util.cc )
s.files += %w( src/core/lib/compression/compression.cc )
s.files += %w( src/core/lib/compression/compression_internal.cc )
s.files += %w( src/core/lib/compression/message_compress.cc )
@@ -684,7 +689,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/filters/client_channel/resolver.cc )
s.files += %w( src/core/ext/filters/client_channel/resolver_registry.cc )
s.files += %w( src/core/ext/filters/client_channel/retry_throttle.cc )
- s.files += %w( src/core/ext/filters/client_channel/status_util.cc )
s.files += %w( src/core/ext/filters/client_channel/subchannel.cc )
s.files += %w( src/core/ext/filters/client_channel/subchannel_index.cc )
s.files += %w( src/core/ext/filters/client_channel/uri_parser.cc )
diff --git a/grpc.gyp b/grpc.gyp
index 1bdebe0019..957bb06f33 100644
--- a/grpc.gyp
+++ b/grpc.gyp
@@ -237,10 +237,13 @@
'src/core/lib/channel/channel_args.cc',
'src/core/lib/channel/channel_stack.cc',
'src/core/lib/channel/channel_stack_builder.cc',
+ 'src/core/lib/channel/channel_trace.cc',
+ 'src/core/lib/channel/channel_trace_registry.cc',
'src/core/lib/channel/connected_channel.cc',
'src/core/lib/channel/handshaker.cc',
'src/core/lib/channel/handshaker_factory.cc',
'src/core/lib/channel/handshaker_registry.cc',
+ 'src/core/lib/channel/status_util.cc',
'src/core/lib/compression/compression.cc',
'src/core/lib/compression/compression_internal.cc',
'src/core/lib/compression/message_compress.cc',
@@ -489,7 +492,6 @@
'src/core/ext/filters/client_channel/resolver.cc',
'src/core/ext/filters/client_channel/resolver_registry.cc',
'src/core/ext/filters/client_channel/retry_throttle.cc',
- 'src/core/ext/filters/client_channel/status_util.cc',
'src/core/ext/filters/client_channel/subchannel.cc',
'src/core/ext/filters/client_channel/subchannel_index.cc',
'src/core/ext/filters/client_channel/uri_parser.cc',
@@ -583,10 +585,13 @@
'src/core/lib/channel/channel_args.cc',
'src/core/lib/channel/channel_stack.cc',
'src/core/lib/channel/channel_stack_builder.cc',
+ 'src/core/lib/channel/channel_trace.cc',
+ 'src/core/lib/channel/channel_trace_registry.cc',
'src/core/lib/channel/connected_channel.cc',
'src/core/lib/channel/handshaker.cc',
'src/core/lib/channel/handshaker_factory.cc',
'src/core/lib/channel/handshaker_registry.cc',
+ 'src/core/lib/channel/status_util.cc',
'src/core/lib/compression/compression.cc',
'src/core/lib/compression/compression_internal.cc',
'src/core/lib/compression/message_compress.cc',
@@ -742,7 +747,6 @@
'src/core/ext/filters/client_channel/resolver.cc',
'src/core/ext/filters/client_channel/resolver_registry.cc',
'src/core/ext/filters/client_channel/retry_throttle.cc',
- 'src/core/ext/filters/client_channel/status_util.cc',
'src/core/ext/filters/client_channel/subchannel.cc',
'src/core/ext/filters/client_channel/subchannel_index.cc',
'src/core/ext/filters/client_channel/uri_parser.cc',
@@ -811,10 +815,13 @@
'src/core/lib/channel/channel_args.cc',
'src/core/lib/channel/channel_stack.cc',
'src/core/lib/channel/channel_stack_builder.cc',
+ 'src/core/lib/channel/channel_trace.cc',
+ 'src/core/lib/channel/channel_trace_registry.cc',
'src/core/lib/channel/connected_channel.cc',
'src/core/lib/channel/handshaker.cc',
'src/core/lib/channel/handshaker_factory.cc',
'src/core/lib/channel/handshaker_registry.cc',
+ 'src/core/lib/channel/status_util.cc',
'src/core/lib/compression/compression.cc',
'src/core/lib/compression/compression_internal.cc',
'src/core/lib/compression/message_compress.cc',
@@ -970,7 +977,6 @@
'src/core/ext/filters/client_channel/resolver.cc',
'src/core/ext/filters/client_channel/resolver_registry.cc',
'src/core/ext/filters/client_channel/retry_throttle.cc',
- 'src/core/ext/filters/client_channel/status_util.cc',
'src/core/ext/filters/client_channel/subchannel.cc',
'src/core/ext/filters/client_channel/subchannel_index.cc',
'src/core/ext/filters/client_channel/uri_parser.cc',
@@ -1018,10 +1024,13 @@
'src/core/lib/channel/channel_args.cc',
'src/core/lib/channel/channel_stack.cc',
'src/core/lib/channel/channel_stack_builder.cc',
+ 'src/core/lib/channel/channel_trace.cc',
+ 'src/core/lib/channel/channel_trace_registry.cc',
'src/core/lib/channel/connected_channel.cc',
'src/core/lib/channel/handshaker.cc',
'src/core/lib/channel/handshaker_factory.cc',
'src/core/lib/channel/handshaker_registry.cc',
+ 'src/core/lib/channel/status_util.cc',
'src/core/lib/compression/compression.cc',
'src/core/lib/compression/compression_internal.cc',
'src/core/lib/compression/message_compress.cc',
@@ -1210,7 +1219,6 @@
'src/core/ext/filters/client_channel/resolver.cc',
'src/core/ext/filters/client_channel/resolver_registry.cc',
'src/core/ext/filters/client_channel/retry_throttle.cc',
- 'src/core/ext/filters/client_channel/status_util.cc',
'src/core/ext/filters/client_channel/subchannel.cc',
'src/core/ext/filters/client_channel/subchannel_index.cc',
'src/core/ext/filters/client_channel/uri_parser.cc',
@@ -1391,12 +1399,14 @@
'grpc',
],
'sources': [
+ 'src/proto/grpc/channelz/channelz.proto',
'src/proto/grpc/health/v1/health.proto',
'src/proto/grpc/testing/echo_messages.proto',
'src/proto/grpc/testing/echo.proto',
'src/proto/grpc/testing/duplicate/echo_duplicate.proto',
'test/cpp/end2end/test_service_impl.cc',
'test/cpp/util/byte_buffer_proto_helper.cc',
+ 'test/cpp/util/channel_trace_proto_helper.cc',
'test/cpp/util/create_test_channel.cc',
'test/cpp/util/string_ref_helper.cc',
'test/cpp/util/subprocess.cc',
diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h
index c129a66949..dd8a5d7d5f 100644
--- a/include/grpc/grpc.h
+++ b/include/grpc/grpc.h
@@ -286,6 +286,14 @@ GRPCAPI grpc_channel* grpc_lame_client_channel_create(
/** Close and destroy a grpc channel */
GRPCAPI void grpc_channel_destroy(grpc_channel* channel);
+/** Returns the JSON formatted channel trace for this channel. The caller
+ owns the returned string and is responsible for freeing it. */
+GRPCAPI char* grpc_channel_get_trace(grpc_channel* channel);
+
+/** Returns the channel uuid, which can be used to look up its trace at a
+ later time. */
+GRPCAPI intptr_t grpc_channel_get_uuid(grpc_channel* channel);
+
/** Error handling for grpc_call
Most grpc_call functions return a grpc_error. If the error is not GRPC_OK
then the operation failed due to some unsatisfied precondition.
diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h
index e1a3f0dcf1..03aaa9fae4 100644
--- a/include/grpc/impl/codegen/grpc_types.h
+++ b/include/grpc/impl/codegen/grpc_types.h
@@ -285,6 +285,10 @@ typedef struct {
#define GRPC_ARG_SOCKET_MUTATOR "grpc.socket_mutator"
/** The grpc_socket_factory instance to create and bind sockets. A pointer. */
#define GRPC_ARG_SOCKET_FACTORY "grpc.socket_factory"
+/** The maximum number of trace events to keep in the tracer for each channel or
+ * subchannel. The default is 10. If set to 0, channel tracing is disabled. */
+#define GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE \
+ "grpc.max_channel_trace_events_per_node"
/** If non-zero, Cronet transport will coalesce packets to fewer frames
* when possible. */
#define GRPC_ARG_USE_CRONET_PACKET_COALESCING \
diff --git a/package.xml b/package.xml
index 2a38df8406..892f9c207d 100644
--- a/package.xml
+++ b/package.xml
@@ -274,7 +274,6 @@
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver_factory.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver_registry.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/retry_throttle.h" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/status_util.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/subchannel.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/subchannel_index.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/uri_parser.h" role="src" />
@@ -293,11 +292,14 @@
<file baseinstalldir="/" name="src/core/lib/channel/channel_args.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/channel_stack.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/channel_stack_builder.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/channel/channel_trace.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/channel/channel_trace_registry.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/connected_channel.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/context.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/handshaker.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/handshaker_factory.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/handshaker_registry.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/channel/status_util.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/compression/algorithm_metadata.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/compression/compression_internal.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/compression/message_compress.h" role="src" />
@@ -439,10 +441,13 @@
<file baseinstalldir="/" name="src/core/lib/channel/channel_args.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/channel_stack.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/channel_stack_builder.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/channel/channel_trace.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/channel/channel_trace_registry.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/connected_channel.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/handshaker.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/handshaker_factory.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/handshaker_registry.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/channel/status_util.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/compression/compression.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/compression/compression_internal.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/compression/message_compress.cc" role="src" />
@@ -691,7 +696,6 @@
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver_registry.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/retry_throttle.cc" role="src" />
- <file baseinstalldir="/" name="src/core/ext/filters/client_channel/status_util.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/subchannel.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/subchannel_index.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/uri_parser.cc" role="src" />
diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc
index bbc5160bec..bf3911e5ee 100644
--- a/src/core/ext/filters/client_channel/client_channel.cc
+++ b/src/core/ext/filters/client_channel/client_channel.cc
@@ -38,12 +38,12 @@
#include "src/core/ext/filters/client_channel/proxy_mapper_registry.h"
#include "src/core/ext/filters/client_channel/resolver_registry.h"
#include "src/core/ext/filters/client_channel/retry_throttle.h"
-#include "src/core/ext/filters/client_channel/status_util.h"
#include "src/core/ext/filters/client_channel/subchannel.h"
#include "src/core/ext/filters/deadline/deadline_filter.h"
#include "src/core/lib/backoff/backoff.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/connected_channel.h"
+#include "src/core/lib/channel/status_util.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gprpp/inlined_vector.h"
#include "src/core/lib/gprpp/manual_constructor.h"
diff --git a/src/core/ext/filters/client_channel/method_params.cc b/src/core/ext/filters/client_channel/method_params.cc
index 374b87e170..1f116bb67d 100644
--- a/src/core/ext/filters/client_channel/method_params.cc
+++ b/src/core/ext/filters/client_channel/method_params.cc
@@ -26,7 +26,7 @@
#include <grpc/support/string_util.h>
#include "src/core/ext/filters/client_channel/method_params.h"
-#include "src/core/ext/filters/client_channel/status_util.h"
+#include "src/core/lib/channel/status_util.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gprpp/memory.h"
diff --git a/src/core/ext/filters/client_channel/method_params.h b/src/core/ext/filters/client_channel/method_params.h
index 48ece29867..099924edf3 100644
--- a/src/core/ext/filters/client_channel/method_params.h
+++ b/src/core/ext/filters/client_channel/method_params.h
@@ -21,7 +21,7 @@
#include <grpc/support/port_platform.h>
-#include "src/core/ext/filters/client_channel/status_util.h"
+#include "src/core/lib/channel/status_util.h"
#include "src/core/lib/gprpp/ref_counted.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/iomgr/exec_ctx.h" // for grpc_millis
diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc
index cae7cc35e3..d7815fb7e1 100644
--- a/src/core/ext/filters/client_channel/subchannel.cc
+++ b/src/core/ext/filters/client_channel/subchannel.cc
@@ -40,6 +40,7 @@
#include "src/core/lib/debug/stats.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/manual_constructor.h"
+#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/iomgr/sockaddr_utils.h"
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/profiling/timers.h"
diff --git a/src/core/lib/channel/channel_trace.cc b/src/core/lib/channel/channel_trace.cc
new file mode 100644
index 0000000000..654300cd32
--- /dev/null
+++ b/src/core/lib/channel/channel_trace.cc
@@ -0,0 +1,239 @@
+/*
+ *
+ * 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/impl/codegen/port_platform.h>
+
+#include "src/core/lib/channel/channel_trace.h"
+
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "src/core/lib/channel/channel_trace_registry.h"
+#include "src/core/lib/channel/status_util.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/memory.h"
+#include "src/core/lib/iomgr/error.h"
+#include "src/core/lib/slice/slice_internal.h"
+#include "src/core/lib/surface/channel.h"
+#include "src/core/lib/transport/connectivity_state.h"
+#include "src/core/lib/transport/error_utils.h"
+
+namespace grpc_core {
+
+ChannelTrace::TraceEvent::TraceEvent(
+ Severity severity, grpc_slice data,
+ RefCountedPtr<ChannelTrace> referenced_tracer, ReferencedType type)
+ : severity_(severity),
+ data_(data),
+ timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(),
+ GPR_CLOCK_REALTIME)),
+ next_(nullptr),
+ referenced_tracer_(std::move(referenced_tracer)),
+ referenced_type_(type) {}
+
+ChannelTrace::TraceEvent::TraceEvent(Severity severity, grpc_slice data)
+ : severity_(severity),
+ data_(data),
+ timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(),
+ GPR_CLOCK_REALTIME)),
+ next_(nullptr) {}
+
+ChannelTrace::TraceEvent::~TraceEvent() { grpc_slice_unref_internal(data_); }
+
+ChannelTrace::ChannelTrace(size_t max_events)
+ : channel_uuid_(-1),
+ num_events_logged_(0),
+ list_size_(0),
+ max_list_size_(max_events),
+ head_trace_(nullptr),
+ tail_trace_(nullptr) {
+ if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0
+ gpr_mu_init(&tracer_mu_);
+ channel_uuid_ = grpc_channel_trace_registry_register_channel_trace(this);
+ time_created_ = grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(),
+ GPR_CLOCK_REALTIME);
+}
+
+ChannelTrace::~ChannelTrace() {
+ if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0
+ TraceEvent* it = head_trace_;
+ while (it != nullptr) {
+ TraceEvent* to_free = it;
+ it = it->next();
+ Delete<TraceEvent>(to_free);
+ }
+ grpc_channel_trace_registry_unregister_channel_trace(channel_uuid_);
+ gpr_mu_destroy(&tracer_mu_);
+}
+
+intptr_t ChannelTrace::GetUuid() const { return channel_uuid_; }
+
+void ChannelTrace::AddTraceEventHelper(TraceEvent* new_trace_event) {
+ ++num_events_logged_;
+ // first event case
+ if (head_trace_ == nullptr) {
+ head_trace_ = tail_trace_ = new_trace_event;
+ }
+ // regular event add case
+ else {
+ tail_trace_->set_next(new_trace_event);
+ tail_trace_ = tail_trace_->next();
+ }
+ ++list_size_;
+ // maybe garbage collect the end
+ if (list_size_ > max_list_size_) {
+ TraceEvent* to_free = head_trace_;
+ head_trace_ = head_trace_->next();
+ Delete<TraceEvent>(to_free);
+ --list_size_;
+ }
+}
+
+void ChannelTrace::AddTraceEvent(Severity severity, grpc_slice data) {
+ if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0
+ AddTraceEventHelper(New<TraceEvent>(severity, data));
+}
+
+void ChannelTrace::AddTraceEventReferencingChannel(
+ Severity severity, grpc_slice data,
+ RefCountedPtr<ChannelTrace> referenced_tracer) {
+ if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0
+ // create and fill up the new event
+ AddTraceEventHelper(
+ New<TraceEvent>(severity, data, std::move(referenced_tracer), Channel));
+}
+
+void ChannelTrace::AddTraceEventReferencingSubchannel(
+ Severity severity, grpc_slice data,
+ RefCountedPtr<ChannelTrace> referenced_tracer) {
+ if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0
+ // create and fill up the new event
+ AddTraceEventHelper(New<TraceEvent>(
+ severity, data, std::move(referenced_tracer), Subchannel));
+}
+
+namespace {
+
+// returns an allocated string that represents tm according to RFC-3339, and,
+// more specifically, follows:
+// https://developers.google.com/protocol-buffers/docs/proto3#json
+//
+// "Uses RFC 3339, where generated output will always be Z-normalized and uses
+// 0, 3, 6 or 9 fractional digits."
+char* fmt_time(gpr_timespec tm) {
+ char time_buffer[35];
+ char ns_buffer[11]; // '.' + 9 digits of precision
+ struct tm* tm_info = localtime((const time_t*)&tm.tv_sec);
+ strftime(time_buffer, sizeof(time_buffer), "%Y-%m-%dT%H:%M:%S", tm_info);
+ snprintf(ns_buffer, 11, ".%09d", tm.tv_nsec);
+ // This loop trims off trailing zeros by inserting a null character that the
+ // right point. We iterate in chunks of three because we want 0, 3, 6, or 9
+ // fractional digits.
+ for (int i = 7; i >= 1; i -= 3) {
+ if (ns_buffer[i] == '0' && ns_buffer[i + 1] == '0' &&
+ ns_buffer[i + 2] == '0') {
+ ns_buffer[i] = '\0';
+ // Edge case in which all fractional digits were 0.
+ if (i == 1) {
+ ns_buffer[0] = '\0';
+ }
+ } else {
+ break;
+ }
+ }
+ char* full_time_str;
+ gpr_asprintf(&full_time_str, "%s%sZ", time_buffer, ns_buffer);
+ return full_time_str;
+}
+
+const char* severity_string(ChannelTrace::Severity severity) {
+ switch (severity) {
+ case ChannelTrace::Severity::Info:
+ return "CT_INFO";
+ case ChannelTrace::Severity::Warning:
+ return "CT_WARNING";
+ case ChannelTrace::Severity::Error:
+ return "CT_ERROR";
+ default:
+ GPR_UNREACHABLE_CODE(return "CT_UNKNOWN");
+ }
+}
+
+} // anonymous namespace
+
+void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) const {
+ grpc_json* json_iterator = nullptr;
+ json_iterator = grpc_json_create_child(json_iterator, json, "description",
+ grpc_slice_to_c_string(data_),
+ GRPC_JSON_STRING, true);
+ json_iterator = grpc_json_create_child(json_iterator, json, "severity",
+ severity_string(severity_),
+ GRPC_JSON_STRING, false);
+ json_iterator =
+ grpc_json_create_child(json_iterator, json, "timestamp",
+ fmt_time(timestamp_), GRPC_JSON_STRING, true);
+ if (referenced_tracer_ != nullptr) {
+ char* uuid_str;
+ gpr_asprintf(&uuid_str, "%" PRIdPTR, referenced_tracer_->channel_uuid_);
+ grpc_json* child_ref = grpc_json_create_child(
+ json_iterator, json,
+ (referenced_type_ == Channel) ? "channelRef" : "subchannelRef", nullptr,
+ GRPC_JSON_OBJECT, false);
+ json_iterator = grpc_json_create_child(
+ nullptr, child_ref,
+ (referenced_type_ == Channel) ? "channelId" : "subchannelId", uuid_str,
+ GRPC_JSON_STRING, true);
+ json_iterator = child_ref;
+ }
+}
+
+char* ChannelTrace::RenderTrace() const {
+ if (!max_list_size_)
+ return nullptr; // tracing is disabled if max_events == 0
+ grpc_json* json = grpc_json_create(GRPC_JSON_OBJECT);
+ char* num_events_logged_str;
+ gpr_asprintf(&num_events_logged_str, "%" PRId64, num_events_logged_);
+ grpc_json* json_iterator = nullptr;
+ json_iterator =
+ grpc_json_create_child(json_iterator, json, "numEventsLogged",
+ num_events_logged_str, GRPC_JSON_STRING, true);
+ json_iterator =
+ grpc_json_create_child(json_iterator, json, "creationTime",
+ fmt_time(time_created_), GRPC_JSON_STRING, true);
+ grpc_json* events = grpc_json_create_child(json_iterator, json, "events",
+ nullptr, GRPC_JSON_ARRAY, false);
+ json_iterator = nullptr;
+ TraceEvent* it = head_trace_;
+ while (it != nullptr) {
+ json_iterator = grpc_json_create_child(json_iterator, events, nullptr,
+ nullptr, GRPC_JSON_OBJECT, false);
+ it->RenderTraceEvent(json_iterator);
+ it = it->next();
+ }
+ char* json_str = grpc_json_dump_to_string(json, 0);
+ grpc_json_destroy(json);
+ return json_str;
+}
+
+} // namespace grpc_core
diff --git a/src/core/lib/channel/channel_trace.h b/src/core/lib/channel/channel_trace.h
new file mode 100644
index 0000000000..1df1e585f2
--- /dev/null
+++ b/src/core/lib/channel/channel_trace.h
@@ -0,0 +1,133 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#ifndef GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_H
+#define GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_H
+
+#include <grpc/impl/codegen/port_platform.h>
+
+#include <grpc/grpc.h>
+#include "src/core/lib/gprpp/ref_counted.h"
+#include "src/core/lib/gprpp/ref_counted_ptr.h"
+#include "src/core/lib/iomgr/error.h"
+#include "src/core/lib/json/json.h"
+
+namespace grpc_core {
+
+// Object used to hold live data for a channel. This data is exposed via the
+// channelz service:
+// https://github.com/grpc/proposal/blob/master/A14-channelz.md
+class ChannelTrace : public RefCounted<ChannelTrace> {
+ public:
+ ChannelTrace(size_t max_events);
+ ~ChannelTrace();
+
+ // returns the tracer's uuid
+ intptr_t GetUuid() const;
+
+ enum Severity {
+ Unset = 0, // never to be used
+ Info, // we start at 1 to avoid using proto default values
+ Warning,
+ Error
+ };
+
+ // Adds a new trace event to the tracing object
+ //
+ // TODO(ncteisen): as this call is used more and more throughout the gRPC
+ // stack, determine if it makes more sense to accept a char* instead of a
+ // slice.
+ void AddTraceEvent(Severity severity, grpc_slice data);
+
+ // Adds a new trace event to the tracing object. This trace event refers to a
+ // an event on a child of the channel. For example, if this channel has
+ // created a new subchannel, then it would record that with a TraceEvent
+ // referencing the new subchannel.
+ //
+ // TODO(ncteisen): Once channelz is implemented, the events should reference
+ // the overall channelz object, not just the ChannelTrace object.
+ // TODO(ncteisen): as this call is used more and more throughout the gRPC
+ // stack, determine if it makes more sense to accept a char* instead of a
+ // slice.
+ void AddTraceEventReferencingChannel(
+ Severity severity, grpc_slice data,
+ RefCountedPtr<ChannelTrace> referenced_tracer);
+ void AddTraceEventReferencingSubchannel(
+ Severity severity, grpc_slice data,
+ RefCountedPtr<ChannelTrace> referenced_tracer);
+
+ // Returns the tracing data rendered as a grpc json string.
+ // The string is owned by the caller and must be freed.
+ char* RenderTrace() const;
+
+ private:
+ // Types of objects that can be references by trace events.
+ enum ReferencedType { Channel, Subchannel };
+ // Private class to encapsulate all the data and bookkeeping needed for a
+ // a trace event.
+ class TraceEvent {
+ public:
+ // Constructor for a TraceEvent that references a different channel.
+ // TODO(ncteisen): once channelz is implemented, this should reference the
+ // overall channelz object, not just the ChannelTrace object
+ TraceEvent(Severity severity, grpc_slice data,
+ RefCountedPtr<ChannelTrace> referenced_tracer,
+ ReferencedType type);
+
+ // Constructor for a TraceEvent that does not reverence a different
+ // channel.
+ TraceEvent(Severity severity, grpc_slice data);
+
+ ~TraceEvent();
+
+ // Renders the data inside of this TraceEvent into a json object. This is
+ // used by the ChannelTrace, when it is rendering itself.
+ void RenderTraceEvent(grpc_json* json) const;
+
+ // set and get for the next_ pointer.
+ TraceEvent* next() const { return next_; }
+ void set_next(TraceEvent* next) { next_ = next; }
+
+ private:
+ Severity severity_;
+ grpc_slice data_;
+ gpr_timespec timestamp_;
+ TraceEvent* next_;
+ // the tracer object for the (sub)channel that this trace event refers to.
+ RefCountedPtr<ChannelTrace> referenced_tracer_;
+ // the type that the referenced tracer points to. Unused if this trace
+ // does not point to any channel or subchannel
+ ReferencedType referenced_type_;
+ }; // TraceEvent
+
+ // Internal helper to add and link in a trace event
+ void AddTraceEventHelper(TraceEvent* new_trace_event);
+
+ gpr_mu tracer_mu_;
+ intptr_t channel_uuid_;
+ uint64_t num_events_logged_;
+ size_t list_size_;
+ size_t max_list_size_;
+ TraceEvent* head_trace_;
+ TraceEvent* tail_trace_;
+ gpr_timespec time_created_;
+};
+
+} // namespace grpc_core
+
+#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_H */
diff --git a/src/core/lib/channel/channel_trace_registry.cc b/src/core/lib/channel/channel_trace_registry.cc
new file mode 100644
index 0000000000..6c82431467
--- /dev/null
+++ b/src/core/lib/channel/channel_trace_registry.cc
@@ -0,0 +1,80 @@
+/*
+ *
+ * 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/impl/codegen/port_platform.h>
+
+#include "src/core/lib/avl/avl.h"
+#include "src/core/lib/channel/channel_trace.h"
+#include "src/core/lib/channel/channel_trace_registry.h"
+#include "src/core/lib/gpr/useful.h"
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+
+// file global lock and avl.
+static gpr_mu g_mu;
+static grpc_avl g_avl;
+static gpr_atm g_uuid = 0;
+
+// avl vtable for uuid (intptr_t) -> ChannelTrace
+// this table is only looking, it does not own anything.
+static void destroy_intptr(void* not_used, void* user_data) {}
+static void* copy_intptr(void* key, void* user_data) { return key; }
+static long compare_intptr(void* key1, void* key2, void* user_data) {
+ return GPR_ICMP(key1, key2);
+}
+
+static void destroy_channel_trace(void* trace, void* user_data) {}
+static void* copy_channel_trace(void* trace, void* user_data) { return trace; }
+static const grpc_avl_vtable avl_vtable = {
+ destroy_intptr, copy_intptr, compare_intptr, destroy_channel_trace,
+ copy_channel_trace};
+
+void grpc_channel_trace_registry_init() {
+ gpr_mu_init(&g_mu);
+ g_avl = grpc_avl_create(&avl_vtable);
+}
+
+void grpc_channel_trace_registry_shutdown() {
+ grpc_avl_unref(g_avl, nullptr);
+ gpr_mu_destroy(&g_mu);
+}
+
+intptr_t grpc_channel_trace_registry_register_channel_trace(
+ grpc_core::ChannelTrace* channel_trace) {
+ intptr_t prior = gpr_atm_no_barrier_fetch_add(&g_uuid, 1);
+ gpr_mu_lock(&g_mu);
+ g_avl = grpc_avl_add(g_avl, (void*)prior, channel_trace, nullptr);
+ gpr_mu_unlock(&g_mu);
+ return prior;
+}
+
+void grpc_channel_trace_registry_unregister_channel_trace(intptr_t uuid) {
+ gpr_mu_lock(&g_mu);
+ g_avl = grpc_avl_remove(g_avl, (void*)uuid, nullptr);
+ gpr_mu_unlock(&g_mu);
+}
+
+grpc_core::ChannelTrace* grpc_channel_trace_registry_get_channel_trace(
+ intptr_t uuid) {
+ gpr_mu_lock(&g_mu);
+ grpc_core::ChannelTrace* ret = static_cast<grpc_core::ChannelTrace*>(
+ grpc_avl_get(g_avl, (void*)uuid, nullptr));
+ gpr_mu_unlock(&g_mu);
+ return ret;
+}
diff --git a/src/core/lib/channel/channel_trace_registry.h b/src/core/lib/channel/channel_trace_registry.h
new file mode 100644
index 0000000000..391ecba7de
--- /dev/null
+++ b/src/core/lib/channel/channel_trace_registry.h
@@ -0,0 +1,43 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#ifndef GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_REGISTRY_H
+#define GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_REGISTRY_H
+
+#include <grpc/impl/codegen/port_platform.h>
+
+#include "src/core/lib/channel/channel_trace.h"
+
+#include <stdint.h>
+
+// TODO(ncteisen): convert this file to C++
+
+void grpc_channel_trace_registry_init();
+void grpc_channel_trace_registry_shutdown();
+
+// globally registers a ChannelTrace. Returns its unique uuid
+intptr_t grpc_channel_trace_registry_register_channel_trace(
+ grpc_core::ChannelTrace* channel_trace);
+// globally unregisters the ChannelTrace that is associated to uuid.
+void grpc_channel_trace_registry_unregister_channel_trace(intptr_t uuid);
+// if object with uuid has previously been registered, returns the ChannelTrace
+// associated with that uuid. Else returns nullptr.
+grpc_core::ChannelTrace* grpc_channel_trace_registry_get_channel_trace(
+ intptr_t uuid);
+
+#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_REGISTRY_H */
diff --git a/src/core/ext/filters/client_channel/status_util.cc b/src/core/lib/channel/status_util.cc
index 11f732ab44..563db40846 100644
--- a/src/core/ext/filters/client_channel/status_util.cc
+++ b/src/core/lib/channel/status_util.cc
@@ -18,7 +18,7 @@
#include <grpc/support/port_platform.h>
-#include "src/core/ext/filters/client_channel/status_util.h"
+#include "src/core/lib/channel/status_util.h"
#include "src/core/lib/gpr/useful.h"
diff --git a/src/core/ext/filters/client_channel/status_util.h b/src/core/lib/channel/status_util.h
index e018709730..5409de6b3c 100644
--- a/src/core/ext/filters/client_channel/status_util.h
+++ b/src/core/lib/channel/status_util.h
@@ -16,8 +16,8 @@
*
*/
-#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_STATUS_UTIL_H
-#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_STATUS_UTIL_H
+#ifndef GRPC_CORE_LIB_CHANNEL_STATUS_UTIL_H
+#define GRPC_CORE_LIB_CHANNEL_STATUS_UTIL_H
#include <grpc/support/port_platform.h>
@@ -55,4 +55,4 @@ class StatusCodeSet {
} // namespace internal
} // namespace grpc_core
-#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_STATUS_UTIL_H */
+#endif /* GRPC_CORE_LIB_CHANNEL_STATUS_UTIL_H */
diff --git a/src/core/lib/json/json.cc b/src/core/lib/json/json.cc
index 2141db4c5b..816241bbf0 100644
--- a/src/core/lib/json/json.cc
+++ b/src/core/lib/json/json.cc
@@ -21,6 +21,7 @@
#include <string.h>
#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
#include "src/core/lib/json/json.h"
@@ -46,5 +47,40 @@ void grpc_json_destroy(grpc_json* json) {
json->parent->child = json->next;
}
+ if (json->owns_value) {
+ gpr_free((void*)json->value);
+ }
+
gpr_free(json);
}
+
+grpc_json* grpc_json_link_child(grpc_json* parent, grpc_json* child,
+ grpc_json* sibling) {
+ // first child case.
+ if (parent->child == nullptr) {
+ GPR_ASSERT(sibling == nullptr);
+ parent->child = child;
+ return child;
+ }
+ if (sibling == nullptr) {
+ sibling = parent->child;
+ }
+ // always find the right most sibling.
+ while (sibling->next != nullptr) {
+ sibling = sibling->next;
+ }
+ sibling->next = child;
+ return child;
+}
+
+grpc_json* grpc_json_create_child(grpc_json* sibling, grpc_json* parent,
+ const char* key, const char* value,
+ grpc_json_type type, bool owns_value) {
+ grpc_json* child = grpc_json_create(type);
+ grpc_json_link_child(parent, child, sibling);
+ child->owns_value = owns_value;
+ child->parent = parent;
+ child->value = value;
+ child->key = key;
+ return child;
+}
diff --git a/src/core/lib/json/json.h b/src/core/lib/json/json.h
index 3a62ef9cfb..f93b43048b 100644
--- a/src/core/lib/json/json.h
+++ b/src/core/lib/json/json.h
@@ -21,6 +21,7 @@
#include <grpc/support/port_platform.h>
+#include <stdbool.h>
#include <stdlib.h>
#include "src/core/lib/json/json_common.h"
@@ -37,6 +38,9 @@ typedef struct grpc_json {
grpc_json_type type;
const char* key;
const char* value;
+
+ /* if set, destructor will free value */
+ bool owns_value;
} grpc_json;
/* The next two functions are going to parse the input string, and
@@ -67,9 +71,24 @@ char* grpc_json_dump_to_string(grpc_json* json, int indent);
/* Use these to create or delete a grpc_json object.
* Deletion is recursive. We will not attempt to free any of the strings
- * in any of the objects of that tree.
+ * in any of the objects of that tree, unless the boolean, owns_value,
+ * is true.
*/
grpc_json* grpc_json_create(grpc_json_type type);
void grpc_json_destroy(grpc_json* json);
+/* Links the child json object into the parent's json tree. If the parent
+ * already has children, then passing in the most recently added child as the
+ * sibling parameter is an optimization. For if sibling is NULL, this function
+ * will manually traverse the tree in order to find the right most sibling.
+ */
+grpc_json* grpc_json_link_child(grpc_json* parent, grpc_json* child,
+ grpc_json* sibling);
+
+/* Creates a child json object into the parent's json tree then links it in
+ * as described above. */
+grpc_json* grpc_json_create_child(grpc_json* sibling, grpc_json* parent,
+ const char* key, const char* value,
+ grpc_json_type type, bool owns_value);
+
#endif /* GRPC_CORE_LIB_JSON_JSON_H */
diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc
index 03353d6beb..cecc15b2df 100644
--- a/src/core/lib/surface/channel.cc
+++ b/src/core/lib/surface/channel.cc
@@ -21,6 +21,7 @@
#include "src/core/lib/surface/channel.h"
#include <inttypes.h>
+#include <limits.h>
#include <stdlib.h>
#include <string.h>
@@ -30,8 +31,12 @@
#include <grpc/support/string_util.h>
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/channel/channel_trace.h"
#include "src/core/lib/debug/stats.h"
#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gprpp/manual_constructor.h"
+#include "src/core/lib/gprpp/memory.h"
+#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/surface/api_trace.h"
@@ -62,6 +67,8 @@ struct grpc_channel {
gpr_mu registered_call_mu;
registered_call* registered_calls;
+ grpc_core::RefCountedPtr<grpc_core::ChannelTrace> tracer;
+
char* target;
};
@@ -93,12 +100,14 @@ grpc_channel* grpc_channel_create_with_builder(
grpc_error_string(error));
GRPC_ERROR_UNREF(error);
gpr_free(target);
- goto done;
+ grpc_channel_args_destroy(args);
+ return channel;
}
memset(channel, 0, sizeof(*channel));
channel->target = target;
channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type);
+ size_t channel_tracer_max_nodes = 0; // default to off
gpr_mu_init(&channel->registered_call_mu);
channel->registered_calls = nullptr;
@@ -161,14 +170,33 @@ grpc_channel* grpc_channel_create_with_builder(
channel->compression_options.enabled_algorithms_bitset =
static_cast<uint32_t>(args->args[i].value.integer) |
0x1; /* always support no compression */
+ } else if (0 == strcmp(args->args[i].key,
+ GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE)) {
+ GPR_ASSERT(channel_tracer_max_nodes == 0);
+ // max_nodes defaults to 0 (which is off), clamped between 0 and INT_MAX
+ const grpc_integer_options options = {0, 0, INT_MAX};
+ channel_tracer_max_nodes =
+ (size_t)grpc_channel_arg_get_integer(&args->args[i], options);
}
}
-done:
grpc_channel_args_destroy(args);
+ channel->tracer = grpc_core::MakeRefCounted<grpc_core::ChannelTrace>(
+ channel_tracer_max_nodes);
+ channel->tracer->AddTraceEvent(
+ grpc_core::ChannelTrace::Severity::Info,
+ grpc_slice_from_static_string("Channel created"));
return channel;
}
+char* grpc_channel_get_trace(grpc_channel* channel) {
+ return channel->tracer->RenderTrace();
+}
+
+intptr_t grpc_channel_get_uuid(grpc_channel* channel) {
+ return channel->tracer->GetUuid();
+}
+
grpc_channel* grpc_channel_create(const char* target,
const grpc_channel_args* input_args,
grpc_channel_stack_type channel_stack_type,
@@ -377,6 +405,7 @@ static void destroy_channel(void* arg, grpc_error* error) {
GRPC_MDELEM_UNREF(rc->authority);
gpr_free(rc);
}
+ channel->tracer.reset();
GRPC_MDELEM_UNREF(channel->default_authority);
gpr_mu_destroy(&channel->registered_call_mu);
gpr_free(channel->target);
diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc
index ac9f9e6066..bd436d6857 100644
--- a/src/core/lib/surface/init.cc
+++ b/src/core/lib/surface/init.cc
@@ -27,6 +27,7 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include "src/core/lib/channel/channel_stack.h"
+#include "src/core/lib/channel/channel_trace_registry.h"
#include "src/core/lib/channel/connected_channel.h"
#include "src/core/lib/channel/handshaker_registry.h"
#include "src/core/lib/debug/stats.h"
@@ -128,6 +129,7 @@ void grpc_init(void) {
grpc_slice_intern_init();
grpc_mdctx_global_init();
grpc_channel_init_init();
+ grpc_channel_trace_registry_init();
grpc_security_pre_init();
grpc_core::ExecCtx::GlobalInit();
grpc_iomgr_init();
@@ -176,6 +178,7 @@ void grpc_shutdown(void) {
grpc_mdctx_global_shutdown();
grpc_handshaker_factory_registry_shutdown();
grpc_slice_intern_shutdown();
+ grpc_channel_trace_registry_shutdown();
grpc_stats_shutdown();
}
grpc_core::ExecCtx::GlobalShutdown();
diff --git a/src/proto/grpc/channelz/BUILD b/src/proto/grpc/channelz/BUILD
new file mode 100644
index 0000000000..bdb03d5e2d
--- /dev/null
+++ b/src/proto/grpc/channelz/BUILD
@@ -0,0 +1,26 @@
+# Copyright 2018 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"]) # Apache v2
+
+load("//bazel:grpc_build_system.bzl", "grpc_proto_library", "grpc_package")
+
+grpc_package(name = "channelz", visibility = "public")
+
+grpc_proto_library(
+ name = "channelz_proto",
+ srcs = ["channelz.proto"],
+ has_services = True,
+ well_known_protos = True,
+)
diff --git a/src/proto/grpc/channelz/channelz.proto b/src/proto/grpc/channelz/channelz.proto
new file mode 100644
index 0000000000..14db66a654
--- /dev/null
+++ b/src/proto/grpc/channelz/channelz.proto
@@ -0,0 +1,456 @@
+// Copyright 2018 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.
+
+syntax = "proto3";
+
+package grpc.channelz;
+
+import "google/protobuf/any.proto";
+import "google/protobuf/duration.proto";
+import "google/protobuf/timestamp.proto";
+import "google/protobuf/wrappers.proto";
+
+// See go/grpc-channelz.
+
+// Channel is a logical grouping of channels, subchannels, and sockets.
+message Channel {
+ // The identifier for this channel.
+ ChannelRef ref = 1;
+ // Data specific to this channel.
+ ChannelData data = 2;
+ // At most one of 'channel_ref+subchannel_ref' and 'socket' is set.
+
+ // There are no ordering guarantees on the order of channel refs.
+ // There may not be cycles in the ref graph.
+ // A channel ref may be present in more than one channel or subchannel.
+ repeated ChannelRef channel_ref = 3;
+
+ // At most one of 'channel_ref+subchannel_ref' and 'socket' is set.
+ // There are no ordering guarantees on the order of subchannel refs.
+ // There may not be cycles in the ref graph.
+ // A sub channel ref may be present in more than one channel or subchannel.
+ repeated SubchannelRef subchannel_ref = 4;
+
+ // There are no ordering guarantees on the order of sockets.
+ repeated SocketRef socket = 5;
+}
+
+// Subchannel is a logical grouping of channels, subchannels, and sockets.
+// A subchannel is load balanced over by it's ancestor
+message Subchannel {
+ // The identifier for this channel.
+ SubchannelRef ref = 1;
+ // Data specific to this channel.
+ ChannelData data = 2;
+ // At most one of 'channel_ref+subchannel_ref' and 'socket' is set.
+
+ // There are no ordering guarantees on the order of channel refs.
+ // There may not be cycles in the ref graph.
+ // A channel ref may be present in more than one channel or subchannel.
+ repeated ChannelRef channel_ref = 3;
+
+ // At most one of 'channel_ref+subchannel_ref' and 'socket' is set.
+ // There are no ordering guarantees on the order of subchannel refs.
+ // There may not be cycles in the ref graph.
+ // A sub channel ref may be present in more than one channel or subchannel.
+ repeated SubchannelRef subchannel_ref = 4;
+
+ // There are no ordering guarantees on the order of sockets.
+ repeated SocketRef socket = 5;
+}
+
+// These come from the specified states in this document:
+// https://github.com/grpc/grpc/blob/master/doc/connectivity-semantics-and-api.md
+message ChannelConnectivityState {
+ enum State {
+ UNKNOWN = 0;
+ IDLE = 1;
+ CONNECTING = 2;
+ READY = 3;
+ TRANSIENT_FAILURE = 4;
+ SHUTDOWN = 5;
+ }
+ State state = 1;
+}
+
+message ChannelData {
+
+ ChannelConnectivityState state = 1;
+
+ // The target this channel originally tried to connect to. May be absent
+ string target = 2;
+
+ ChannelTrace trace = 3;
+
+ // The number of calls started on the channel
+ int64 calls_started = 4;
+ // The number of calls that have completed with an OK status
+ int64 calls_succeeded = 5;
+ // The number of calls that have a completed with a non-OK status
+ int64 calls_failed = 6;
+
+ // The last time a call was started on the channel.
+ google.protobuf.Timestamp last_call_started_timestamp = 7;
+}
+
+// A trace event is an interesting thing that happened to a channel or
+// subchannel, such as creation, address resolution, subchannel creation, etc.
+message ChannelTraceEvent {
+ // High level description of the event.
+ string description = 1;
+ // The supported severity levels of trace events.
+ enum Severity {
+ CT_UNKNOWN = 0;
+ CT_INFO = 1;
+ CT_WARNING = 2;
+ CT_ERROR = 3;
+ }
+ // the severity of the trace event
+ Severity severity = 2;
+ // When this event occurred.
+ google.protobuf.Timestamp timestamp = 3;
+ // ref of referenced channel or subchannel.
+ // Optional, only present if this event refers to a child object. For example,
+ // this field would be filled if this trace event was for a subchannel being
+ // created.
+ oneof child_ref {
+ ChannelRef channel_ref = 4;
+ SubchannelRef subchannel_ref = 5;
+ }
+}
+
+message ChannelTrace {
+ // Number of events ever logged in this tracing object. This can differ from
+ // events.size() because events can be overwritten or garbage collected by
+ // implementations.
+ int64 num_events_logged = 1;
+ // Time that this channel was created.
+ google.protobuf.Timestamp creation_time = 2;
+ // List of events that have occurred on this channel.
+ repeated ChannelTraceEvent events = 3;
+}
+
+message ChannelRef {
+ // The globally unique id for this channel. Must be a positive number.
+ int64 channel_id = 1;
+ // An optional name associated with the channel.
+ string name = 2;
+ // Intentionally don't use field numbers from other refs.
+ reserved 3, 4, 5, 6;
+}
+
+message SubchannelRef {
+ // The globally unique id for this subchannel. Must be a positive number.
+ int64 subchannel_id = 7;
+ // An optional name associated with the subchannel.
+ string name = 8;
+ // Intentionally don't use field numbers from other refs.
+ reserved 1, 2, 3, 4, 5, 6;
+}
+
+message SocketRef {
+ int64 socket_id = 3;
+ // An optional name associated with the socket.
+ string name = 4;
+ // Intentionally don't use field numbers from other refs.
+ reserved 1, 2, 5, 6, 7, 8;
+}
+
+message ServerRef {
+ // A globally unique identifier for this server. Must be a positive number.
+ int64 server_id = 5;
+ // An optional name associated with the server.
+ string name = 6;
+ // Intentionally don't use field numbers from other refs.
+ reserved 1, 2, 3, 4, 7, 8;
+}
+
+message Server {
+ ServerRef ref = 1;
+ ServerData data = 2;
+
+ // The sockets that the server is listening on. There are no ordering
+ // guarantees.
+ repeated SocketRef listen_socket = 3;
+}
+
+message ServerData {
+ ChannelTrace trace = 1;
+
+ // The number of incoming calls started on the server
+ int64 calls_started = 2;
+ // The number of incoming calls that have completed with an OK status
+ int64 calls_succeeded = 3;
+ // The number of incoming calls that have a completed with a non-OK status
+ int64 calls_failed = 4;
+
+ // The last time a call was started on the server.
+ google.protobuf.Timestamp last_call_started_timestamp = 5;
+}
+
+// Information about an actual connection. Pronounced "sock-ay".
+message Socket {
+ SocketRef ref = 1;
+
+ SocketData data = 2;
+ // The locally bound address.
+ Address local = 3;
+ // The remote bound address. May be absent.
+ Address remote = 4;
+ Security security = 5;
+
+ // Optional, represents the name of the remote endpoint, if different than
+ // the original target name.
+ string remote_name = 6;
+}
+
+message SocketData {
+ // The number of streams that have been started.
+ int64 streams_started = 1;
+ // The number of streams that have ended successfully with the EoS bit set for
+ // both end points
+ int64 streams_succeeded = 2;
+ // The number of incoming streams that have a completed with a non-OK status
+ int64 streams_failed = 3;
+
+ // The number of messages successfully sent on this socket.
+ int64 messages_sent = 4;
+ int64 messages_received = 5;
+
+ // The number of keep alives sent. This is typically implemented with HTTP/2
+ // ping messages.
+ int64 keep_alives_sent = 6;
+
+ // The last time a stream was created by this endpoint. Usually unset for
+ // servers.
+ google.protobuf.Timestamp last_local_stream_created_timestamp = 7;
+ // The last time a stream was created by the remote endpoint. Usually unset
+ // for clients.
+ google.protobuf.Timestamp last_remote_stream_created_timestamp = 8;
+
+ // The last time a message was sent by this endpoint.
+ google.protobuf.Timestamp last_message_sent_timestamp = 9;
+ // The last time a message was received by this endpoint.
+ google.protobuf.Timestamp last_message_received_timestamp = 10;
+
+ // The amount of window, granted to the local endpoint by the remote endpoint.
+ // This may be slightly out of date due to network latency. This does NOT
+ // include stream level or TCP level flow control info.
+ google.protobuf.Int64Value local_flow_control_window = 11;
+
+ // The amount of window, granted to the remote endpoint by the local endpoint.
+ // This may be slightly out of date due to network latency. This does NOT
+ // include stream level or TCP level flow control info.
+ google.protobuf.Int64Value remote_flow_control_window = 12;
+
+ repeated SocketOption option = 13;
+}
+
+message Address {
+ message TcpIpAddress {
+ // Either the IPv4 or IPv6 address in bytes. Will either be 4 bytes or 16
+ // bytes in length.
+ bytes ip_address = 1;
+ // 0-64k, or -1 if not appropriate.
+ int32 port = 2;
+ }
+ // A Unix Domain Socket address.
+ message UdsAddress {
+ string filename = 1;
+ }
+ // An address type not included above.
+ message OtherAddress {
+ // The human readable version of the value.
+ string name = 1;
+ // The actual address message.
+ google.protobuf.Any value = 2;
+ }
+
+ oneof address {
+ TcpIpAddress tcpip_address = 1;
+ UdsAddress uds_address = 2;
+ OtherAddress other_address = 3;
+ }
+}
+
+message Security {
+ message Tls {
+ // The key exchange used. e.g. X25519
+ string key_exchange = 1;
+ // The cipher used. e.g. AES_128_GCM.
+ string cipher = 2;
+ // the certificate used by this endpoint.
+ bytes local_certificate = 3;
+ // the certificate used by the remote endpoint.
+ bytes remote_certificate = 4;
+ }
+ message OtherSecurity {
+ // The human readable version of the value.
+ string name = 1;
+ // The actual security details message.
+ google.protobuf.Any value = 2;
+ }
+ oneof model {
+ Tls tls = 1;
+ OtherSecurity other = 2;
+ }
+}
+
+message SocketOption {
+ string name = 1;
+ // The human readable value of this socket option. At least one of value or
+ // additional will be set.
+ string value = 2;
+ // Additional data associated with the socket option. At least one of value
+ // or additional will be set.
+ google.protobuf.Any additional = 3;
+}
+
+// For use with SocketOption's additional field. This is primarily used for
+// SO_RCVTIMEO and SO_SNDTIMEO
+message SocketOptionTimeout {
+ google.protobuf.Duration duration = 1;
+}
+
+message SocketOptionLinger {
+ bool active = 1;
+ google.protobuf.Duration duration = 2;
+}
+
+// Tcp info for SOL_TCP, TCP_INFO
+message SocketOptionTcpInfo {
+ uint32 tcpi_state = 1;
+
+ uint32 tcpi_ca_state = 2;
+ uint32 tcpi_retransmits = 3;
+ uint32 tcpi_probes = 4;
+ uint32 tcpi_backoff = 5;
+ uint32 tcpi_options = 6;
+ uint32 tcpi_snd_wscale = 7;
+ uint32 tcpi_rcv_wscale = 8;
+
+ uint32 tcpi_rto = 9;
+ uint32 tcpi_ato = 10;
+ uint32 tcpi_snd_mss = 11;
+ uint32 tcpi_rcv_mss = 12;
+
+ uint32 tcpi_unacked = 13;
+ uint32 tcpi_sacked = 14;
+ uint32 tcpi_lost = 15;
+ uint32 tcpi_retrans = 16;
+ uint32 tcpi_fackets = 17;
+
+ uint32 tcpi_last_data_sent = 18;
+ uint32 tcpi_last_ack_sent = 19;
+ uint32 tcpi_last_data_recv = 20;
+ uint32 tcpi_last_ack_recv = 21;
+
+ uint32 tcpi_pmtu = 22;
+ uint32 tcpi_rcv_ssthresh = 23;
+ uint32 tcpi_rtt = 24;
+ uint32 tcpi_rttvar = 25;
+ uint32 tcpi_snd_ssthresh = 26;
+ uint32 tcpi_snd_cwnd = 27;
+ uint32 tcpi_advmss = 28;
+ uint32 tcpi_reordering = 29;
+}
+
+service Channelz {
+ // Gets all root channels (e.g. channels the application has directly
+ // created). This does not include subchannels nor non-top level channels.
+ rpc GetTopChannels(GetTopChannelsRequest) returns (GetTopChannelsResponse);
+ // Gets all servers that exist in the process.
+ rpc GetServers(GetServersRequest) returns (GetServersResponse);
+ // Gets all server sockets that exist in the process.
+ rpc GetServerSockets(GetServerSocketsRequest) returns (GetServerSocketsResponse);
+ // Returns a single Channel, or else a NOT_FOUND code.
+ rpc GetChannel(GetChannelRequest) returns (GetChannelResponse);
+ // Returns a single Subchannel, or else a NOT_FOUND code.
+ rpc GetSubchannel(GetSubchannelRequest) returns (GetSubchannelResponse);
+ // Returns a single Socket or else a NOT_FOUND code.
+ rpc GetSocket(GetSocketRequest) returns (GetSocketResponse);
+}
+
+message GetServersRequest {
+ // start_server_id indicates that only servers at or above this id should be
+ // included in the results.
+ int64 start_server_id = 1;
+}
+
+message GetServersResponse {
+ // list of servers that the connection detail service knows about. Sorted in
+ // ascending server_id order.
+ repeated Server server = 1;
+ // If set, indicates that the list of servers is the final list. Requesting
+ // more servers will only return more if they are created after this RPC
+ // completes.
+ bool end = 2;
+}
+
+message GetServerSocketsRequest {
+ int64 server_id = 1;
+ // start_socket_id indicates that only sockets at or above this id should be
+ // included in the results.
+ int64 start_socket_id = 2;
+}
+
+message GetServerSocketsResponse {
+ // list of socket refs that the connection detail service knows about. Sorted in
+ // ascending socket_id order.
+ repeated SocketRef socket_ref = 1;
+ // If set, indicates that the list of sockets is the final list. Requesting
+ // more sockets will only return more if they are created after this RPC
+ // completes.
+ bool end = 2;
+}
+
+message GetTopChannelsRequest {
+ // start_channel_id indicates that only channels at or above this id should be
+ // included in the results.
+ int64 start_channel_id = 1;
+}
+
+message GetTopChannelsResponse {
+ // list of channels that the connection detail service knows about. Sorted in
+ // ascending channel_id order.
+ repeated Channel channel = 1;
+ // If set, indicates that the list of channels is the final list. Requesting
+ // more channels can only return more if they are created after this RPC
+ // completes.
+ bool end = 2;
+}
+
+message GetChannelRequest {
+ int64 channel_id = 1;
+}
+
+message GetChannelResponse {
+ Channel channel = 1;
+}
+
+message GetSubchannelRequest {
+ int64 subchannel_id = 1;
+}
+
+message GetSubchannelResponse {
+ Subchannel subchannel = 1;
+}
+
+message GetSocketRequest {
+ int64 socket_id = 1;
+}
+
+message GetSocketResponse {
+ Socket socket = 1;
+}
diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py
index 62e54a388a..8e815fba7e 100644
--- a/src/python/grpcio/grpc_core_dependencies.py
+++ b/src/python/grpcio/grpc_core_dependencies.py
@@ -60,10 +60,13 @@ CORE_SOURCE_FILES = [
'src/core/lib/channel/channel_args.cc',
'src/core/lib/channel/channel_stack.cc',
'src/core/lib/channel/channel_stack_builder.cc',
+ 'src/core/lib/channel/channel_trace.cc',
+ 'src/core/lib/channel/channel_trace_registry.cc',
'src/core/lib/channel/connected_channel.cc',
'src/core/lib/channel/handshaker.cc',
'src/core/lib/channel/handshaker_factory.cc',
'src/core/lib/channel/handshaker_registry.cc',
+ 'src/core/lib/channel/status_util.cc',
'src/core/lib/compression/compression.cc',
'src/core/lib/compression/compression_internal.cc',
'src/core/lib/compression/message_compress.cc',
@@ -312,7 +315,6 @@ CORE_SOURCE_FILES = [
'src/core/ext/filters/client_channel/resolver.cc',
'src/core/ext/filters/client_channel/resolver_registry.cc',
'src/core/ext/filters/client_channel/retry_throttle.cc',
- 'src/core/ext/filters/client_channel/status_util.cc',
'src/core/ext/filters/client_channel/subchannel.cc',
'src/core/ext/filters/client_channel/subchannel_index.cc',
'src/core/ext/filters/client_channel/uri_parser.cc',
diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c
index 7009bd80f6..a12819e87c 100644
--- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c
+++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c
@@ -68,6 +68,8 @@ grpc_channel_get_info_type grpc_channel_get_info_import;
grpc_insecure_channel_create_type grpc_insecure_channel_create_import;
grpc_lame_client_channel_create_type grpc_lame_client_channel_create_import;
grpc_channel_destroy_type grpc_channel_destroy_import;
+grpc_channel_get_trace_type grpc_channel_get_trace_import;
+grpc_channel_get_uuid_type grpc_channel_get_uuid_import;
grpc_call_cancel_type grpc_call_cancel_import;
grpc_call_cancel_with_status_type grpc_call_cancel_with_status_import;
grpc_call_ref_type grpc_call_ref_import;
@@ -307,6 +309,8 @@ void grpc_rb_load_imports(HMODULE library) {
grpc_insecure_channel_create_import = (grpc_insecure_channel_create_type) GetProcAddress(library, "grpc_insecure_channel_create");
grpc_lame_client_channel_create_import = (grpc_lame_client_channel_create_type) GetProcAddress(library, "grpc_lame_client_channel_create");
grpc_channel_destroy_import = (grpc_channel_destroy_type) GetProcAddress(library, "grpc_channel_destroy");
+ grpc_channel_get_trace_import = (grpc_channel_get_trace_type) GetProcAddress(library, "grpc_channel_get_trace");
+ grpc_channel_get_uuid_import = (grpc_channel_get_uuid_type) GetProcAddress(library, "grpc_channel_get_uuid");
grpc_call_cancel_import = (grpc_call_cancel_type) GetProcAddress(library, "grpc_call_cancel");
grpc_call_cancel_with_status_import = (grpc_call_cancel_with_status_type) GetProcAddress(library, "grpc_call_cancel_with_status");
grpc_call_ref_import = (grpc_call_ref_type) GetProcAddress(library, "grpc_call_ref");
diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h
index 244976c9c5..089cb8a61a 100644
--- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h
+++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h
@@ -179,6 +179,12 @@ extern grpc_lame_client_channel_create_type grpc_lame_client_channel_create_impo
typedef void(*grpc_channel_destroy_type)(grpc_channel* channel);
extern grpc_channel_destroy_type grpc_channel_destroy_import;
#define grpc_channel_destroy grpc_channel_destroy_import
+typedef char*(*grpc_channel_get_trace_type)(grpc_channel* channel);
+extern grpc_channel_get_trace_type grpc_channel_get_trace_import;
+#define grpc_channel_get_trace grpc_channel_get_trace_import
+typedef intptr_t(*grpc_channel_get_uuid_type)(grpc_channel* channel);
+extern grpc_channel_get_uuid_type grpc_channel_get_uuid_import;
+#define grpc_channel_get_uuid grpc_channel_get_uuid_import
typedef grpc_call_error(*grpc_call_cancel_type)(grpc_call* call, void* reserved);
extern grpc_call_cancel_type grpc_call_cancel_import;
#define grpc_call_cancel grpc_call_cancel_import
diff --git a/test/core/channel/BUILD b/test/core/channel/BUILD
index c5dfd8ef37..6bf4fcdbb8 100644
--- a/test/core/channel/BUILD
+++ b/test/core/channel/BUILD
@@ -65,3 +65,32 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
],
)
+
+grpc_cc_test(
+ name = "channel_trace_test",
+ srcs = ["channel_trace_test.cc"],
+ language = "C++",
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//:grpc++",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ "//test/cpp/util:channel_trace_proto_helper",
+ ],
+ external_deps = [
+ "gtest",
+ ],
+)
+
+grpc_cc_test(
+ name = "status_util_test",
+ srcs = ["status_util_test.cc"],
+ language = "C++",
+ deps = [
+ "//:grpc",
+ ],
+ external_deps = [
+ "gtest",
+ ],
+)
diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc
new file mode 100644
index 0000000000..3c73e33612
--- /dev/null
+++ b/test/core/channel/channel_trace_test.cc
@@ -0,0 +1,240 @@
+/*
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+
+#include <gtest/gtest.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+
+#include "src/core/lib/channel/channel_trace.h"
+#include "src/core/lib/channel/channel_trace_registry.h"
+#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/iomgr/exec_ctx.h"
+#include "src/core/lib/json/json.h"
+
+#include "test/core/util/test_config.h"
+#include "test/cpp/util/channel_trace_proto_helper.h"
+
+// remove me
+#include <grpc/support/string_util.h>
+#include <stdlib.h>
+#include <string.h>
+
+namespace grpc_core {
+namespace testing {
+namespace {
+
+grpc_json* GetJsonChild(grpc_json* parent, const char* key) {
+ EXPECT_NE(parent, nullptr);
+ for (grpc_json* child = parent->child; child != nullptr;
+ child = child->next) {
+ if (child->key != nullptr && strcmp(child->key, key) == 0) return child;
+ }
+ return nullptr;
+}
+
+void ValidateJsonArraySize(grpc_json* json, const char* key,
+ size_t expected_size) {
+ grpc_json* arr = GetJsonChild(json, key);
+ ASSERT_NE(arr, nullptr);
+ ASSERT_EQ(arr->type, GRPC_JSON_ARRAY);
+ size_t count = 0;
+ for (grpc_json* child = arr->child; child != nullptr; child = child->next) {
+ ++count;
+ }
+ ASSERT_EQ(count, expected_size);
+}
+
+void ValidateChannelTraceData(grpc_json* json,
+ size_t num_events_logged_expected,
+ size_t actual_num_events_expected) {
+ ASSERT_NE(json, nullptr);
+ grpc_json* num_events_logged_json = GetJsonChild(json, "numEventsLogged");
+ ASSERT_NE(num_events_logged_json, nullptr);
+ grpc_json* start_time = GetJsonChild(json, "creationTime");
+ ASSERT_NE(start_time, nullptr);
+ size_t num_events_logged =
+ (size_t)strtol(num_events_logged_json->value, nullptr, 0);
+ ASSERT_EQ(num_events_logged, num_events_logged_expected);
+ ValidateJsonArraySize(json, "events", actual_num_events_expected);
+}
+
+void AddSimpleTrace(RefCountedPtr<ChannelTrace> tracer) {
+ tracer->AddTraceEvent(ChannelTrace::Severity::Info,
+ grpc_slice_from_static_string("simple trace"));
+}
+
+// checks for the existence of all the required members of the tracer.
+void ValidateChannelTrace(RefCountedPtr<ChannelTrace> tracer,
+ size_t expected_num_event_logged, size_t max_nodes) {
+ if (!max_nodes) return;
+ char* json_str = tracer->RenderTrace();
+ grpc::testing::ValidateChannelTraceProtoJsonTranslation(json_str);
+ grpc_json* json = grpc_json_parse_string(json_str);
+ ValidateChannelTraceData(json, expected_num_event_logged,
+ GPR_MIN(expected_num_event_logged, max_nodes));
+ grpc_json_destroy(json);
+ gpr_free(json_str);
+}
+
+void ValidateTraceDataMatchedUuidLookup(RefCountedPtr<ChannelTrace> tracer) {
+ intptr_t uuid = tracer->GetUuid();
+ if (uuid == -1) return; // Doesn't make sense to lookup if tracing disabled
+ char* tracer_json_str = tracer->RenderTrace();
+ ChannelTrace* uuid_lookup =
+ grpc_channel_trace_registry_get_channel_trace(uuid);
+ char* uuid_lookup_json_str = uuid_lookup->RenderTrace();
+ EXPECT_EQ(strcmp(tracer_json_str, uuid_lookup_json_str), 0);
+ gpr_free(tracer_json_str);
+ gpr_free(uuid_lookup_json_str);
+}
+
+} // anonymous namespace
+
+class ChannelTracerTest : public ::testing::TestWithParam<size_t> {};
+
+// Tests basic ChannelTrace functionality like construction, adding trace, and
+// lookups by uuid.
+TEST_P(ChannelTracerTest, BasicTest) {
+ grpc_core::ExecCtx exec_ctx;
+ RefCountedPtr<ChannelTrace> tracer = MakeRefCounted<ChannelTrace>(GetParam());
+ AddSimpleTrace(tracer);
+ AddSimpleTrace(tracer);
+ ValidateTraceDataMatchedUuidLookup(tracer);
+ tracer->AddTraceEvent(ChannelTrace::Severity::Info,
+ grpc_slice_from_static_string("trace three"));
+ tracer->AddTraceEvent(ChannelTrace::Severity::Error,
+ grpc_slice_from_static_string("trace four error"));
+ ValidateChannelTrace(tracer, 4, GetParam());
+ AddSimpleTrace(tracer);
+ AddSimpleTrace(tracer);
+ ValidateChannelTrace(tracer, 6, GetParam());
+ AddSimpleTrace(tracer);
+ AddSimpleTrace(tracer);
+ AddSimpleTrace(tracer);
+ AddSimpleTrace(tracer);
+ ValidateChannelTrace(tracer, 10, GetParam());
+ ValidateTraceDataMatchedUuidLookup(tracer);
+ tracer.reset(nullptr);
+}
+
+// Tests more complex functionality, like a parent channel tracking
+// subchannles. This exercises the ref/unref patterns since the parent tracer
+// and this function will both hold refs to the subchannel.
+TEST_P(ChannelTracerTest, ComplexTest) {
+ grpc_core::ExecCtx exec_ctx;
+ RefCountedPtr<ChannelTrace> tracer = MakeRefCounted<ChannelTrace>(GetParam());
+ AddSimpleTrace(tracer);
+ AddSimpleTrace(tracer);
+ RefCountedPtr<ChannelTrace> sc1 = MakeRefCounted<ChannelTrace>(GetParam());
+ tracer->AddTraceEventReferencingSubchannel(
+ ChannelTrace::Severity::Info,
+ grpc_slice_from_static_string("subchannel one created"), sc1);
+ ValidateChannelTrace(tracer, 3, GetParam());
+ AddSimpleTrace(sc1);
+ AddSimpleTrace(sc1);
+ AddSimpleTrace(sc1);
+ ValidateChannelTrace(sc1, 3, GetParam());
+ AddSimpleTrace(sc1);
+ AddSimpleTrace(sc1);
+ AddSimpleTrace(sc1);
+ ValidateChannelTrace(sc1, 6, GetParam());
+ AddSimpleTrace(tracer);
+ AddSimpleTrace(tracer);
+ ValidateChannelTrace(tracer, 5, GetParam());
+ ValidateTraceDataMatchedUuidLookup(tracer);
+ RefCountedPtr<ChannelTrace> sc2 = MakeRefCounted<ChannelTrace>(GetParam());
+ tracer->AddTraceEventReferencingChannel(
+ ChannelTrace::Severity::Info,
+ grpc_slice_from_static_string("LB channel two created"), sc2);
+ tracer->AddTraceEventReferencingSubchannel(
+ ChannelTrace::Severity::Warning,
+ grpc_slice_from_static_string("subchannel one inactive"), sc1);
+ ValidateChannelTrace(tracer, 7, GetParam());
+ AddSimpleTrace(tracer);
+ AddSimpleTrace(tracer);
+ AddSimpleTrace(tracer);
+ AddSimpleTrace(tracer);
+ AddSimpleTrace(tracer);
+ AddSimpleTrace(tracer);
+ ValidateTraceDataMatchedUuidLookup(tracer);
+ tracer.reset(nullptr);
+ sc1.reset(nullptr);
+ sc2.reset(nullptr);
+}
+
+// Test a case in which the parent channel has subchannels and the subchannels
+// have connections. Ensures that everything lives as long as it should then
+// gets deleted.
+TEST_P(ChannelTracerTest, TestNesting) {
+ grpc_core::ExecCtx exec_ctx;
+ RefCountedPtr<ChannelTrace> tracer = MakeRefCounted<ChannelTrace>(GetParam());
+ AddSimpleTrace(tracer);
+ AddSimpleTrace(tracer);
+ ValidateChannelTrace(tracer, 2, GetParam());
+ RefCountedPtr<ChannelTrace> sc1 = MakeRefCounted<ChannelTrace>(GetParam());
+ tracer->AddTraceEventReferencingChannel(
+ ChannelTrace::Severity::Info,
+ grpc_slice_from_static_string("subchannel one created"), sc1);
+ ValidateChannelTrace(tracer, 3, GetParam());
+ AddSimpleTrace(sc1);
+ RefCountedPtr<ChannelTrace> conn1 = MakeRefCounted<ChannelTrace>(GetParam());
+ // nesting one level deeper.
+ sc1->AddTraceEventReferencingSubchannel(
+ ChannelTrace::Severity::Info,
+ grpc_slice_from_static_string("connection one created"), conn1);
+ ValidateChannelTrace(tracer, 3, GetParam());
+ AddSimpleTrace(conn1);
+ AddSimpleTrace(tracer);
+ AddSimpleTrace(tracer);
+ ValidateChannelTrace(tracer, 5, GetParam());
+ ValidateChannelTrace(conn1, 1, GetParam());
+ RefCountedPtr<ChannelTrace> sc2 = MakeRefCounted<ChannelTrace>(GetParam());
+ tracer->AddTraceEventReferencingSubchannel(
+ ChannelTrace::Severity::Info,
+ grpc_slice_from_static_string("subchannel two created"), sc2);
+ // this trace should not get added to the parents children since it is already
+ // present in the tracer.
+ tracer->AddTraceEventReferencingChannel(
+ ChannelTrace::Severity::Warning,
+ grpc_slice_from_static_string("subchannel one inactive"), sc1);
+ AddSimpleTrace(tracer);
+ ValidateChannelTrace(tracer, 8, GetParam());
+ tracer.reset(nullptr);
+ sc1.reset(nullptr);
+ sc2.reset(nullptr);
+ conn1.reset(nullptr);
+}
+
+INSTANTIATE_TEST_CASE_P(ChannelTracerTestSweep, ChannelTracerTest,
+ ::testing::Values(0, 1, 2, 6, 10, 15));
+
+} // namespace testing
+} // namespace grpc_core
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ grpc_init();
+ ::testing::InitGoogleTest(&argc, argv);
+ int ret = RUN_ALL_TESTS();
+ grpc_shutdown();
+ return ret;
+}
diff --git a/test/core/client_channel/status_util_test.cc b/test/core/channel/status_util_test.cc
index f944990ad2..1d64bf1995 100644
--- a/test/core/client_channel/status_util_test.cc
+++ b/test/core/channel/status_util_test.cc
@@ -16,7 +16,7 @@
*
*/
-#include "src/core/ext/filters/client_channel/status_util.h"
+#include "src/core/lib/channel/status_util.h"
#include <gtest/gtest.h>
diff --git a/test/core/client_channel/BUILD b/test/core/client_channel/BUILD
index d430b722df..5148dc5f74 100644
--- a/test/core/client_channel/BUILD
+++ b/test/core/client_channel/BUILD
@@ -53,15 +53,3 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
],
)
-
-grpc_cc_test(
- name = "status_util_test",
- srcs = ["status_util_test.cc"],
- language = "C++",
- deps = [
- "//:grpc",
- ],
- external_deps = [
- "gtest",
- ],
-)
diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c
index 38a7d7e709..866bee5b2f 100644
--- a/test/core/surface/public_headers_must_be_c89.c
+++ b/test/core/surface/public_headers_must_be_c89.c
@@ -106,6 +106,8 @@ int main(int argc, char **argv) {
printf("%lx", (unsigned long) grpc_insecure_channel_create);
printf("%lx", (unsigned long) grpc_lame_client_channel_create);
printf("%lx", (unsigned long) grpc_channel_destroy);
+ printf("%lx", (unsigned long) grpc_channel_get_trace);
+ printf("%lx", (unsigned long) grpc_channel_get_uuid);
printf("%lx", (unsigned long) grpc_call_cancel);
printf("%lx", (unsigned long) grpc_call_cancel_with_status);
printf("%lx", (unsigned long) grpc_call_ref);
diff --git a/test/cpp/util/BUILD b/test/cpp/util/BUILD
index 4f84c73820..f53bc7eb7f 100644
--- a/test/cpp/util/BUILD
+++ b/test/cpp/util/BUILD
@@ -85,6 +85,25 @@ grpc_cc_library(
)
grpc_cc_library(
+ name = "channel_trace_proto_helper",
+ testonly = 1,
+ srcs = [
+ "channel_trace_proto_helper.cc",
+ ],
+ hdrs = [
+ "channel_trace_proto_helper.h",
+ ],
+ deps = [
+ "//:grpc++",
+ "//src/proto/grpc/channelz:channelz_proto",
+ ],
+ external_deps = [
+ "gtest",
+ "protobuf",
+ ],
+)
+
+grpc_cc_library(
name = "test_util_unsecure",
srcs = GRPCXX_TESTUTIL_SRCS,
hdrs = GRPCXX_TESTUTIL_HDRS,
diff --git a/test/cpp/util/channel_trace_proto_helper.cc b/test/cpp/util/channel_trace_proto_helper.cc
new file mode 100644
index 0000000000..fbc9f1501c
--- /dev/null
+++ b/test/cpp/util/channel_trace_proto_helper.cc
@@ -0,0 +1,56 @@
+/*
+ *
+ * Copyright 2018 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 "test/cpp/util/channel_trace_proto_helper.h"
+
+#include <google/protobuf/text_format.h>
+#include <google/protobuf/util/json_util.h>
+
+#include <grpc/grpc.h>
+#include <grpc/support/log.h>
+#include <gtest/gtest.h>
+
+#include "src/proto/grpc/channelz/channelz.pb.h"
+
+namespace grpc {
+namespace testing {
+
+void ValidateChannelTraceProtoJsonTranslation(char* tracer_json_c_str) {
+ std::string tracer_json_str(tracer_json_c_str);
+ grpc::channelz::ChannelTrace channel_trace;
+ google::protobuf::util::JsonParseOptions parse_options;
+ // If the following line is failing, then uncomment the last line of the
+ // comment, and uncomment the lines that print the two strings. You can
+ // then compare the output, and determine what fields are missing.
+ //
+ // options.ignore_unknown_fields = true;
+ ASSERT_EQ(google::protobuf::util::JsonStringToMessage(
+ tracer_json_str, &channel_trace, parse_options),
+ google::protobuf::util::Status::OK);
+ std::string proto_json_str;
+ ASSERT_EQ(google::protobuf::util::MessageToJsonString(channel_trace,
+ &proto_json_str),
+ google::protobuf::util::Status::OK);
+ // uncomment these to compare the the json strings.
+ // gpr_log(GPR_ERROR, "tracer json: %s", tracer_json_str.c_str());
+ // gpr_log(GPR_ERROR, "proto json: %s", proto_json_str.c_str());
+ ASSERT_EQ(tracer_json_str, proto_json_str);
+}
+
+} // namespace testing
+} // namespace grpc
diff --git a/test/cpp/util/channel_trace_proto_helper.h b/test/cpp/util/channel_trace_proto_helper.h
new file mode 100644
index 0000000000..d7043d9f06
--- /dev/null
+++ b/test/cpp/util/channel_trace_proto_helper.h
@@ -0,0 +1,30 @@
+/*
+ *
+ * Copyright 2018 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_TEST_CPP_UTIL_CHANNEL_TRACE_PROTO_HELPER_H
+#define GRPC_TEST_CPP_UTIL_CHANNEL_TRACE_PROTO_HELPER_H
+
+namespace grpc {
+namespace testing {
+
+void ValidateChannelTraceProtoJsonTranslation(char* tracer_json_c_str);
+
+} // namespace testing
+} // namespace grpc
+
+#endif // GRPC_TEST_CPP_UTIL_CHANNEL_TRACE_PROTO_HELPER_H
diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal
index c822d9b3cd..52a16d6e98 100644
--- a/tools/doxygen/Doxyfile.c++.internal
+++ b/tools/doxygen/Doxyfile.c++.internal
@@ -1007,11 +1007,14 @@ src/core/lib/backoff/backoff.h \
src/core/lib/channel/channel_args.h \
src/core/lib/channel/channel_stack.h \
src/core/lib/channel/channel_stack_builder.h \
+src/core/lib/channel/channel_trace.h \
+src/core/lib/channel/channel_trace_registry.h \
src/core/lib/channel/connected_channel.h \
src/core/lib/channel/context.h \
src/core/lib/channel/handshaker.h \
src/core/lib/channel/handshaker_factory.h \
src/core/lib/channel/handshaker_registry.h \
+src/core/lib/channel/status_util.h \
src/core/lib/compression/algorithm_metadata.h \
src/core/lib/compression/compression_internal.h \
src/core/lib/compression/message_compress.h \
diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal
index af0c875b99..85675e9a53 100644
--- a/tools/doxygen/Doxyfile.core.internal
+++ b/tools/doxygen/Doxyfile.core.internal
@@ -929,8 +929,6 @@ src/core/ext/filters/client_channel/resolver_registry.cc \
src/core/ext/filters/client_channel/resolver_registry.h \
src/core/ext/filters/client_channel/retry_throttle.cc \
src/core/ext/filters/client_channel/retry_throttle.h \
-src/core/ext/filters/client_channel/status_util.cc \
-src/core/ext/filters/client_channel/status_util.h \
src/core/ext/filters/client_channel/subchannel.cc \
src/core/ext/filters/client_channel/subchannel.h \
src/core/ext/filters/client_channel/subchannel_index.cc \
@@ -1034,6 +1032,10 @@ src/core/lib/channel/channel_stack.cc \
src/core/lib/channel/channel_stack.h \
src/core/lib/channel/channel_stack_builder.cc \
src/core/lib/channel/channel_stack_builder.h \
+src/core/lib/channel/channel_trace.cc \
+src/core/lib/channel/channel_trace.h \
+src/core/lib/channel/channel_trace_registry.cc \
+src/core/lib/channel/channel_trace_registry.h \
src/core/lib/channel/connected_channel.cc \
src/core/lib/channel/connected_channel.h \
src/core/lib/channel/context.h \
@@ -1043,6 +1045,8 @@ src/core/lib/channel/handshaker_factory.cc \
src/core/lib/channel/handshaker_factory.h \
src/core/lib/channel/handshaker_registry.cc \
src/core/lib/channel/handshaker_registry.h \
+src/core/lib/channel/status_util.cc \
+src/core/lib/channel/status_util.h \
src/core/lib/compression/algorithm_metadata.h \
src/core/lib/compression/compression.cc \
src/core/lib/compression/compression_internal.cc \
diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json
index 1b18349cfa..3ebd8c1a40 100644
--- a/tools/run_tests/generated/sources_and_headers.json
+++ b/tools/run_tests/generated/sources_and_headers.json
@@ -3037,6 +3037,27 @@
{
"deps": [
"gpr",
+ "gpr_test_util",
+ "grpc",
+ "grpc++",
+ "grpc++_channelz_proto",
+ "grpc++_test",
+ "grpc++_test_util",
+ "grpc_test_util"
+ ],
+ "headers": [],
+ "is_filegroup": false,
+ "language": "c++",
+ "name": "channel_trace_test",
+ "src": [
+ "test/core/channel/channel_trace_test.cc"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [
+ "gpr",
"grpc"
],
"headers": [],
@@ -4504,7 +4525,7 @@
"language": "c++",
"name": "status_util_test",
"src": [
- "test/core/client_channel/status_util_test.cc"
+ "test/core/channel/status_util_test.cc"
],
"third_party": false,
"type": "target"
@@ -6985,6 +7006,9 @@
"grpc_test_util"
],
"headers": [
+ "src/proto/grpc/channelz/channelz.grpc.pb.h",
+ "src/proto/grpc/channelz/channelz.pb.h",
+ "src/proto/grpc/channelz/channelz_mock.grpc.pb.h",
"src/proto/grpc/health/v1/health.grpc.pb.h",
"src/proto/grpc/health/v1/health.pb.h",
"src/proto/grpc/health/v1/health_mock.grpc.pb.h",
@@ -6999,6 +7023,7 @@
"src/proto/grpc/testing/echo_mock.grpc.pb.h",
"test/cpp/end2end/test_service_impl.h",
"test/cpp/util/byte_buffer_proto_helper.h",
+ "test/cpp/util/channel_trace_proto_helper.h",
"test/cpp/util/create_test_channel.h",
"test/cpp/util/string_ref_helper.h",
"test/cpp/util/subprocess.h",
@@ -7012,6 +7037,8 @@
"test/cpp/end2end/test_service_impl.h",
"test/cpp/util/byte_buffer_proto_helper.cc",
"test/cpp/util/byte_buffer_proto_helper.h",
+ "test/cpp/util/channel_trace_proto_helper.cc",
+ "test/cpp/util/channel_trace_proto_helper.h",
"test/cpp/util/create_test_channel.cc",
"test/cpp/util/create_test_channel.h",
"test/cpp/util/string_ref_helper.cc",
@@ -9013,10 +9040,13 @@
"src/core/lib/channel/channel_args.cc",
"src/core/lib/channel/channel_stack.cc",
"src/core/lib/channel/channel_stack_builder.cc",
+ "src/core/lib/channel/channel_trace.cc",
+ "src/core/lib/channel/channel_trace_registry.cc",
"src/core/lib/channel/connected_channel.cc",
"src/core/lib/channel/handshaker.cc",
"src/core/lib/channel/handshaker_factory.cc",
"src/core/lib/channel/handshaker_registry.cc",
+ "src/core/lib/channel/status_util.cc",
"src/core/lib/compression/compression.cc",
"src/core/lib/compression/compression_internal.cc",
"src/core/lib/compression/message_compress.cc",
@@ -9181,11 +9211,14 @@
"src/core/lib/channel/channel_args.h",
"src/core/lib/channel/channel_stack.h",
"src/core/lib/channel/channel_stack_builder.h",
+ "src/core/lib/channel/channel_trace.h",
+ "src/core/lib/channel/channel_trace_registry.h",
"src/core/lib/channel/connected_channel.h",
"src/core/lib/channel/context.h",
"src/core/lib/channel/handshaker.h",
"src/core/lib/channel/handshaker_factory.h",
"src/core/lib/channel/handshaker_registry.h",
+ "src/core/lib/channel/status_util.h",
"src/core/lib/compression/algorithm_metadata.h",
"src/core/lib/compression/compression_internal.h",
"src/core/lib/compression/message_compress.h",
@@ -9327,11 +9360,14 @@
"src/core/lib/channel/channel_args.h",
"src/core/lib/channel/channel_stack.h",
"src/core/lib/channel/channel_stack_builder.h",
+ "src/core/lib/channel/channel_trace.h",
+ "src/core/lib/channel/channel_trace_registry.h",
"src/core/lib/channel/connected_channel.h",
"src/core/lib/channel/context.h",
"src/core/lib/channel/handshaker.h",
"src/core/lib/channel/handshaker_factory.h",
"src/core/lib/channel/handshaker_registry.h",
+ "src/core/lib/channel/status_util.h",
"src/core/lib/compression/algorithm_metadata.h",
"src/core/lib/compression/compression_internal.h",
"src/core/lib/compression/message_compress.h",
@@ -9479,7 +9515,6 @@
"src/core/ext/filters/client_channel/resolver_factory.h",
"src/core/ext/filters/client_channel/resolver_registry.h",
"src/core/ext/filters/client_channel/retry_throttle.h",
- "src/core/ext/filters/client_channel/status_util.h",
"src/core/ext/filters/client_channel/subchannel.h",
"src/core/ext/filters/client_channel/subchannel_index.h",
"src/core/ext/filters/client_channel/uri_parser.h"
@@ -9523,8 +9558,6 @@
"src/core/ext/filters/client_channel/resolver_registry.h",
"src/core/ext/filters/client_channel/retry_throttle.cc",
"src/core/ext/filters/client_channel/retry_throttle.h",
- "src/core/ext/filters/client_channel/status_util.cc",
- "src/core/ext/filters/client_channel/status_util.h",
"src/core/ext/filters/client_channel/subchannel.cc",
"src/core/ext/filters/client_channel/subchannel.h",
"src/core/ext/filters/client_channel/subchannel_index.cc",
@@ -10471,6 +10504,20 @@
"type": "filegroup"
},
{
+ "deps": [],
+ "headers": [
+ "src/proto/grpc/channelz/channelz.grpc.pb.h",
+ "src/proto/grpc/channelz/channelz.pb.h",
+ "src/proto/grpc/channelz/channelz_mock.grpc.pb.h"
+ ],
+ "is_filegroup": true,
+ "language": "c++",
+ "name": "grpc++_channelz_proto",
+ "src": [],
+ "third_party": false,
+ "type": "filegroup"
+ },
+ {
"deps": [
"grpc_codegen"
],
diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json
index 11f2b9a0dd..e703328ef1 100644
--- a/tools/run_tests/generated/tests.json
+++ b/tools/run_tests/generated/tests.json
@@ -3662,6 +3662,30 @@
"exclude_configs": [],
"exclude_iomgrs": [],
"flaky": false,
+ "gtest": true,
+ "language": "c++",
+ "name": "channel_trace_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "uses_polling": false
+ },
+ {
+ "args": [],
+ "benchmark": false,
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
"gtest": false,
"language": "c++",
"name": "check_gcp_environment_linux_test",