diff --git a/BUILD b/BUILD index eb4bc77f081..7cd081fb527 100644 --- a/BUILD +++ b/BUILD @@ -907,6 +907,7 @@ grpc_cc_library( ], visibility = ["@grpc:grpc++_public_hdrs"], deps = [ + "global_callback_hook", "grpc_public_hdrs", "//src/core:gpr_atm", ], @@ -951,6 +952,7 @@ grpc_cc_library( tags = ["nofixdeps"], visibility = ["@grpc:public"], deps = [ + "global_callback_hook", "grpc++_base", "//src/core:gpr_atm", "//src/core:slice", @@ -1260,6 +1262,7 @@ grpc_cc_library( deps = [ "channel_arg_names", "generic_stub_internal", + "global_callback_hook", "gpr", "grpc++_base_unsecure", "grpc++_codegen_proto", @@ -2455,6 +2458,7 @@ grpc_cc_library( "config", "exec_ctx", "generic_stub_internal", + "global_callback_hook", "gpr", "grpc", "grpc++_codegen_proto", @@ -2544,6 +2548,7 @@ grpc_cc_library( "config", "exec_ctx", "generic_stub_internal", + "global_callback_hook", "gpr", "grpc_base", "grpc_core_credentials_header", @@ -4913,6 +4918,22 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "global_callback_hook", + srcs = [ + "src/cpp/client/global_callback_hook.cc", + ], + hdrs = [ + "include/grpcpp/support/global_callback_hook.h", + ], + external_deps = [ + "absl/base:no_destructor", + "absl/log:check", + "absl/functional:function_ref", + ], + language = "c++", +) + # TODO(yashykt): Remove the UPB definitions from here once they are no longer needed ### UPB Targets diff --git a/CMakeLists.txt b/CMakeLists.txt index da48ca9f836..99a85a30376 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4182,6 +4182,7 @@ add_library(grpc++ src/cpp/client/create_channel.cc src/cpp/client/create_channel_internal.cc src/cpp/client/create_channel_posix.cc + src/cpp/client/global_callback_hook.cc src/cpp/client/insecure_credentials.cc src/cpp/client/secure_credentials.cc src/cpp/client/xds_credentials.cc @@ -4465,6 +4466,7 @@ foreach(_hdr include/grpcpp/support/client_callback.h include/grpcpp/support/client_interceptor.h include/grpcpp/support/config.h + include/grpcpp/support/global_callback_hook.h include/grpcpp/support/interceptor.h include/grpcpp/support/message_allocator.h include/grpcpp/support/method_handler.h @@ -4938,6 +4940,7 @@ add_library(grpc++_unsecure src/cpp/client/create_channel.cc src/cpp/client/create_channel_internal.cc src/cpp/client/create_channel_posix.cc + src/cpp/client/global_callback_hook.cc src/cpp/client/insecure_credentials.cc src/cpp/common/alarm.cc src/cpp/common/channel_arguments.cc @@ -5209,6 +5212,7 @@ foreach(_hdr include/grpcpp/support/client_callback.h include/grpcpp/support/client_interceptor.h include/grpcpp/support/config.h + include/grpcpp/support/global_callback_hook.h include/grpcpp/support/interceptor.h include/grpcpp/support/message_allocator.h include/grpcpp/support/method_handler.h @@ -8266,6 +8270,7 @@ add_executable(binder_transport_test src/cpp/client/create_channel.cc src/cpp/client/create_channel_internal.cc src/cpp/client/create_channel_posix.cc + src/cpp/client/global_callback_hook.cc src/cpp/client/insecure_credentials.cc src/cpp/client/secure_credentials.cc src/cpp/common/alarm.cc @@ -13405,6 +13410,7 @@ add_executable(endpoint_binder_pool_test src/cpp/client/create_channel.cc src/cpp/client/create_channel_internal.cc src/cpp/client/create_channel_posix.cc + src/cpp/client/global_callback_hook.cc src/cpp/client/insecure_credentials.cc src/cpp/client/secure_credentials.cc src/cpp/common/alarm.cc @@ -14260,6 +14266,7 @@ add_executable(fake_binder_test src/cpp/client/create_channel.cc src/cpp/client/create_channel_internal.cc src/cpp/client/create_channel_posix.cc + src/cpp/client/global_callback_hook.cc src/cpp/client/insecure_credentials.cc src/cpp/client/secure_credentials.cc src/cpp/common/alarm.cc @@ -32271,6 +32278,7 @@ add_executable(transport_stream_receiver_test src/cpp/client/create_channel.cc src/cpp/client/create_channel_internal.cc src/cpp/client/create_channel_posix.cc + src/cpp/client/global_callback_hook.cc src/cpp/client/insecure_credentials.cc src/cpp/client/secure_credentials.cc src/cpp/common/alarm.cc @@ -33157,6 +33165,7 @@ add_executable(wire_reader_test src/cpp/client/create_channel.cc src/cpp/client/create_channel_internal.cc src/cpp/client/create_channel_posix.cc + src/cpp/client/global_callback_hook.cc src/cpp/client/insecure_credentials.cc src/cpp/client/secure_credentials.cc src/cpp/common/alarm.cc @@ -33267,6 +33276,7 @@ add_executable(wire_writer_test src/cpp/client/create_channel.cc src/cpp/client/create_channel_internal.cc src/cpp/client/create_channel_posix.cc + src/cpp/client/global_callback_hook.cc src/cpp/client/insecure_credentials.cc src/cpp/client/secure_credentials.cc src/cpp/common/alarm.cc @@ -33847,6 +33857,7 @@ add_executable(xds_client_test ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/percent.grpc.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/percent.pb.h ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/percent.grpc.pb.h + src/cpp/client/global_callback_hook.cc src/cpp/util/status.cc test/core/xds/xds_client_test.cc test/core/xds/xds_transport_fake.cc @@ -34142,6 +34153,7 @@ add_executable(xds_cluster_resource_type_test ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/wrr_locality.grpc.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/wrr_locality.pb.h ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/wrr_locality.grpc.pb.h + src/cpp/client/global_callback_hook.cc src/cpp/util/status.cc test/core/xds/xds_cluster_resource_type_test.cc ) @@ -35138,6 +35150,7 @@ add_executable(xds_endpoint_resource_type_test ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/percent.grpc.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/percent.pb.h ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/percent.grpc.pb.h + src/cpp/client/global_callback_hook.cc src/cpp/util/status.cc test/core/xds/xds_endpoint_resource_type_test.cc ) diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index b95f89cafd6..abcef83cc2a 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -3836,6 +3836,7 @@ libs: - include/grpcpp/support/client_callback.h - include/grpcpp/support/client_interceptor.h - include/grpcpp/support/config.h + - include/grpcpp/support/global_callback_hook.h - include/grpcpp/support/interceptor.h - include/grpcpp/support/message_allocator.h - include/grpcpp/support/method_handler.h @@ -3915,6 +3916,7 @@ libs: - src/cpp/client/create_channel.cc - src/cpp/client/create_channel_internal.cc - src/cpp/client/create_channel_posix.cc + - src/cpp/client/global_callback_hook.cc - src/cpp/client/insecure_credentials.cc - src/cpp/client/secure_credentials.cc - src/cpp/client/xds_credentials.cc @@ -4267,6 +4269,7 @@ libs: - include/grpcpp/support/client_callback.h - include/grpcpp/support/client_interceptor.h - include/grpcpp/support/config.h + - include/grpcpp/support/global_callback_hook.h - include/grpcpp/support/interceptor.h - include/grpcpp/support/message_allocator.h - include/grpcpp/support/method_handler.h @@ -4303,6 +4306,7 @@ libs: - src/cpp/client/create_channel.cc - src/cpp/client/create_channel_internal.cc - src/cpp/client/create_channel_posix.cc + - src/cpp/client/global_callback_hook.cc - src/cpp/client/insecure_credentials.cc - src/cpp/common/alarm.cc - src/cpp/common/channel_arguments.cc @@ -6182,6 +6186,7 @@ targets: - src/cpp/client/create_channel.cc - src/cpp/client/create_channel_internal.cc - src/cpp/client/create_channel_posix.cc + - src/cpp/client/global_callback_hook.cc - src/cpp/client/insecure_credentials.cc - src/cpp/client/secure_credentials.cc - src/cpp/common/alarm.cc @@ -9668,6 +9673,7 @@ targets: - src/cpp/client/create_channel.cc - src/cpp/client/create_channel_internal.cc - src/cpp/client/create_channel_posix.cc + - src/cpp/client/global_callback_hook.cc - src/cpp/client/insecure_credentials.cc - src/cpp/client/secure_credentials.cc - src/cpp/common/alarm.cc @@ -10143,6 +10149,7 @@ targets: - src/cpp/client/create_channel.cc - src/cpp/client/create_channel_internal.cc - src/cpp/client/create_channel_posix.cc + - src/cpp/client/global_callback_hook.cc - src/cpp/client/insecure_credentials.cc - src/cpp/client/secure_credentials.cc - src/cpp/common/alarm.cc @@ -20379,6 +20386,7 @@ targets: - src/cpp/client/create_channel.cc - src/cpp/client/create_channel_internal.cc - src/cpp/client/create_channel_posix.cc + - src/cpp/client/global_callback_hook.cc - src/cpp/client/insecure_credentials.cc - src/cpp/client/secure_credentials.cc - src/cpp/common/alarm.cc @@ -20798,6 +20806,7 @@ targets: - src/cpp/client/create_channel.cc - src/cpp/client/create_channel_internal.cc - src/cpp/client/create_channel_posix.cc + - src/cpp/client/global_callback_hook.cc - src/cpp/client/insecure_credentials.cc - src/cpp/client/secure_credentials.cc - src/cpp/common/alarm.cc @@ -20909,6 +20918,7 @@ targets: - src/cpp/client/create_channel.cc - src/cpp/client/create_channel_internal.cc - src/cpp/client/create_channel_posix.cc + - src/cpp/client/global_callback_hook.cc - src/cpp/client/insecure_credentials.cc - src/cpp/client/secure_credentials.cc - src/cpp/common/alarm.cc @@ -21232,6 +21242,7 @@ targets: - src/proto/grpc/testing/xds/v3/base.proto - src/proto/grpc/testing/xds/v3/discovery.proto - src/proto/grpc/testing/xds/v3/percent.proto + - src/cpp/client/global_callback_hook.cc - src/cpp/util/status.cc - test/core/xds/xds_client_test.cc - test/core/xds/xds_transport_fake.cc @@ -21329,6 +21340,7 @@ targets: - src/proto/grpc/testing/xds/v3/tls.proto - src/proto/grpc/testing/xds/v3/typed_struct.proto - src/proto/grpc/testing/xds/v3/wrr_locality.proto + - src/cpp/client/global_callback_hook.cc - src/cpp/util/status.cc - test/core/xds/xds_cluster_resource_type_test.cc deps: @@ -21676,6 +21688,7 @@ targets: - src/proto/grpc/testing/xds/v3/endpoint.proto - src/proto/grpc/testing/xds/v3/health_check.proto - src/proto/grpc/testing/xds/v3/percent.proto + - src/cpp/client/global_callback_hook.cc - src/cpp/util/status.cc - test/core/xds/xds_endpoint_resource_type_test.cc deps: diff --git a/examples/cpp/helloworld/greeter_async_client.cc b/examples/cpp/helloworld/greeter_async_client.cc index 5d2fd7eb303..25417269085 100644 --- a/examples/cpp/helloworld/greeter_async_client.cc +++ b/examples/cpp/helloworld/greeter_async_client.cc @@ -24,7 +24,6 @@ #include "absl/flags/parse.h" #include "absl/log/check.h" -#include #include #ifdef BAZEL_BUILD diff --git a/examples/cpp/helloworld/greeter_async_client2.cc b/examples/cpp/helloworld/greeter_async_client2.cc index 65f18cb1014..83662761837 100644 --- a/examples/cpp/helloworld/greeter_async_client2.cc +++ b/examples/cpp/helloworld/greeter_async_client2.cc @@ -25,7 +25,6 @@ #include "absl/flags/parse.h" #include "absl/log/check.h" -#include #include #ifdef BAZEL_BUILD diff --git a/examples/cpp/helloworld/greeter_async_server.cc b/examples/cpp/helloworld/greeter_async_server.cc index 9ba22844e6d..9adefedf7d9 100644 --- a/examples/cpp/helloworld/greeter_async_server.cc +++ b/examples/cpp/helloworld/greeter_async_server.cc @@ -26,7 +26,6 @@ #include "absl/log/check.h" #include "absl/strings/str_format.h" -#include #include #ifdef BAZEL_BUILD diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index fe2176500b4..122a26ff39d 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -206,6 +206,7 @@ Pod::Spec.new do |s| 'include/grpcpp/support/client_callback.h', 'include/grpcpp/support/client_interceptor.h', 'include/grpcpp/support/config.h', + 'include/grpcpp/support/global_callback_hook.h', 'include/grpcpp/support/interceptor.h', 'include/grpcpp/support/message_allocator.h', 'include/grpcpp/support/method_handler.h', @@ -1378,6 +1379,7 @@ Pod::Spec.new do |s| 'src/cpp/client/create_channel_internal.cc', 'src/cpp/client/create_channel_internal.h', 'src/cpp/client/create_channel_posix.cc', + 'src/cpp/client/global_callback_hook.cc', 'src/cpp/client/insecure_credentials.cc', 'src/cpp/client/secure_credentials.cc', 'src/cpp/client/secure_credentials.h', diff --git a/grpc.def b/grpc.def index 4820cf14213..59bc8f2aa78 100644 --- a/grpc.def +++ b/grpc.def @@ -231,7 +231,6 @@ EXPORTS gpr_cpu_num_cores gpr_cpu_current_cpu gpr_log - absl_vlog2_enabled gpr_log_verbosity_init gpr_format_message gpr_strdup diff --git a/include/grpc/support/log.h b/include/grpc/support/log.h index 82e64a8c56f..d536bc85922 100644 --- a/include/grpc/support/log.h +++ b/include/grpc/support/log.h @@ -51,9 +51,6 @@ typedef enum gpr_log_severity { GPRAPI void gpr_log(const char* file, int line, gpr_log_severity severity, const char* format, ...) GPR_PRINT_FORMAT_CHECK(4, 5); -/** Deprecated. **/ -GPRAPI int absl_vlog2_enabled(); - GPRAPI void gpr_log_verbosity_init(void); #ifdef __cplusplus diff --git a/include/grpcpp/support/callback_common.h b/include/grpcpp/support/callback_common.h index 0de9cbcf050..a333407bb4e 100644 --- a/include/grpcpp/support/callback_common.h +++ b/include/grpcpp/support/callback_common.h @@ -30,6 +30,7 @@ #include #include #include +#include #include namespace grpc { @@ -127,7 +128,18 @@ class CallbackWithStatusTag : public grpc_completion_queue_functor { auto status = std::move(status_); func_ = nullptr; // reset to clear this out for sure status_ = Status(); // reset to clear this out for sure - CatchingCallback(std::move(func), std::move(status)); + GetGlobalCallbackHook()->RunCallback( + call_, [func = std::move(func), status = std::move(status)]() { +#if GRPC_ALLOW_EXCEPTIONS + try { + func(status); + } catch (...) { + // nothing to return or change here, just don't crash the library + } +#else // GRPC_ALLOW_EXCEPTIONS + func(status); +#endif // GRPC_ALLOW_EXCEPTIONS + }); grpc_call_unref(call_); } }; @@ -214,7 +226,17 @@ class CallbackWithSuccessTag : public grpc_completion_queue_functor { #endif if (do_callback) { - CatchingCallback(func_, ok); + GetGlobalCallbackHook()->RunCallback(call_, [this, ok]() { +#if GRPC_ALLOW_EXCEPTIONS + try { + func_(ok); + } catch (...) { + // nothing to return or change here, just don't crash the library + } +#else // GRPC_ALLOW_EXCEPTIONS + func_(ok); +#endif // GRPC_ALLOW_EXCEPTIONS + }); } } }; diff --git a/include/grpcpp/support/global_callback_hook.h b/include/grpcpp/support/global_callback_hook.h new file mode 100644 index 00000000000..c453bc807f4 --- /dev/null +++ b/include/grpcpp/support/global_callback_hook.h @@ -0,0 +1,58 @@ +// Copyright 2024 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef GRPCPP_SUPPORT_GLOBAL_CALLBACK_HOOK_H +#define GRPCPP_SUPPORT_GLOBAL_CALLBACK_HOOK_H + +#include "absl/functional/function_ref.h" + +struct grpc_call; + +namespace grpc { + +class GlobalCallbackHook { + public: + virtual ~GlobalCallbackHook() = default; + virtual void RunCallback(grpc_call* call, + absl::FunctionRef callback) = 0; + + protected: + // An exception-safe way of invoking a user-specified callback function. + template + void CatchingCallback(Func&& func, Args&&... args) { +#if GRPC_ALLOW_EXCEPTIONS + try { + func(std::forward(args)...); + } catch (...) { + // nothing to return or change here, just don't crash the library + } +#else // GRPC_ALLOW_EXCEPTIONS + func(std::forward(args)...); +#endif // GRPC_ALLOW_EXCEPTIONS + } +}; + +class DefaultGlobalCallbackHook final : public GlobalCallbackHook { + public: + void RunCallback(grpc_call* call, + absl::FunctionRef callback) override { + CatchingCallback(callback); + } +}; + +std::shared_ptr GetGlobalCallbackHook(); +void SetGlobalCallbackHook(GlobalCallbackHook* hook); +} // namespace grpc + +#endif // GRPCPP_SUPPORT_GLOBAL_CALLBACK_HOOK_H diff --git a/src/core/BUILD b/src/core/BUILD index e762447cfbc..d5a6c51183d 100644 --- a/src/core/BUILD +++ b/src/core/BUILD @@ -142,6 +142,8 @@ grpc_cc_library( "util/latent_see.h", ], external_deps = [ + "absl/base:core_headers", + "absl/functional:any_invocable", "absl/log", "absl/strings", "absl/types:optional", diff --git a/src/core/client_channel/retry_filter_legacy_call_data.cc b/src/core/client_channel/retry_filter_legacy_call_data.cc index f3b96a9d977..dd0267d7c5b 100644 --- a/src/core/client_channel/retry_filter_legacy_call_data.cc +++ b/src/core/client_channel/retry_filter_legacy_call_data.cc @@ -230,12 +230,11 @@ void RetryFilter::LegacyCallData::CallAttempt::MaybeSwitchToFastPath() { // yet seen that op from the surface, we can't switch yet. if (recv_trailing_metadata_internal_batch_ != nullptr) return; // Switch to fast path. - if (GRPC_TRACE_FLAG_ENABLED(retry)) { - LOG(INFO) << "chand=" << calld_->chand_ << " calld=" << calld_ - << " attempt=" << this - << ": retry state no longer needed; " - "moving LB call to parent and unreffing the call attempt"; - } + GRPC_TRACE_LOG(retry, INFO) + << "chand=" << calld_->chand_ << " calld=" << calld_ + << " attempt=" << this + << ": retry state no longer needed; " + "moving LB call to parent and unreffing the call attempt"; calld_->committed_call_ = std::move(lb_call_); calld_->call_attempt_.reset(DEBUG_LOCATION, "MaybeSwitchToFastPath"); } @@ -249,12 +248,10 @@ RetryFilter::LegacyCallData::CallAttempt::MaybeCreateBatchForReplay() { // send_initial_metadata. if (calld_->seen_send_initial_metadata_ && !started_send_initial_metadata_ && !calld_->pending_send_initial_metadata_) { - if (GRPC_TRACE_FLAG_ENABLED(retry)) { - LOG(INFO) << "chand=" << calld_->chand_ << " calld=" << calld_ - << " attempt=" << this - << ": replaying previously completed " - "send_initial_metadata op"; - } + GRPC_TRACE_LOG(retry, INFO) << "chand=" << calld_->chand_ + << " calld=" << calld_ << " attempt=" << this + << ": replaying previously completed " + "send_initial_metadata op"; replay_batch_data = CreateBatch(1, true /* set_on_complete */); replay_batch_data->AddRetriableSendInitialMetadataOp(); } @@ -263,12 +260,10 @@ RetryFilter::LegacyCallData::CallAttempt::MaybeCreateBatchForReplay() { if (started_send_message_count_ < calld_->send_messages_.size() && started_send_message_count_ == completed_send_message_count_ && !calld_->pending_send_message_) { - if (GRPC_TRACE_FLAG_ENABLED(retry)) { - LOG(INFO) << "chand=" << calld_->chand_ << " calld=" << calld_ - << " attempt=" << this - << ": replaying previously completed " - "send_message op"; - } + GRPC_TRACE_LOG(retry, INFO) << "chand=" << calld_->chand_ + << " calld=" << calld_ << " attempt=" << this + << ": replaying previously completed " + "send_message op"; if (replay_batch_data == nullptr) { replay_batch_data = CreateBatch(1, true /* set_on_complete */); } @@ -282,12 +277,10 @@ RetryFilter::LegacyCallData::CallAttempt::MaybeCreateBatchForReplay() { started_send_message_count_ == calld_->send_messages_.size() && !started_send_trailing_metadata_ && !calld_->pending_send_trailing_metadata_) { - if (GRPC_TRACE_FLAG_ENABLED(retry)) { - LOG(INFO) << "chand=" << calld_->chand_ << " calld=" << calld_ - << " attempt=" << this - << ": replaying previously completed " - "send_trailing_metadata op"; - } + GRPC_TRACE_LOG(retry, INFO) << "chand=" << calld_->chand_ + << " calld=" << calld_ << " attempt=" << this + << ": replaying previously completed " + "send_trailing_metadata op"; if (replay_batch_data == nullptr) { replay_batch_data = CreateBatch(1, true /* set_on_complete */); } @@ -325,12 +318,11 @@ void RetryFilter::LegacyCallData::CallAttempt::AddClosureForBatch( void RetryFilter::LegacyCallData::CallAttempt:: AddBatchForInternalRecvTrailingMetadata(CallCombinerClosureList* closures) { - if (GRPC_TRACE_FLAG_ENABLED(retry)) { - LOG(INFO) << "chand=" << calld_->chand_ << " calld=" << calld_ - << " attempt=" << this - << ": call failed but recv_trailing_metadata not started; " - "starting it internally"; - } + GRPC_TRACE_LOG(retry, INFO) + << "chand=" << calld_->chand_ << " calld=" << calld_ + << " attempt=" << this + << ": call failed but recv_trailing_metadata not started; " + "starting it internally"; // Create batch_data with 2 refs, since this batch will be unreffed twice: // once for the recv_trailing_metadata_ready callback when the batch // completes, and again when we actually get a recv_trailing_metadata @@ -556,12 +548,11 @@ bool RetryFilter::LegacyCallData::CallAttempt::ShouldRetry( } // Status is not OK. Check whether the status is retryable. if (!calld_->retry_policy_->retryable_status_codes().Contains(*status)) { - if (GRPC_TRACE_FLAG_ENABLED(retry)) { - LOG(INFO) << "chand=" << calld_->chand_ << " calld=" << calld_ - << " attempt=" << this << ": status " - << grpc_status_code_to_string(*status) - << " not configured as retryable"; - } + GRPC_TRACE_LOG(retry, INFO) + << "chand=" << calld_->chand_ << " calld=" << calld_ + << " attempt=" << this << ": status " + << grpc_status_code_to_string(*status) + << " not configured as retryable"; return false; } } @@ -651,14 +642,12 @@ void RetryFilter::LegacyCallData::CallAttempt::OnPerAttemptRecvTimerLocked( void* arg, grpc_error_handle error) { auto* call_attempt = static_cast(arg); auto* calld = call_attempt->calld_; - if (GRPC_TRACE_FLAG_ENABLED(retry)) { - LOG(INFO) << "chand=" << calld->chand_ << " calld=" << calld - << " attempt=" << call_attempt - << ": perAttemptRecvTimeout timer fired: error=" - << StatusToString(error) - << ", per_attempt_recv_timer_handle_.has_value()=" - << call_attempt->per_attempt_recv_timer_handle_.has_value(); - } + GRPC_TRACE_LOG(retry, INFO) + << "chand=" << calld->chand_ << " calld=" << calld + << " attempt=" << call_attempt + << ": perAttemptRecvTimeout timer fired: error=" << StatusToString(error) + << ", per_attempt_recv_timer_handle_.has_value()=" + << call_attempt->per_attempt_recv_timer_handle_.has_value(); CallCombinerClosureList closures; call_attempt->per_attempt_recv_timer_handle_.reset(); // Cancel this attempt. @@ -804,13 +793,10 @@ void RetryFilter::LegacyCallData::CallAttempt::BatchData:: RefCountedPtr batch_data(static_cast(arg)); CallAttempt* call_attempt = batch_data->call_attempt_; RetryFilter::LegacyCallData* calld = call_attempt->calld_; - if (GRPC_TRACE_FLAG_ENABLED(retry)) { - LOG(INFO) << "chand=" << calld->chand_ << " calld=" << calld - << " attempt=" << call_attempt - << " batch_data=" << batch_data.get() - << ": got recv_initial_metadata_ready, error=" - << StatusToString(error); - } + GRPC_TRACE_LOG(retry, INFO) + << "chand=" << calld->chand_ << " calld=" << calld + << " attempt=" << call_attempt << " batch_data=" << batch_data.get() + << ": got recv_initial_metadata_ready, error=" << StatusToString(error); call_attempt->completed_recv_initial_metadata_ = true; // If this attempt has been abandoned, then we're not going to use the // result of this recv_initial_metadata op, so do nothing. @@ -901,12 +887,10 @@ void RetryFilter::LegacyCallData::CallAttempt::BatchData::RecvMessageReady( RefCountedPtr batch_data(static_cast(arg)); CallAttempt* call_attempt = batch_data->call_attempt_; RetryFilter::LegacyCallData* calld = call_attempt->calld_; - if (GRPC_TRACE_FLAG_ENABLED(retry)) { - LOG(INFO) << "chand=" << calld->chand_ << " calld=" << calld - << " attempt=" << call_attempt - << " batch_data=" << batch_data.get() - << ": got recv_message_ready, error=" << StatusToString(error); - } + GRPC_TRACE_LOG(retry, INFO) + << "chand=" << calld->chand_ << " calld=" << calld + << " attempt=" << call_attempt << " batch_data=" << batch_data.get() + << ": got recv_message_ready, error=" << StatusToString(error); ++call_attempt->completed_recv_message_count_; // If this attempt has been abandoned, then we're not going to use the // result of this recv_message op, so do nothing. @@ -930,12 +914,11 @@ void RetryFilter::LegacyCallData::CallAttempt::BatchData::RecvMessageReady( if (GPR_UNLIKELY( (!call_attempt->recv_message_.has_value() || !error.ok()) && !call_attempt->completed_recv_trailing_metadata_)) { - if (GRPC_TRACE_FLAG_ENABLED(retry)) { - LOG(INFO) << "chand=" << calld->chand_ << " calld=" << calld - << " attempt=" << call_attempt - << ": deferring recv_message_ready (nullptr message and " - "recv_trailing_metadata pending)"; - } + GRPC_TRACE_LOG(retry, INFO) + << "chand=" << calld->chand_ << " calld=" << calld + << " attempt=" << call_attempt + << ": deferring recv_message_ready (nullptr message and " + "recv_trailing_metadata pending)"; call_attempt->recv_message_ready_deferred_batch_ = std::move(batch_data); call_attempt->recv_message_error_ = error; CallCombinerClosureList closures; @@ -1094,13 +1077,10 @@ void RetryFilter::LegacyCallData::CallAttempt::BatchData:: RefCountedPtr batch_data(static_cast(arg)); CallAttempt* call_attempt = batch_data->call_attempt_; RetryFilter::LegacyCallData* calld = call_attempt->calld_; - if (GRPC_TRACE_FLAG_ENABLED(retry)) { - LOG(INFO) << "chand=" << calld->chand_ << " calld=" << calld - << " attempt=" << call_attempt - << " batch_data=" << batch_data.get() - << ": got recv_trailing_metadata_ready, error=" - << StatusToString(error); - } + GRPC_TRACE_LOG(retry, INFO) + << "chand=" << calld->chand_ << " calld=" << calld + << " attempt=" << call_attempt << " batch_data=" << batch_data.get() + << ": got recv_trailing_metadata_ready, error=" << StatusToString(error); call_attempt->completed_recv_trailing_metadata_ = true; // If this attempt has been abandoned, then we're not going to use the // result of this recv_trailing_metadata op, so do nothing. @@ -1121,17 +1101,15 @@ void RetryFilter::LegacyCallData::CallAttempt::BatchData:: batch_data->batch_.payload->recv_trailing_metadata.recv_trailing_metadata; GetCallStatus(calld->deadline_, md_batch, error, &status, &server_pushback, &is_lb_drop, &stream_network_state); - if (GRPC_TRACE_FLAG_ENABLED(retry)) { - LOG(INFO) << "chand=" << calld->chand_ << " calld=" << calld - << " attempt=" << call_attempt << ": call finished, status=" - << grpc_status_code_to_string(status) << " server_pushback=" - << (server_pushback.has_value() ? server_pushback->ToString() - : "N/A") - << " is_lb_drop=" << is_lb_drop << " stream_network_state=" - << (stream_network_state.has_value() - ? absl::StrCat(*stream_network_state) - : "N/A"); - } + GRPC_TRACE_LOG(retry, INFO) + << "chand=" << calld->chand_ << " calld=" << calld + << " attempt=" << call_attempt + << ": call finished, status=" << grpc_status_code_to_string(status) + << " server_pushback=" + << (server_pushback.has_value() ? server_pushback->ToString() : "N/A") + << " is_lb_drop=" << is_lb_drop << " stream_network_state=" + << (stream_network_state.has_value() ? absl::StrCat(*stream_network_state) + : "N/A"); // Check if we should retry. if (!is_lb_drop) { // Never retry on LB drops. enum { kNoRetry, kTransparentRetry, kConfigurableRetry } retry = kNoRetry; @@ -1253,15 +1231,11 @@ void RetryFilter::LegacyCallData::CallAttempt::BatchData::OnComplete( RefCountedPtr batch_data(static_cast(arg)); CallAttempt* call_attempt = batch_data->call_attempt_; RetryFilter::LegacyCallData* calld = call_attempt->calld_; - if (GRPC_TRACE_FLAG_ENABLED(retry)) { - LOG(INFO) << "chand=" << calld->chand_ << " calld=" << calld - << " attempt=" << call_attempt - << " batch_data=" << batch_data.get() - << ": got on_complete, error=" << StatusToString(error) - << ", batch=" - << grpc_transport_stream_op_batch_string(&batch_data->batch_, - false); - } + GRPC_TRACE_LOG(retry, INFO) + << "chand=" << calld->chand_ << " calld=" << calld + << " attempt=" << call_attempt << " batch_data=" << batch_data.get() + << ": got on_complete, error=" << StatusToString(error) << ", batch=" + << grpc_transport_stream_op_batch_string(&batch_data->batch_, false); // If this attempt has been abandoned, then we're not going to propagate // the completion of this batch, so do nothing. if (call_attempt->abandoned_) { @@ -1328,15 +1302,12 @@ void RetryFilter::LegacyCallData::CallAttempt::BatchData::OnCompleteForCancelOp( RefCountedPtr batch_data(static_cast(arg)); CallAttempt* call_attempt = batch_data->call_attempt_; RetryFilter::LegacyCallData* calld = call_attempt->calld_; - if (GRPC_TRACE_FLAG_ENABLED(retry)) { - LOG(INFO) << "chand=" << calld->chand_ << " calld=" << calld - << " attempt=" << call_attempt - << " batch_data=" << batch_data.get() - << ": got on_complete for cancel_stream batch, error=" - << StatusToString(error) << ", batch=" - << grpc_transport_stream_op_batch_string(&batch_data->batch_, - false); - } + GRPC_TRACE_LOG(retry, INFO) + << "chand=" << calld->chand_ << " calld=" << calld + << " attempt=" << call_attempt << " batch_data=" << batch_data.get() + << ": got on_complete for cancel_stream batch, error=" + << StatusToString(error) << ", batch=" + << grpc_transport_stream_op_batch_string(&batch_data->batch_, false); GRPC_CALL_COMBINER_STOP( calld->call_combiner_, "on_complete for internally generated cancel_stream op"); @@ -1371,12 +1342,10 @@ void RetryFilter::LegacyCallData::CallAttempt::BatchData:: void RetryFilter::LegacyCallData::CallAttempt::BatchData:: AddRetriableSendMessageOp() { auto* calld = call_attempt_->calld_; - if (GRPC_TRACE_FLAG_ENABLED(retry)) { - LOG(INFO) << "chand=" << calld->chand_ << " calld=" << calld - << " attempt=" << call_attempt_ - << ": starting calld->send_messages[" - << call_attempt_->started_send_message_count_ << "]"; - } + GRPC_TRACE_LOG(retry, INFO) + << "chand=" << calld->chand_ << " calld=" << calld + << " attempt=" << call_attempt_ << ": starting calld->send_messages[" + << call_attempt_->started_send_message_count_ << "]"; CachedSendMessage cache = calld->send_messages_[call_attempt_->started_send_message_count_]; ++call_attempt_->started_send_message_count_; diff --git a/src/core/client_channel/subchannel.cc b/src/core/client_channel/subchannel.cc index 5a313c9646b..35ec507c4d2 100644 --- a/src/core/client_channel/subchannel.cc +++ b/src/core/client_channel/subchannel.cc @@ -417,12 +417,11 @@ class Subchannel::ConnectedSubchannelStateWatcher final if (c->connected_subchannel_ == nullptr) return; if (new_state == GRPC_CHANNEL_TRANSIENT_FAILURE || new_state == GRPC_CHANNEL_SHUTDOWN) { - if (GRPC_TRACE_FLAG_ENABLED(subchannel)) { - LOG(INFO) << "subchannel " << c << " " << c->key_.ToString() - << ": Connected subchannel " - << c->connected_subchannel_.get() << " reports " - << ConnectivityStateName(new_state) << ": " << status; - } + GRPC_TRACE_LOG(subchannel, INFO) + << "subchannel " << c << " " << c->key_.ToString() + << ": Connected subchannel " << c->connected_subchannel_.get() + << " reports " << ConnectivityStateName(new_state) << ": " + << status; c->connected_subchannel_.reset(); if (c->channelz_node() != nullptr) { c->channelz_node()->SetChildSocket(nullptr); @@ -803,12 +802,10 @@ void Subchannel::OnConnectingFinishedLocked(grpc_error_handle error) { if (connecting_result_.transport == nullptr || !PublishTransportLocked()) { const Duration time_until_next_attempt = next_attempt_time_ - Timestamp::Now(); - if (GRPC_TRACE_FLAG_ENABLED(subchannel)) { - LOG(INFO) << "subchannel " << this << " " << key_.ToString() - << ": connect failed (" << StatusToString(error) - << "), backing off for " << time_until_next_attempt.millis() - << " ms"; - } + GRPC_TRACE_LOG(subchannel, INFO) + << "subchannel " << this << " " << key_.ToString() + << ": connect failed (" << StatusToString(error) + << "), backing off for " << time_until_next_attempt.millis() << " ms"; SetConnectivityStateLocked(GRPC_CHANNEL_TRANSIENT_FAILURE, grpc_error_to_absl_status(error)); retry_timer_handle_ = event_engine_->RunAfter( diff --git a/src/core/ext/transport/chaotic_good/chaotic_good_transport.h b/src/core/ext/transport/chaotic_good/chaotic_good_transport.h index 903b8024a6f..b3df1ceb1e6 100644 --- a/src/core/ext/transport/chaotic_good/chaotic_good_transport.h +++ b/src/core/ext/transport/chaotic_good/chaotic_good_transport.h @@ -56,12 +56,11 @@ class ChaoticGoodTransport : public RefCounted { bool saw_encoding_errors = false; auto buffers = frame.Serialize(&encoder_, saw_encoding_errors); // ignore encoding errors: they will be logged separately already - if (GRPC_TRACE_FLAG_ENABLED(chaotic_good)) { - LOG(INFO) << "CHAOTIC_GOOD: WriteFrame to:" - << ResolvedAddressToString(control_endpoint_.GetPeerAddress()) - .value_or("<>") - << " " << frame.ToString(); - } + GRPC_TRACE_LOG(chaotic_good, INFO) + << "CHAOTIC_GOOD: WriteFrame to:" + << ResolvedAddressToString(control_endpoint_.GetPeerAddress()) + .value_or("<>") + << " " << frame.ToString(); return TryJoin( control_endpoint_.Write(std::move(buffers.control)), data_endpoint_.Write(std::move(buffers.data))); @@ -76,15 +75,13 @@ class ChaoticGoodTransport : public RefCounted { auto frame_header = FrameHeader::Parse(reinterpret_cast( GRPC_SLICE_START_PTR(read_buffer.c_slice()))); - if (GRPC_TRACE_FLAG_ENABLED(chaotic_good)) { - LOG(INFO) << "CHAOTIC_GOOD: ReadHeader from:" - << ResolvedAddressToString( - control_endpoint_.GetPeerAddress()) - .value_or("<>") - << " " - << (frame_header.ok() ? frame_header->ToString() - : frame_header.status().ToString()); - } + GRPC_TRACE_LOG(chaotic_good, INFO) + << "CHAOTIC_GOOD: ReadHeader from:" + << ResolvedAddressToString(control_endpoint_.GetPeerAddress()) + .value_or("<>") + << " " + << (frame_header.ok() ? frame_header->ToString() + : frame_header.status().ToString()); // Read header and trailers from control endpoint. // Read message padding and message from data endpoint. return If( diff --git a/src/core/ext/transport/chaotic_good/frame.cc b/src/core/ext/transport/chaotic_good/frame.cc index 4a165e9aa89..243d8ef4ca2 100644 --- a/src/core/ext/transport/chaotic_good/frame.cc +++ b/src/core/ext/transport/chaotic_good/frame.cc @@ -25,7 +25,6 @@ #include "absl/status/statusor.h" #include -#include #include #include "src/core/ext/transport/chaotic_good/frame_header.h" diff --git a/src/core/ext/transport/chaotic_good/frame_header.cc b/src/core/ext/transport/chaotic_good/frame_header.cc index b4c27074ce1..903e4646419 100644 --- a/src/core/ext/transport/chaotic_good/frame_header.cc +++ b/src/core/ext/transport/chaotic_good/frame_header.cc @@ -19,7 +19,6 @@ #include "absl/status/status.h" #include "absl/strings/str_cat.h" -#include #include namespace grpc_core { diff --git a/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc b/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc index 43549036622..f13ec98eae7 100644 --- a/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc +++ b/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc @@ -300,12 +300,10 @@ auto ChaoticGoodServerListener::ActiveConnection::HandshakingState:: }, [self](PromiseEndpoint ret) -> absl::Status { MutexLock lock(&self->connection_->listener_->mu_); - if (GRPC_TRACE_FLAG_ENABLED(chaotic_good)) { - LOG(INFO) << self->connection_.get() - << " Data endpoint setup done: shutdown=" - << (self->connection_->listener_->shutdown_ ? "true" - : "false"); - } + GRPC_TRACE_LOG(chaotic_good, INFO) + << self->connection_.get() + << " Data endpoint setup done: shutdown=" + << (self->connection_->listener_->shutdown_ ? "true" : "false"); if (self->connection_->listener_->shutdown_) { return absl::UnavailableError("Server shutdown"); } diff --git a/src/core/ext/transport/chttp2/alpn/alpn.cc b/src/core/ext/transport/chttp2/alpn/alpn.cc index cb9c2d6e34d..75f17402335 100644 --- a/src/core/ext/transport/chttp2/alpn/alpn.cc +++ b/src/core/ext/transport/chttp2/alpn/alpn.cc @@ -20,7 +20,6 @@ #include "absl/log/check.h" -#include #include #include "src/core/util/useful.h" diff --git a/src/core/ext/transport/chttp2/transport/bin_encoder.cc b/src/core/ext/transport/chttp2/transport/bin_encoder.cc index cf024f03d49..4063d1d5491 100644 --- a/src/core/ext/transport/chttp2/transport/bin_encoder.cc +++ b/src/core/ext/transport/chttp2/transport/bin_encoder.cc @@ -23,7 +23,6 @@ #include "absl/log/check.h" -#include #include #include "src/core/ext/transport/chttp2/transport/huffsyms.h" diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 5c48b14746c..94d45f56637 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -1362,6 +1362,241 @@ static void log_metadata(const grpc_metadata_batch* md_batch, uint32_t id, }); } +static void send_initial_metadata_locked( + grpc_transport_stream_op_batch* op, grpc_chttp2_stream* s, + grpc_transport_stream_op_batch_payload* op_payload, + grpc_chttp2_transport* t, grpc_closure* on_complete) { + if (!grpc_core::IsCallTracerInTransportEnabled()) { + if (s->call_tracer != nullptr) { + s->call_tracer->RecordAnnotation( + grpc_core::HttpAnnotation(grpc_core::HttpAnnotation::Type::kStart, + gpr_now(GPR_CLOCK_REALTIME)) + .Add(s->t->flow_control.stats()) + .Add(s->flow_control.stats())); + } + } else if (grpc_core::IsTraceRecordCallopsEnabled()) { + auto* call_tracer = s->arena->GetContext(); + if (call_tracer != nullptr && call_tracer->IsSampled()) { + call_tracer->RecordAnnotation( + grpc_core::HttpAnnotation(grpc_core::HttpAnnotation::Type::kStart, + gpr_now(GPR_CLOCK_REALTIME)) + .Add(s->t->flow_control.stats()) + .Add(s->flow_control.stats())); + } + } + if (t->is_client && t->channelz_socket != nullptr) { + t->channelz_socket->RecordStreamStartedFromLocal(); + } + CHECK_EQ(s->send_initial_metadata_finished, nullptr); + on_complete->next_data.scratch |= t->closure_barrier_may_cover_write; + + s->send_initial_metadata_finished = add_closure_barrier(on_complete); + s->send_initial_metadata = + op_payload->send_initial_metadata.send_initial_metadata; + if (t->is_client) { + s->deadline = + std::min(s->deadline, + s->send_initial_metadata->get(grpc_core::GrpcTimeoutMetadata()) + .value_or(grpc_core::Timestamp::InfFuture())); + } + if (contains_non_ok_status(s->send_initial_metadata)) { + s->seen_error = true; + } + if (!s->write_closed) { + if (t->is_client) { + if (t->closed_with_error.ok()) { + CHECK_EQ(s->id, 0u); + grpc_chttp2_list_add_waiting_for_concurrency(t, s); + maybe_start_some_streams(t); + } else { + s->trailing_metadata_buffer.Set( + grpc_core::GrpcStreamNetworkState(), + grpc_core::GrpcStreamNetworkState::kNotSentOnWire); + grpc_chttp2_cancel_stream( + t, s, + grpc_error_set_int( + GRPC_ERROR_CREATE_REFERENCING("Transport closed", + &t->closed_with_error, 1), + grpc_core::StatusIntProperty::kRpcStatus, + GRPC_STATUS_UNAVAILABLE), + false); + } + } else { + CHECK_NE(s->id, 0u); + grpc_chttp2_mark_stream_writable(t, s); + if (!(op->send_message && + (op->payload->send_message.flags & GRPC_WRITE_BUFFER_HINT))) { + grpc_chttp2_initiate_write( + t, GRPC_CHTTP2_INITIATE_WRITE_SEND_INITIAL_METADATA); + } + } + } else { + s->send_initial_metadata = nullptr; + grpc_chttp2_complete_closure_step( + t, &s->send_initial_metadata_finished, + GRPC_ERROR_CREATE_REFERENCING( + "Attempt to send initial metadata after stream was closed", + &s->write_closed_error, 1), + "send_initial_metadata_finished"); + } +} + +static void send_message_locked( + grpc_transport_stream_op_batch* op, grpc_chttp2_stream* s, + grpc_transport_stream_op_batch_payload* op_payload, + grpc_chttp2_transport* t, grpc_closure* on_complete) { + t->num_messages_in_next_write++; + grpc_core::global_stats().IncrementHttp2SendMessageSize( + op->payload->send_message.send_message->Length()); + on_complete->next_data.scratch |= t->closure_barrier_may_cover_write; + s->send_message_finished = add_closure_barrier(op->on_complete); + const uint32_t flags = op_payload->send_message.flags; + if (s->write_closed) { + op->payload->send_message.stream_write_closed = true; + // We should NOT return an error here, so as to avoid a cancel OP being + // started. The surface layer will notice that the stream has been closed + // for writes and fail the send message op. + grpc_chttp2_complete_closure_step(t, &s->send_message_finished, + absl::OkStatus(), + "fetching_send_message_finished"); + } else { + uint8_t* frame_hdr = grpc_slice_buffer_tiny_add(&s->flow_controlled_buffer, + GRPC_HEADER_SIZE_IN_BYTES); + frame_hdr[0] = (flags & GRPC_WRITE_INTERNAL_COMPRESS) != 0; + size_t len = op_payload->send_message.send_message->Length(); + frame_hdr[1] = static_cast(len >> 24); + frame_hdr[2] = static_cast(len >> 16); + frame_hdr[3] = static_cast(len >> 8); + frame_hdr[4] = static_cast(len); + + s->call_tracer_wrapper.RecordOutgoingBytes( + {GRPC_HEADER_SIZE_IN_BYTES, len, 0}); + s->next_message_end_offset = + s->flow_controlled_bytes_written + + static_cast(s->flow_controlled_buffer.length) + + static_cast(len); + if (flags & GRPC_WRITE_BUFFER_HINT) { + s->next_message_end_offset -= t->write_buffer_size; + s->write_buffering = true; + } else { + s->write_buffering = false; + } + + grpc_slice* const slices = + op_payload->send_message.send_message->c_slice_buffer()->slices; + grpc_slice* const end = + slices + op_payload->send_message.send_message->Count(); + for (grpc_slice* slice = slices; slice != end; slice++) { + grpc_slice_buffer_add(&s->flow_controlled_buffer, + grpc_core::CSliceRef(*slice)); + } + + int64_t notify_offset = s->next_message_end_offset; + if (notify_offset <= s->flow_controlled_bytes_written) { + grpc_chttp2_complete_closure_step(t, &s->send_message_finished, + absl::OkStatus(), + "fetching_send_message_finished"); + } else { + grpc_chttp2_write_cb* cb = t->write_cb_pool; + if (cb == nullptr) { + cb = static_cast(gpr_malloc(sizeof(*cb))); + } else { + t->write_cb_pool = cb->next; + } + cb->call_at_byte = notify_offset; + cb->closure = s->send_message_finished; + s->send_message_finished = nullptr; + grpc_chttp2_write_cb** list = flags & GRPC_WRITE_THROUGH + ? &s->on_write_finished_cbs + : &s->on_flow_controlled_cbs; + cb->next = *list; + *list = cb; + } + + if (s->id != 0 && (!s->write_buffering || s->flow_controlled_buffer.length > + t->write_buffer_size)) { + grpc_chttp2_mark_stream_writable(t, s); + grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_SEND_MESSAGE); + } + } +} + +static void send_trailing_metadata_locked( + grpc_transport_stream_op_batch* op, grpc_chttp2_stream* s, + grpc_transport_stream_op_batch_payload* op_payload, + grpc_chttp2_transport* t, grpc_closure* on_complete) { + CHECK_EQ(s->send_trailing_metadata_finished, nullptr); + on_complete->next_data.scratch |= t->closure_barrier_may_cover_write; + s->send_trailing_metadata_finished = add_closure_barrier(on_complete); + s->send_trailing_metadata = + op_payload->send_trailing_metadata.send_trailing_metadata; + s->sent_trailing_metadata_op = op_payload->send_trailing_metadata.sent; + s->write_buffering = false; + if (contains_non_ok_status(s->send_trailing_metadata)) { + s->seen_error = true; + } + if (s->write_closed) { + s->send_trailing_metadata = nullptr; + s->sent_trailing_metadata_op = nullptr; + grpc_chttp2_complete_closure_step( + t, &s->send_trailing_metadata_finished, + op->payload->send_trailing_metadata.send_trailing_metadata->empty() + ? absl::OkStatus() + : GRPC_ERROR_CREATE("Attempt to send trailing metadata after " + "stream was closed"), + "send_trailing_metadata_finished"); + } else if (s->id != 0) { + // TODO(ctiller): check if there's flow control for any outstanding + // bytes before going writable + grpc_chttp2_mark_stream_writable(t, s); + grpc_chttp2_initiate_write( + t, GRPC_CHTTP2_INITIATE_WRITE_SEND_TRAILING_METADATA); + } +} + +static void recv_initial_metadata_locked( + grpc_chttp2_stream* s, grpc_transport_stream_op_batch_payload* op_payload, + grpc_chttp2_transport* t) { + CHECK_EQ(s->recv_initial_metadata_ready, nullptr); + s->recv_initial_metadata_ready = + op_payload->recv_initial_metadata.recv_initial_metadata_ready; + s->recv_initial_metadata = + op_payload->recv_initial_metadata.recv_initial_metadata; + s->trailing_metadata_available = + op_payload->recv_initial_metadata.trailing_metadata_available; + if (s->parsed_trailers_only && s->trailing_metadata_available != nullptr) { + *s->trailing_metadata_available = true; + } + grpc_chttp2_maybe_complete_recv_initial_metadata(t, s); +} + +static void recv_message_locked( + grpc_chttp2_stream* s, grpc_transport_stream_op_batch_payload* op_payload, + grpc_chttp2_transport* t) { + CHECK_EQ(s->recv_message_ready, nullptr); + s->recv_message_ready = op_payload->recv_message.recv_message_ready; + s->recv_message = op_payload->recv_message.recv_message; + s->recv_message->emplace(); + s->recv_message_flags = op_payload->recv_message.flags; + s->call_failed_before_recv_message = + op_payload->recv_message.call_failed_before_recv_message; + grpc_chttp2_maybe_complete_recv_trailing_metadata(t, s); +} + +static void recv_trailing_metadata_locked( + grpc_chttp2_stream* s, grpc_transport_stream_op_batch_payload* op_payload, + grpc_chttp2_transport* t) { + CHECK_EQ(s->collecting_stats, nullptr); + s->collecting_stats = op_payload->recv_trailing_metadata.collect_stats; + CHECK_EQ(s->recv_trailing_metadata_finished, nullptr); + s->recv_trailing_metadata_finished = + op_payload->recv_trailing_metadata.recv_trailing_metadata_ready; + s->recv_trailing_metadata = + op_payload->recv_trailing_metadata.recv_trailing_metadata; + s->final_metadata_requested = true; + grpc_chttp2_maybe_complete_recv_trailing_metadata(t, s); +} + static void perform_stream_op_locked(void* stream_op, grpc_error_handle /*error_ignored*/) { grpc_transport_stream_op_batch* op = @@ -1405,225 +1640,27 @@ static void perform_stream_op_locked(void* stream_op, } if (op->send_initial_metadata) { - if (!grpc_core::IsCallTracerInTransportEnabled()) { - if (s->call_tracer != nullptr) { - s->call_tracer->RecordAnnotation( - grpc_core::HttpAnnotation(grpc_core::HttpAnnotation::Type::kStart, - gpr_now(GPR_CLOCK_REALTIME)) - .Add(s->t->flow_control.stats()) - .Add(s->flow_control.stats())); - } - } else if (grpc_core::IsTraceRecordCallopsEnabled()) { - auto* call_tracer = - s->arena->GetContext(); - if (call_tracer != nullptr && call_tracer->IsSampled()) { - call_tracer->RecordAnnotation( - grpc_core::HttpAnnotation(grpc_core::HttpAnnotation::Type::kStart, - gpr_now(GPR_CLOCK_REALTIME)) - .Add(s->t->flow_control.stats()) - .Add(s->flow_control.stats())); - } - } - if (t->is_client && t->channelz_socket != nullptr) { - t->channelz_socket->RecordStreamStartedFromLocal(); - } - CHECK_EQ(s->send_initial_metadata_finished, nullptr); - on_complete->next_data.scratch |= t->closure_barrier_may_cover_write; - - s->send_initial_metadata_finished = add_closure_barrier(on_complete); - s->send_initial_metadata = - op_payload->send_initial_metadata.send_initial_metadata; - if (t->is_client) { - s->deadline = std::min( - s->deadline, - s->send_initial_metadata->get(grpc_core::GrpcTimeoutMetadata()) - .value_or(grpc_core::Timestamp::InfFuture())); - } - if (contains_non_ok_status(s->send_initial_metadata)) { - s->seen_error = true; - } - if (!s->write_closed) { - if (t->is_client) { - if (t->closed_with_error.ok()) { - CHECK_EQ(s->id, 0u); - grpc_chttp2_list_add_waiting_for_concurrency(t, s); - maybe_start_some_streams(t); - } else { - s->trailing_metadata_buffer.Set( - grpc_core::GrpcStreamNetworkState(), - grpc_core::GrpcStreamNetworkState::kNotSentOnWire); - grpc_chttp2_cancel_stream( - t, s, - grpc_error_set_int( - GRPC_ERROR_CREATE_REFERENCING("Transport closed", - &t->closed_with_error, 1), - grpc_core::StatusIntProperty::kRpcStatus, - GRPC_STATUS_UNAVAILABLE), - false); - } - } else { - CHECK_NE(s->id, 0u); - grpc_chttp2_mark_stream_writable(t, s); - if (!(op->send_message && - (op->payload->send_message.flags & GRPC_WRITE_BUFFER_HINT))) { - grpc_chttp2_initiate_write( - t, GRPC_CHTTP2_INITIATE_WRITE_SEND_INITIAL_METADATA); - } - } - } else { - s->send_initial_metadata = nullptr; - grpc_chttp2_complete_closure_step( - t, &s->send_initial_metadata_finished, - GRPC_ERROR_CREATE_REFERENCING( - "Attempt to send initial metadata after stream was closed", - &s->write_closed_error, 1), - "send_initial_metadata_finished"); - } + send_initial_metadata_locked(op, s, op_payload, t, on_complete); } if (op->send_message) { - t->num_messages_in_next_write++; - grpc_core::global_stats().IncrementHttp2SendMessageSize( - op->payload->send_message.send_message->Length()); - on_complete->next_data.scratch |= t->closure_barrier_may_cover_write; - s->send_message_finished = add_closure_barrier(op->on_complete); - const uint32_t flags = op_payload->send_message.flags; - if (s->write_closed) { - op->payload->send_message.stream_write_closed = true; - // We should NOT return an error here, so as to avoid a cancel OP being - // started. The surface layer will notice that the stream has been closed - // for writes and fail the send message op. - grpc_chttp2_complete_closure_step(t, &s->send_message_finished, - absl::OkStatus(), - "fetching_send_message_finished"); - } else { - uint8_t* frame_hdr = grpc_slice_buffer_tiny_add( - &s->flow_controlled_buffer, GRPC_HEADER_SIZE_IN_BYTES); - frame_hdr[0] = (flags & GRPC_WRITE_INTERNAL_COMPRESS) != 0; - size_t len = op_payload->send_message.send_message->Length(); - frame_hdr[1] = static_cast(len >> 24); - frame_hdr[2] = static_cast(len >> 16); - frame_hdr[3] = static_cast(len >> 8); - frame_hdr[4] = static_cast(len); - - s->call_tracer_wrapper.RecordOutgoingBytes( - {GRPC_HEADER_SIZE_IN_BYTES, len, 0}); - s->next_message_end_offset = - s->flow_controlled_bytes_written + - static_cast(s->flow_controlled_buffer.length) + - static_cast(len); - if (flags & GRPC_WRITE_BUFFER_HINT) { - s->next_message_end_offset -= t->write_buffer_size; - s->write_buffering = true; - } else { - s->write_buffering = false; - } - - grpc_slice* const slices = - op_payload->send_message.send_message->c_slice_buffer()->slices; - grpc_slice* const end = - slices + op_payload->send_message.send_message->Count(); - for (grpc_slice* slice = slices; slice != end; slice++) { - grpc_slice_buffer_add(&s->flow_controlled_buffer, - grpc_core::CSliceRef(*slice)); - } - - int64_t notify_offset = s->next_message_end_offset; - if (notify_offset <= s->flow_controlled_bytes_written) { - grpc_chttp2_complete_closure_step(t, &s->send_message_finished, - absl::OkStatus(), - "fetching_send_message_finished"); - } else { - grpc_chttp2_write_cb* cb = t->write_cb_pool; - if (cb == nullptr) { - cb = static_cast(gpr_malloc(sizeof(*cb))); - } else { - t->write_cb_pool = cb->next; - } - cb->call_at_byte = notify_offset; - cb->closure = s->send_message_finished; - s->send_message_finished = nullptr; - grpc_chttp2_write_cb** list = flags & GRPC_WRITE_THROUGH - ? &s->on_write_finished_cbs - : &s->on_flow_controlled_cbs; - cb->next = *list; - *list = cb; - } - - if (s->id != 0 && - (!s->write_buffering || - s->flow_controlled_buffer.length > t->write_buffer_size)) { - grpc_chttp2_mark_stream_writable(t, s); - grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_SEND_MESSAGE); - } - } + send_message_locked(op, s, op_payload, t, on_complete); } if (op->send_trailing_metadata) { - CHECK_EQ(s->send_trailing_metadata_finished, nullptr); - on_complete->next_data.scratch |= t->closure_barrier_may_cover_write; - s->send_trailing_metadata_finished = add_closure_barrier(on_complete); - s->send_trailing_metadata = - op_payload->send_trailing_metadata.send_trailing_metadata; - s->sent_trailing_metadata_op = op_payload->send_trailing_metadata.sent; - s->write_buffering = false; - if (contains_non_ok_status(s->send_trailing_metadata)) { - s->seen_error = true; - } - if (s->write_closed) { - s->send_trailing_metadata = nullptr; - s->sent_trailing_metadata_op = nullptr; - grpc_chttp2_complete_closure_step( - t, &s->send_trailing_metadata_finished, - op->payload->send_trailing_metadata.send_trailing_metadata->empty() - ? absl::OkStatus() - : GRPC_ERROR_CREATE("Attempt to send trailing metadata after " - "stream was closed"), - "send_trailing_metadata_finished"); - } else if (s->id != 0) { - // TODO(ctiller): check if there's flow control for any outstanding - // bytes before going writable - grpc_chttp2_mark_stream_writable(t, s); - grpc_chttp2_initiate_write( - t, GRPC_CHTTP2_INITIATE_WRITE_SEND_TRAILING_METADATA); - } + send_trailing_metadata_locked(op, s, op_payload, t, on_complete); } if (op->recv_initial_metadata) { - CHECK_EQ(s->recv_initial_metadata_ready, nullptr); - s->recv_initial_metadata_ready = - op_payload->recv_initial_metadata.recv_initial_metadata_ready; - s->recv_initial_metadata = - op_payload->recv_initial_metadata.recv_initial_metadata; - s->trailing_metadata_available = - op_payload->recv_initial_metadata.trailing_metadata_available; - if (s->parsed_trailers_only && s->trailing_metadata_available != nullptr) { - *s->trailing_metadata_available = true; - } - grpc_chttp2_maybe_complete_recv_initial_metadata(t, s); + recv_initial_metadata_locked(s, op_payload, t); } if (op->recv_message) { - CHECK_EQ(s->recv_message_ready, nullptr); - s->recv_message_ready = op_payload->recv_message.recv_message_ready; - s->recv_message = op_payload->recv_message.recv_message; - s->recv_message->emplace(); - s->recv_message_flags = op_payload->recv_message.flags; - s->call_failed_before_recv_message = - op_payload->recv_message.call_failed_before_recv_message; - grpc_chttp2_maybe_complete_recv_trailing_metadata(t, s); + recv_message_locked(s, op_payload, t); } if (op->recv_trailing_metadata) { - CHECK_EQ(s->collecting_stats, nullptr); - s->collecting_stats = op_payload->recv_trailing_metadata.collect_stats; - CHECK_EQ(s->recv_trailing_metadata_finished, nullptr); - s->recv_trailing_metadata_finished = - op_payload->recv_trailing_metadata.recv_trailing_metadata_ready; - s->recv_trailing_metadata = - op_payload->recv_trailing_metadata.recv_trailing_metadata; - s->final_metadata_requested = true; - grpc_chttp2_maybe_complete_recv_trailing_metadata(t, s); + recv_trailing_metadata_locked(s, op_payload, t); } if (on_complete != nullptr) { diff --git a/src/core/ext/transport/chttp2/transport/frame.cc b/src/core/ext/transport/chttp2/transport/frame.cc index 9e05cf6d854..92788903f15 100644 --- a/src/core/ext/transport/chttp2/transport/frame.cc +++ b/src/core/ext/transport/chttp2/transport/frame.cc @@ -23,7 +23,6 @@ #include "absl/status/status.h" #include "absl/strings/str_cat.h" -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_data.cc b/src/core/ext/transport/chttp2/transport/frame_data.cc index e16965c4478..77739c30883 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.cc +++ b/src/core/ext/transport/chttp2/transport/frame_data.cc @@ -25,7 +25,6 @@ #include "absl/strings/str_format.h" #include -#include #include #include "src/core/ext/transport/chttp2/transport/internal.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_goaway.cc b/src/core/ext/transport/chttp2/transport/frame_goaway.cc index fadce901392..31e7c76ba39 100644 --- a/src/core/ext/transport/chttp2/transport/frame_goaway.cc +++ b/src/core/ext/transport/chttp2/transport/frame_goaway.cc @@ -28,7 +28,6 @@ #include #include -#include #include #include "src/core/ext/transport/chttp2/transport/internal.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.cc b/src/core/ext/transport/chttp2/transport/frame_settings.cc index ebf74b21142..e0a12218cab 100644 --- a/src/core/ext/transport/chttp2/transport/frame_settings.cc +++ b/src/core/ext/transport/chttp2/transport/frame_settings.cc @@ -187,12 +187,11 @@ grpc_error_handle grpc_chttp2_settings_parser_parse(void* p, "invalid value %u passed for %s", parser->value, grpc_core::Http2Settings::WireIdToName(parser->id).c_str())); } - if (GRPC_TRACE_FLAG_ENABLED(http)) { - LOG(INFO) << "CHTTP2:" << (t->is_client ? "CLI" : "SVR") << ":" - << t->peer_string.as_string_view() << ": got setting " - << grpc_core::Http2Settings::WireIdToName(parser->id) - << " = " << parser->value; - } + GRPC_TRACE_LOG(http, INFO) + << "CHTTP2:" << (t->is_client ? "CLI" : "SVR") << ":" + << t->peer_string.as_string_view() << ": got setting " + << grpc_core::Http2Settings::WireIdToName(parser->id) << " = " + << parser->value; } break; } } diff --git a/src/core/ext/transport/chttp2/transport/frame_window_update.cc b/src/core/ext/transport/chttp2/transport/frame_window_update.cc index efae1615eb9..6dafd5318b2 100644 --- a/src/core/ext/transport/chttp2/transport/frame_window_update.cc +++ b/src/core/ext/transport/chttp2/transport/frame_window_update.cc @@ -25,7 +25,6 @@ #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" -#include #include #include "src/core/ext/transport/chttp2/transport/flow_control.h" diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc b/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc index 3492fd5982b..143781dca32 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc @@ -18,7 +18,6 @@ #include "absl/log/check.h" -#include #include namespace grpc_core { diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc index 070294b2cf4..919e8473c68 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.cc +++ b/src/core/ext/transport/chttp2/transport/parsing.cc @@ -331,13 +331,11 @@ absl::variant grpc_chttp2_perform_read( case GRPC_DTS_FH_8: DCHECK_LT(cur, end); t->incoming_stream_id |= (static_cast(*cur)); - if (GRPC_TRACE_FLAG_ENABLED(http)) { - LOG(INFO) << "INCOMING[" << t << "]: " - << FrameTypeString(t->incoming_frame_type, - t->incoming_frame_flags) - << " len:" << t->incoming_frame_size - << absl::StrFormat(" id:0x%08x", t->incoming_stream_id); - } + GRPC_TRACE_LOG(http, INFO) + << "INCOMING[" << t << "]: " + << FrameTypeString(t->incoming_frame_type, t->incoming_frame_flags) + << " len:" << t->incoming_frame_size + << absl::StrFormat(" id:0x%08x", t->incoming_stream_id); t->deframe_state = GRPC_DTS_FRAME; err = init_frame_parser(t, requests_started); if (!err.ok()) { @@ -453,10 +451,9 @@ static grpc_error_handle init_frame_parser(grpc_chttp2_transport* t, case GRPC_CHTTP2_FRAME_GOAWAY: return init_goaway_parser(t); default: - if (GRPC_TRACE_FLAG_ENABLED(http)) { - LOG(ERROR) << "Unknown frame type " - << absl::StrFormat("%02x", t->incoming_frame_type); - } + GRPC_TRACE_LOG(http, ERROR) + << "Unknown frame type " + << absl::StrFormat("%02x", t->incoming_frame_type); return init_non_header_skip_frame_parser(t); } } @@ -790,10 +787,8 @@ static grpc_error_handle init_window_update_frame_parser( grpc_chttp2_stream* s = t->incoming_stream = grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id); if (s == nullptr) { - if (GRPC_TRACE_FLAG_ENABLED(http)) { - LOG(ERROR) << "Stream " << t->incoming_stream_id - << " not found, ignoring WINDOW_UPDATE"; - } + GRPC_TRACE_LOG(http, ERROR) << "Stream " << t->incoming_stream_id + << " not found, ignoring WINDOW_UPDATE"; return init_non_header_skip_frame_parser(t); } s->call_tracer_wrapper.RecordIncomingBytes({9, 0, 0}); diff --git a/src/core/ext/transport/chttp2/transport/ping_callbacks.cc b/src/core/ext/transport/chttp2/transport/ping_callbacks.cc index b568ad860a7..4bd16e1fbb4 100644 --- a/src/core/ext/transport/chttp2/transport/ping_callbacks.cc +++ b/src/core/ext/transport/chttp2/transport/ping_callbacks.cc @@ -20,7 +20,6 @@ #include "absl/meta/type_traits.h" #include "absl/random/distributions.h" -#include #include namespace grpc_core { diff --git a/src/core/ext/transport/chttp2/transport/write_size_policy.cc b/src/core/ext/transport/chttp2/transport/write_size_policy.cc index f8ec481d7fe..63e8d2b7e25 100644 --- a/src/core/ext/transport/chttp2/transport/write_size_policy.cc +++ b/src/core/ext/transport/chttp2/transport/write_size_policy.cc @@ -18,7 +18,6 @@ #include "absl/log/check.h" -#include #include namespace grpc_core { diff --git a/src/core/ext/transport/cronet/transport/cronet_api_phony.cc b/src/core/ext/transport/cronet/transport/cronet_api_phony.cc index 57afb811468..f0befc2faa1 100644 --- a/src/core/ext/transport/cronet/transport/cronet_api_phony.cc +++ b/src/core/ext/transport/cronet/transport/cronet_api_phony.cc @@ -22,7 +22,6 @@ #include "absl/log/check.h" #include "third_party/objective_c/Cronet/bidirectional_stream_c.h" -#include #include #ifdef GRPC_COMPILE_WITH_CRONET diff --git a/src/core/handshaker/handshaker.cc b/src/core/handshaker/handshaker.cc index 263628cab01..3949dccbe59 100644 --- a/src/core/handshaker/handshaker.cc +++ b/src/core/handshaker/handshaker.cc @@ -166,12 +166,10 @@ void HandshakeManager::CallNextHandshakerLocked(absl::Status error) { error = GRPC_ERROR_CREATE("handshaker shutdown"); args_.endpoint.reset(); } - if (GRPC_TRACE_FLAG_ENABLED(handshaker)) { - LOG(INFO) << "handshake_manager " << this - << ": handshaking complete -- scheduling " - "on_handshake_done with error=" - << error; - } + GRPC_TRACE_LOG(handshaker, INFO) << "handshake_manager " << this + << ": handshaking complete -- scheduling " + "on_handshake_done with error=" + << error; // Cancel deadline timer, since we're invoking the on_handshake_done // callback now. args_.event_engine->Cancel(deadline_timer_handle_); diff --git a/src/core/lib/channel/channel_stack.cc b/src/core/lib/channel/channel_stack.cc index 36e3461700a..2590ab4590d 100644 --- a/src/core/lib/channel/channel_stack.cc +++ b/src/core/lib/channel/channel_stack.cc @@ -26,7 +26,6 @@ #include "absl/log/check.h" #include "absl/log/log.h" -#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/src/core/lib/channel/channel_stack_builder_impl.cc b/src/core/lib/channel/channel_stack_builder_impl.cc index 7db444474e9..a5d93d81edc 100644 --- a/src/core/lib/channel/channel_stack_builder_impl.cc +++ b/src/core/lib/channel/channel_stack_builder_impl.cc @@ -33,7 +33,6 @@ #include "absl/strings/str_cat.h" #include -#include #include #include "src/core/lib/channel/channel_fwd.h" diff --git a/src/core/lib/channel/connected_channel.cc b/src/core/lib/channel/connected_channel.cc index f24304bac89..9977ecdabfe 100644 --- a/src/core/lib/channel/connected_channel.cc +++ b/src/core/lib/channel/connected_channel.cc @@ -34,7 +34,6 @@ #include #include #include -#include #include #include "src/core/lib/channel/call_finalization.h" diff --git a/src/core/lib/channel/promise_based_filter.cc b/src/core/lib/channel/promise_based_filter.cc index 6af8436b187..e1253c702be 100644 --- a/src/core/lib/channel/promise_based_filter.cc +++ b/src/core/lib/channel/promise_based_filter.cc @@ -468,13 +468,12 @@ void BaseCallData::SendMessage::Done(const ServerMetadata& metadata, void BaseCallData::SendMessage::WakeInsideCombiner(Flusher* flusher, bool allow_push_to_pipe) { - if (GRPC_TRACE_FLAG_ENABLED(channel)) { - LOG(INFO) << base_->LogTag() - << " SendMessage.WakeInsideCombiner st=" << StateString(state_) - << (state_ == State::kBatchCompleted - ? absl::StrCat(" status=", completed_status_.ToString()) - : ""); - } + GRPC_TRACE_LOG(channel, INFO) + << base_->LogTag() + << " SendMessage.WakeInsideCombiner st=" << StateString(state_) + << (state_ == State::kBatchCompleted + ? absl::StrCat(" status=", completed_status_.ToString()) + : ""); switch (state_) { case State::kInitial: case State::kIdle: @@ -502,12 +501,11 @@ void BaseCallData::SendMessage::WakeInsideCombiner(Flusher* flusher, CHECK(push_.has_value()); auto r_push = (*push_)(); if (auto* p = r_push.value_if_ready()) { - if (GRPC_TRACE_FLAG_ENABLED(channel)) { - LOG(INFO) << base_->LogTag() - << " SendMessage.WakeInsideCombiner push complete, " - "result=" - << (*p ? "true" : "false"); - } + GRPC_TRACE_LOG(channel, INFO) + << base_->LogTag() + << " SendMessage.WakeInsideCombiner push complete, " + "result=" + << (*p ? "true" : "false"); // We haven't pulled through yet, so this certainly shouldn't succeed. CHECK(!*p); state_ = State::kCancelled; @@ -517,12 +515,11 @@ void BaseCallData::SendMessage::WakeInsideCombiner(Flusher* flusher, CHECK(next_.has_value()); auto r_next = (*next_)(); if (auto* p = r_next.value_if_ready()) { - if (GRPC_TRACE_FLAG_ENABLED(channel)) { - LOG(INFO) << base_->LogTag() - << " SendMessage.WakeInsideCombiner next complete, " - "result.has_value=" - << (p->has_value() ? "true" : "false"); - } + GRPC_TRACE_LOG(channel, INFO) + << base_->LogTag() + << " SendMessage.WakeInsideCombiner next complete, " + "result.has_value=" + << (p->has_value() ? "true" : "false"); if (p->has_value()) { batch_->payload->send_message.send_message->Swap((**p)->payload()); batch_->payload->send_message.flags = (**p)->flags(); @@ -774,13 +771,12 @@ void BaseCallData::ReceiveMessage::Done(const ServerMetadata& metadata, void BaseCallData::ReceiveMessage::WakeInsideCombiner(Flusher* flusher, bool allow_push_to_pipe) { - if (GRPC_TRACE_FLAG_ENABLED(channel)) { - LOG(INFO) << base_->LogTag() - << " ReceiveMessage.WakeInsideCombiner st=" << StateString(state_) - << " push?=" << (push_.has_value() ? "yes" : "no") - << " next?=" << (next_.has_value() ? "yes" : "no") - << " allow_push_to_pipe=" << (allow_push_to_pipe ? "yes" : "no"); - } + GRPC_TRACE_LOG(channel, INFO) + << base_->LogTag() + << " ReceiveMessage.WakeInsideCombiner st=" << StateString(state_) + << " push?=" << (push_.has_value() ? "yes" : "no") + << " next?=" << (next_.has_value() ? "yes" : "no") + << " allow_push_to_pipe=" << (allow_push_to_pipe ? "yes" : "no"); switch (state_) { case State::kInitial: case State::kIdle: @@ -865,12 +861,11 @@ void BaseCallData::ReceiveMessage::WakeInsideCombiner(Flusher* flusher, p->cancelled() ? absl::CancelledError() : absl::OkStatus(), "recv_message"); } - if (GRPC_TRACE_FLAG_ENABLED(channel)) { - LOG(INFO) << base_->LogTag() - << " ReceiveMessage.WakeInsideCombiner next complete: " - << (p->has_value() ? "got message" : "end of stream") - << " new_state=" << StateString(state_); - } + GRPC_TRACE_LOG(channel, INFO) + << base_->LogTag() + << " ReceiveMessage.WakeInsideCombiner next complete: " + << (p->has_value() ? "got message" : "end of stream") + << " new_state=" << StateString(state_); } if (state_ != State::kPulledFromPipe && state_ != State::kCompletedWhilePulledFromPipe) { @@ -1079,15 +1074,14 @@ class ClientCallData::PollContext { case SendInitialState::kForwarded: { // Poll the promise once since we're waiting for it. Poll poll = self_->promise_(); - if (GRPC_TRACE_FLAG_ENABLED(channel)) { - LOG(INFO) << self_->LogTag() - << " ClientCallData.PollContext.Run: poll=" - << PollToString(poll, - [](const ServerMetadataHandle& h) { - return h->DebugString(); - }) - << "; " << self_->DebugString(); - } + GRPC_TRACE_LOG(channel, INFO) + << self_->LogTag() << " ClientCallData.PollContext.Run: poll=" + << PollToString(poll, + [](const ServerMetadataHandle& h) { + return h->DebugString(); + }) + << "; " << self_->DebugString(); + if (auto* r = poll.value_if_ready()) { auto md = std::move(*r); if (self_->send_message() != nullptr) { @@ -1749,12 +1743,10 @@ void ClientCallData::RecvTrailingMetadataReadyCallback( void ClientCallData::RecvTrailingMetadataReady(grpc_error_handle error) { Flusher flusher(this); - if (GRPC_TRACE_FLAG_ENABLED(channel)) { - LOG(INFO) << LogTag() << " ClientCallData.RecvTrailingMetadataReady " - << "recv_trailing_state=" << StateString(recv_trailing_state_) - << " error=" << error - << " md=" << recv_trailing_metadata_->DebugString(); - } + GRPC_TRACE_LOG(channel, INFO) + << LogTag() << " ClientCallData.RecvTrailingMetadataReady " + << "recv_trailing_state=" << StateString(recv_trailing_state_) + << " error=" << error << " md=" << recv_trailing_metadata_->DebugString(); // If we were cancelled prior to receiving this callback, we should simply // forward the callback up with the same error. if (recv_trailing_state_ == RecvTrailingState::kCancelled) { @@ -2422,34 +2414,30 @@ void ServerCallData::WakeInsideCombiner(Flusher* flusher) { if (promise_.has_value()) { Poll poll; poll = promise_(); - if (GRPC_TRACE_FLAG_ENABLED(channel)) { - LOG(INFO) << LogTag() << ": WakeInsideCombiner poll=" - << PollToString(poll, - [](const ServerMetadataHandle& h) { - return h->DebugString(); - }) - .c_str() - << "; send_initial_metadata=" - << (send_initial_metadata_ == nullptr - ? "null" - : SendInitialMetadata::StateString( - send_initial_metadata_->state)) - << " send_trailing_metadata=" - << StateString(send_trailing_state_); - } + GRPC_TRACE_LOG(channel, INFO) + << LogTag() << ": WakeInsideCombiner poll=" + << PollToString( + poll, + [](const ServerMetadataHandle& h) { return h->DebugString(); }) + .c_str() + << "; send_initial_metadata=" + << (send_initial_metadata_ == nullptr + ? "null" + : SendInitialMetadata::StateString( + send_initial_metadata_->state)) + << " send_trailing_metadata=" << StateString(send_trailing_state_); + if (send_initial_metadata_ != nullptr && send_initial_metadata_->state == SendInitialMetadata::kQueuedAndPushedToPipe) { CHECK(send_initial_metadata_->metadata_next_.has_value()); auto p = (*send_initial_metadata_->metadata_next_)(); - if (GRPC_TRACE_FLAG_ENABLED(channel)) { - LOG(INFO) << LogTag() - << ": WakeInsideCombiner send_initial_metadata poll=" - << PollToString( - p, [](const NextResult& h) { - return (*h)->DebugString(); - }); - } + GRPC_TRACE_LOG(channel, INFO) + << LogTag() << ": WakeInsideCombiner send_initial_metadata poll=" + << PollToString(p, [](const NextResult& h) { + return (*h)->DebugString(); + }); + if (auto* nr = p.value_if_ready()) { ServerMetadataHandle md = std::move(nr->value()); if (send_initial_metadata_->batch->payload->send_initial_metadata diff --git a/src/core/lib/compression/compression_internal.cc b/src/core/lib/compression/compression_internal.cc index 6a2883f4883..c643b1cd817 100644 --- a/src/core/lib/compression/compression_internal.cc +++ b/src/core/lib/compression/compression_internal.cc @@ -29,7 +29,6 @@ #include "absl/strings/str_split.h" #include -#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/src/core/lib/config/core_configuration.cc b/src/core/lib/config/core_configuration.cc index 7baa803bb47..474ec3b56c4 100644 --- a/src/core/lib/config/core_configuration.cc +++ b/src/core/lib/config/core_configuration.cc @@ -20,7 +20,6 @@ #include "absl/log/check.h" -#include #include namespace grpc_core { diff --git a/src/core/lib/debug/event_log.cc b/src/core/lib/debug/event_log.cc index 76edac8584b..48dbb5809a8 100644 --- a/src/core/lib/debug/event_log.cc +++ b/src/core/lib/debug/event_log.cc @@ -21,7 +21,6 @@ #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" -#include #include namespace grpc_core { diff --git a/src/core/lib/event_engine/ares_resolver.cc b/src/core/lib/event_engine/ares_resolver.cc index 9824408dc4e..1cd7c73f54e 100644 --- a/src/core/lib/event_engine/ares_resolver.cc +++ b/src/core/lib/event_engine/ares_resolver.cc @@ -61,7 +61,6 @@ #include "absl/types/optional.h" #include -#include #include "src/core/lib/address_utils/parse_address.h" #include "src/core/lib/address_utils/sockaddr_utils.h" diff --git a/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc b/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc index 47e67d8e4a4..4721437860b 100644 --- a/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +++ b/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc @@ -335,9 +335,18 @@ void CFStreamEndpointImpl::DoWrite( continue; } - size_t written_size = + CFIndex written_size = CFWriteStreamWrite(cf_write_stream_, slice.begin(), slice.size()); + if (written_size < 0) { + auto status = CFErrorToStatus(CFWriteStreamCopyError(cf_write_stream_)); + GRPC_TRACE_LOG(event_engine_endpoint, INFO) + << "CFStream write error: " << status + << ", written_size: " << written_size; + on_writable(status); + return; + } + total_written_size += written_size; if (written_size < slice.size()) { SliceBuffer written; diff --git a/src/core/lib/event_engine/forkable.cc b/src/core/lib/event_engine/forkable.cc index c096ceb7782..0034cbbd92e 100644 --- a/src/core/lib/event_engine/forkable.cc +++ b/src/core/lib/event_engine/forkable.cc @@ -16,7 +16,6 @@ #include "absl/log/check.h" -#include #include #ifdef GRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK diff --git a/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc b/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc index 3f383e663bd..e573be30642 100644 --- a/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +++ b/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc @@ -30,7 +30,6 @@ #include #include -#include #include #include #include diff --git a/src/core/lib/event_engine/posix_engine/lockfree_event.cc b/src/core/lib/event_engine/posix_engine/lockfree_event.cc index f95969bc69c..dc7900646a0 100644 --- a/src/core/lib/event_engine/posix_engine/lockfree_event.cc +++ b/src/core/lib/event_engine/posix_engine/lockfree_event.cc @@ -20,7 +20,6 @@ #include "absl/status/status.h" #include -#include #include #include "src/core/lib/event_engine/posix_engine/event_poller.h" diff --git a/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc b/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc index 1171cb76624..d4cdfac8b7f 100644 --- a/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc +++ b/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc @@ -24,7 +24,6 @@ #include "absl/functional/any_invocable.h" #include "absl/log/log.h" -#include #include #include diff --git a/src/core/lib/event_engine/resolved_address.cc b/src/core/lib/event_engine/resolved_address.cc index d6e01da006c..95c37586ae2 100644 --- a/src/core/lib/event_engine/resolved_address.cc +++ b/src/core/lib/event_engine/resolved_address.cc @@ -19,7 +19,6 @@ #include "absl/log/check.h" #include -#include #include #include "src/core/lib/event_engine/resolved_address_internal.h" diff --git a/src/core/lib/event_engine/slice.cc b/src/core/lib/event_engine/slice.cc index 51563f4a0c5..7d4a6c4a051 100644 --- a/src/core/lib/event_engine/slice.cc +++ b/src/core/lib/event_engine/slice.cc @@ -23,7 +23,6 @@ #include #include -#include #include #include "src/core/lib/slice/slice_internal.h" diff --git a/src/core/lib/event_engine/thread_pool/thread_count.cc b/src/core/lib/event_engine/thread_pool/thread_count.cc index 9148b1a5d23..6fc6a43c213 100644 --- a/src/core/lib/event_engine/thread_pool/thread_count.cc +++ b/src/core/lib/event_engine/thread_pool/thread_count.cc @@ -23,7 +23,6 @@ #include "absl/time/clock.h" #include "absl/time/time.h" -#include #include #include "src/core/lib/gprpp/time.h" diff --git a/src/core/lib/gprpp/host_port.cc b/src/core/lib/gprpp/host_port.cc index 7e5ae646ca7..fec43151109 100644 --- a/src/core/lib/gprpp/host_port.cc +++ b/src/core/lib/gprpp/host_port.cc @@ -24,7 +24,6 @@ #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" -#include #include namespace grpc_core { diff --git a/src/core/lib/gprpp/load_file.cc b/src/core/lib/gprpp/load_file.cc index 01cb7798de2..dd15004570a 100644 --- a/src/core/lib/gprpp/load_file.cc +++ b/src/core/lib/gprpp/load_file.cc @@ -24,7 +24,6 @@ #include #include -#include #include namespace grpc_core { diff --git a/src/core/lib/gprpp/status_helper.cc b/src/core/lib/gprpp/status_helper.cc index a2a5160e2f1..b3563592b55 100644 --- a/src/core/lib/gprpp/status_helper.cc +++ b/src/core/lib/gprpp/status_helper.cc @@ -35,7 +35,6 @@ #include "upb/base/string_view.h" #include "upb/mem/arena.hpp" -#include #include #include "src/core/lib/slice/percent_encoding.h" diff --git a/src/core/lib/gprpp/time_util.cc b/src/core/lib/gprpp/time_util.cc index 3a1cd376370..94ca4e08d88 100644 --- a/src/core/lib/gprpp/time_util.cc +++ b/src/core/lib/gprpp/time_util.cc @@ -21,7 +21,6 @@ #include "absl/log/check.h" -#include #include #include diff --git a/src/core/lib/gprpp/windows/directory_reader.cc b/src/core/lib/gprpp/windows/directory_reader.cc index 3d45ee6532d..2deedb8ca5a 100644 --- a/src/core/lib/gprpp/windows/directory_reader.cc +++ b/src/core/lib/gprpp/windows/directory_reader.cc @@ -30,8 +30,6 @@ #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include - #include "src/core/lib/gprpp/directory_reader.h" namespace grpc_core { diff --git a/src/core/lib/gprpp/windows/thd.cc b/src/core/lib/gprpp/windows/thd.cc index b5c6368cf40..1e754e916b9 100644 --- a/src/core/lib/gprpp/windows/thd.cc +++ b/src/core/lib/gprpp/windows/thd.cc @@ -27,7 +27,6 @@ #include "absl/log/log.h" #include -#include #include #include #include diff --git a/src/core/lib/iomgr/buffer_list.cc b/src/core/lib/iomgr/buffer_list.cc index aedb4227073..dd59b4e7d49 100644 --- a/src/core/lib/iomgr/buffer_list.cc +++ b/src/core/lib/iomgr/buffer_list.cc @@ -20,7 +20,6 @@ #include "absl/log/log.h" -#include #include #include diff --git a/src/core/lib/iomgr/call_combiner.h b/src/core/lib/iomgr/call_combiner.h index d2c7c0c9851..87ad024880f 100644 --- a/src/core/lib/iomgr/call_combiner.h +++ b/src/core/lib/iomgr/call_combiner.h @@ -166,14 +166,12 @@ class CallCombinerClosureList { GRPC_CALL_COMBINER_START(call_combiner, closure.closure, closure.error, closure.reason); } - if (GRPC_TRACE_FLAG_ENABLED(call_combiner)) { - LOG(INFO) << "CallCombinerClosureList executing closure while already " - "holding call_combiner " - << call_combiner - << ": closure=" << closures_[0].closure->DebugString() - << " error=" << StatusToString(closures_[0].error) - << " reason=" << closures_[0].reason; - } + GRPC_TRACE_LOG(call_combiner, INFO) + << "CallCombinerClosureList executing closure while already " + "holding call_combiner " + << call_combiner << ": closure=" << closures_[0].closure->DebugString() + << " error=" << StatusToString(closures_[0].error) + << " reason=" << closures_[0].reason; // This will release the call combiner. ExecCtx::Run(DEBUG_LOCATION, closures_[0].closure, closures_[0].error); closures_.clear(); diff --git a/src/core/lib/iomgr/endpoint_pair_posix.cc b/src/core/lib/iomgr/endpoint_pair_posix.cc index 42d0e7acdb6..4043f9a8120 100644 --- a/src/core/lib/iomgr/endpoint_pair_posix.cc +++ b/src/core/lib/iomgr/endpoint_pair_posix.cc @@ -34,7 +34,6 @@ #include "absl/strings/str_cat.h" #include -#include #include "src/core/lib/event_engine/channel_args_endpoint_config.h" #include "src/core/lib/gprpp/crash.h" diff --git a/src/core/lib/iomgr/ev_epoll1_linux.cc b/src/core/lib/iomgr/ev_epoll1_linux.cc index 278e544bb79..f3c4ad1decf 100644 --- a/src/core/lib/iomgr/ev_epoll1_linux.cc +++ b/src/core/lib/iomgr/ev_epoll1_linux.cc @@ -831,12 +831,11 @@ static bool begin_worker(grpc_pollset* pollset, grpc_pollset_worker* worker, grpc_core::ExecCtx::Get()->InvalidateNow(); } - if (GRPC_TRACE_FLAG_ENABLED(polling)) { - LOG(INFO) << "PS:" << pollset << " BEGIN_DONE:" << worker - << " kick_state=" << kick_state_string(worker->state) - << " shutdown=" << pollset->shutting_down - << " kicked_without_poller: " << pollset->kicked_without_poller; - } + GRPC_TRACE_LOG(polling, INFO) + << "PS:" << pollset << " BEGIN_DONE:" << worker + << " kick_state=" << kick_state_string(worker->state) + << " shutdown=" << pollset->shutting_down + << " kicked_without_poller: " << pollset->kicked_without_poller; // We release pollset lock in this function at a couple of places: // 1. Briefly when assigning pollset to a neighborhood diff --git a/src/core/lib/iomgr/ev_poll_posix.cc b/src/core/lib/iomgr/ev_poll_posix.cc index 9d0728a97d0..a2e8e7a083e 100644 --- a/src/core/lib/iomgr/ev_poll_posix.cc +++ b/src/core/lib/iomgr/ev_poll_posix.cc @@ -1062,12 +1062,11 @@ static grpc_error_handle pollset_work(grpc_pollset* pollset, } fd_end_poll(&watchers[i], 0, 0); } else { - if (GRPC_TRACE_FLAG_ENABLED(polling)) { - LOG(INFO) << pollset << " got_event: " << pfds[i].fd - << " r:" << ((pfds[i].revents & POLLIN_CHECK) != 0) - << " w:" << ((pfds[i].revents & POLLOUT_CHECK) != 0) - << " [" << pfds[i].revents << "]"; - } + GRPC_TRACE_LOG(polling, INFO) + << pollset << " got_event: " << pfds[i].fd + << " r:" << ((pfds[i].revents & POLLIN_CHECK) != 0) + << " w:" << ((pfds[i].revents & POLLOUT_CHECK) != 0) << " [" + << pfds[i].revents << "]"; // This is a mitigation to prevent poll() from spinning on a //* POLLHUP https://github.com/grpc/grpc/pull/13665 // diff --git a/src/core/lib/iomgr/ev_posix.cc b/src/core/lib/iomgr/ev_posix.cc index d23c976ca46..70ee372c4fd 100644 --- a/src/core/lib/iomgr/ev_posix.cc +++ b/src/core/lib/iomgr/ev_posix.cc @@ -30,7 +30,6 @@ #include "absl/strings/str_split.h" #include -#include #include #include "src/core/lib/config/config_vars.h" diff --git a/src/core/lib/iomgr/executor.cc b/src/core/lib/iomgr/executor.cc index a47d80acc3e..02f21cf796b 100644 --- a/src/core/lib/iomgr/executor.cc +++ b/src/core/lib/iomgr/executor.cc @@ -26,7 +26,6 @@ #include #include -#include #include #include diff --git a/src/core/lib/iomgr/fork_windows.cc b/src/core/lib/iomgr/fork_windows.cc index 0e1583173d3..84d0609e2a0 100644 --- a/src/core/lib/iomgr/fork_windows.cc +++ b/src/core/lib/iomgr/fork_windows.cc @@ -25,7 +25,6 @@ #include "absl/log/log.h" #include -#include // // NOTE: FORKING IS NOT GENERALLY SUPPORTED, THIS IS ONLY INTENDED TO WORK diff --git a/src/core/lib/iomgr/internal_errqueue.cc b/src/core/lib/iomgr/internal_errqueue.cc index 5223687a439..dbf001b4cc6 100644 --- a/src/core/lib/iomgr/internal_errqueue.cc +++ b/src/core/lib/iomgr/internal_errqueue.cc @@ -16,7 +16,6 @@ #include "absl/log/log.h" -#include #include #include "src/core/lib/iomgr/port.h" diff --git a/src/core/lib/iomgr/iocp_windows.cc b/src/core/lib/iomgr/iocp_windows.cc index 9d6477aaaaf..bc931a4f44b 100644 --- a/src/core/lib/iomgr/iocp_windows.cc +++ b/src/core/lib/iomgr/iocp_windows.cc @@ -30,7 +30,6 @@ #include "absl/log/log.h" #include -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/src/core/lib/iomgr/iomgr_windows.cc b/src/core/lib/iomgr/iomgr_windows.cc index 21570d9033f..ae35534186f 100644 --- a/src/core/lib/iomgr/iomgr_windows.cc +++ b/src/core/lib/iomgr/iomgr_windows.cc @@ -24,8 +24,6 @@ #include "absl/log/check.h" -#include - #include "src/core/lib/experiments/experiments.h" #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/iomgr/iocp_windows.h" diff --git a/src/core/lib/iomgr/polling_entity.cc b/src/core/lib/iomgr/polling_entity.cc index 8b225444c7e..2a3e9c77060 100644 --- a/src/core/lib/iomgr/polling_entity.cc +++ b/src/core/lib/iomgr/polling_entity.cc @@ -22,7 +22,6 @@ #include "absl/strings/str_format.h" #include -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/src/core/lib/iomgr/pollset_windows.cc b/src/core/lib/iomgr/pollset_windows.cc index c42d83da495..32925c61a93 100644 --- a/src/core/lib/iomgr/pollset_windows.cc +++ b/src/core/lib/iomgr/pollset_windows.cc @@ -22,8 +22,6 @@ #ifdef GRPC_WINSOCK_SOCKET -#include - #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/iomgr/iocp_windows.h" diff --git a/src/core/lib/iomgr/resolve_address.cc b/src/core/lib/iomgr/resolve_address.cc index 24cdcf1c6d0..db7b891bcc7 100644 --- a/src/core/lib/iomgr/resolve_address.cc +++ b/src/core/lib/iomgr/resolve_address.cc @@ -21,7 +21,6 @@ #include #include -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/src/core/lib/iomgr/resolve_address_posix.cc b/src/core/lib/iomgr/resolve_address_posix.cc index 8cad6517c1a..f890a349b97 100644 --- a/src/core/lib/iomgr/resolve_address_posix.cc +++ b/src/core/lib/iomgr/resolve_address_posix.cc @@ -25,7 +25,6 @@ #include #include -#include #include #include diff --git a/src/core/lib/iomgr/resolve_address_windows.cc b/src/core/lib/iomgr/resolve_address_windows.cc index 054f7423816..105dcc85744 100644 --- a/src/core/lib/iomgr/resolve_address_windows.cc +++ b/src/core/lib/iomgr/resolve_address_windows.cc @@ -28,7 +28,6 @@ #include "absl/strings/str_format.h" #include -#include #include #include #include diff --git a/src/core/lib/iomgr/sockaddr_utils_posix.cc b/src/core/lib/iomgr/sockaddr_utils_posix.cc index d1981a43196..62d5bcac84d 100644 --- a/src/core/lib/iomgr/sockaddr_utils_posix.cc +++ b/src/core/lib/iomgr/sockaddr_utils_posix.cc @@ -40,7 +40,6 @@ #include "absl/log/check.h" #include -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/src/core/lib/iomgr/socket_mutator.cc b/src/core/lib/iomgr/socket_mutator.cc index 428cc0bdf3f..f77661969ce 100644 --- a/src/core/lib/iomgr/socket_mutator.cc +++ b/src/core/lib/iomgr/socket_mutator.cc @@ -19,7 +19,6 @@ #include "src/core/lib/iomgr/socket_mutator.h" #include -#include #include #include diff --git a/src/core/lib/iomgr/socket_utils_linux.cc b/src/core/lib/iomgr/socket_utils_linux.cc index 2e64c21e0b5..d699a1d5fe5 100644 --- a/src/core/lib/iomgr/socket_utils_linux.cc +++ b/src/core/lib/iomgr/socket_utils_linux.cc @@ -25,8 +25,6 @@ #include #include -#include - #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/socket_utils_posix.h" diff --git a/src/core/lib/iomgr/socket_utils_posix.cc b/src/core/lib/iomgr/socket_utils_posix.cc index b34f3749c7f..88b5d9a6bcf 100644 --- a/src/core/lib/iomgr/socket_utils_posix.cc +++ b/src/core/lib/iomgr/socket_utils_posix.cc @@ -28,7 +28,6 @@ #include #include -#include #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/iomgr/sockaddr.h" diff --git a/src/core/lib/iomgr/socket_utils_windows.cc b/src/core/lib/iomgr/socket_utils_windows.cc index 8b0e8f45f7c..195a838598b 100644 --- a/src/core/lib/iomgr/socket_utils_windows.cc +++ b/src/core/lib/iomgr/socket_utils_windows.cc @@ -22,8 +22,6 @@ #ifdef GRPC_WINDOWS_SOCKETUTILS -#include - #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/socket_utils.h" diff --git a/src/core/lib/iomgr/tcp_client_windows.cc b/src/core/lib/iomgr/tcp_client_windows.cc index bedf1cca5b1..4086d45a577 100644 --- a/src/core/lib/iomgr/tcp_client_windows.cc +++ b/src/core/lib/iomgr/tcp_client_windows.cc @@ -29,7 +29,6 @@ #include #include #include -#include #include #include "src/core/lib/address_utils/sockaddr_utils.h" diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index d0c68d40c7f..37e409d1235 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -1255,9 +1255,8 @@ static bool tcp_write_with_timestamps(grpc_tcp* tcp, struct msghdr* msg, uint32_t opt = grpc_core::kTimestampingSocketOptions; if (setsockopt(tcp->fd, SOL_SOCKET, SO_TIMESTAMPING, static_cast(&opt), sizeof(opt)) != 0) { - if (GRPC_TRACE_FLAG_ENABLED(tcp)) { - LOG(ERROR) << "Failed to set timestamping options on the socket."; - } + GRPC_TRACE_LOG(tcp, ERROR) + << "Failed to set timestamping options on the socket."; return false; } tcp->bytes_counter = -1; @@ -1341,9 +1340,7 @@ struct cmsghdr* process_timestamp(grpc_tcp* tcp, msghdr* msg, auto next_cmsg = CMSG_NXTHDR(msg, cmsg); cmsghdr* opt_stats = nullptr; if (next_cmsg == nullptr) { - if (GRPC_TRACE_FLAG_ENABLED(tcp)) { - LOG(ERROR) << "Received timestamp without extended error"; - } + GRPC_TRACE_LOG(tcp, ERROR) << "Received timestamp without extended error"; return cmsg; } @@ -1353,9 +1350,7 @@ struct cmsghdr* process_timestamp(grpc_tcp* tcp, msghdr* msg, opt_stats = next_cmsg; next_cmsg = CMSG_NXTHDR(msg, opt_stats); if (next_cmsg == nullptr) { - if (GRPC_TRACE_FLAG_ENABLED(tcp)) { - LOG(ERROR) << "Received timestamp without extended error"; - } + GRPC_TRACE_LOG(tcp, ERROR) << "Received timestamp without extended error"; return opt_stats; } } @@ -1363,9 +1358,7 @@ struct cmsghdr* process_timestamp(grpc_tcp* tcp, msghdr* msg, if (!(next_cmsg->cmsg_level == SOL_IP || next_cmsg->cmsg_level == SOL_IPV6) || !(next_cmsg->cmsg_type == IP_RECVERR || next_cmsg->cmsg_type == IPV6_RECVERR)) { - if (GRPC_TRACE_FLAG_ENABLED(tcp)) { - LOG(ERROR) << "Unexpected control message"; - } + GRPC_TRACE_LOG(tcp, ERROR) << "Unexpected control message"; return cmsg; } diff --git a/src/core/lib/iomgr/unix_sockets_posix.cc b/src/core/lib/iomgr/unix_sockets_posix.cc index 15b2226b688..904cb10faa2 100644 --- a/src/core/lib/iomgr/unix_sockets_posix.cc +++ b/src/core/lib/iomgr/unix_sockets_posix.cc @@ -37,7 +37,6 @@ #include "absl/strings/str_cat.h" #include -#include #include "src/core/lib/address_utils/parse_address.h" #include "src/core/lib/gprpp/crash.h" diff --git a/src/core/lib/iomgr/unix_sockets_posix_noop.cc b/src/core/lib/iomgr/unix_sockets_posix_noop.cc index 8e783c8cb70..1f9038e9537 100644 --- a/src/core/lib/iomgr/unix_sockets_posix_noop.cc +++ b/src/core/lib/iomgr/unix_sockets_posix_noop.cc @@ -26,8 +26,6 @@ #include "absl/log/check.h" -#include - #include "src/core/lib/gprpp/crash.h" void grpc_create_socketpair_if_unix(int /* sv */[2]) { diff --git a/src/core/lib/iomgr/vsock.cc b/src/core/lib/iomgr/vsock.cc index 847dabe0f17..c6dc71a8430 100644 --- a/src/core/lib/iomgr/vsock.cc +++ b/src/core/lib/iomgr/vsock.cc @@ -28,7 +28,6 @@ #include "absl/strings/str_cat.h" #include -#include #include "src/core/lib/address_utils/parse_address.h" #include "src/core/lib/gprpp/crash.h" diff --git a/src/core/lib/iomgr/wakeup_fd_eventfd.cc b/src/core/lib/iomgr/wakeup_fd_eventfd.cc index 38760c2cfb4..fcdb63b2e5b 100644 --- a/src/core/lib/iomgr/wakeup_fd_eventfd.cc +++ b/src/core/lib/iomgr/wakeup_fd_eventfd.cc @@ -26,8 +26,6 @@ #include #include -#include - #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/strerror.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" diff --git a/src/core/lib/resource_quota/connection_quota.cc b/src/core/lib/resource_quota/connection_quota.cc index ab07f5e21b3..846883f78c3 100644 --- a/src/core/lib/resource_quota/connection_quota.cc +++ b/src/core/lib/resource_quota/connection_quota.cc @@ -19,7 +19,6 @@ #include "absl/log/check.h" -#include #include namespace grpc_core { diff --git a/src/core/lib/resource_quota/thread_quota.cc b/src/core/lib/resource_quota/thread_quota.cc index b2aba40210f..73e8b224402 100644 --- a/src/core/lib/resource_quota/thread_quota.cc +++ b/src/core/lib/resource_quota/thread_quota.cc @@ -16,7 +16,6 @@ #include "absl/log/check.h" -#include #include namespace grpc_core { diff --git a/src/core/lib/security/authorization/audit_logging.cc b/src/core/lib/security/authorization/audit_logging.cc index d5b9ae3d149..d5c8f95705e 100644 --- a/src/core/lib/security/authorization/audit_logging.cc +++ b/src/core/lib/security/authorization/audit_logging.cc @@ -30,7 +30,6 @@ #include #include -#include #include #include "src/core/lib/gprpp/sync.h" diff --git a/src/core/lib/security/authorization/grpc_authorization_engine.cc b/src/core/lib/security/authorization/grpc_authorization_engine.cc index 62595ee70b5..4fed6af4fed 100644 --- a/src/core/lib/security/authorization/grpc_authorization_engine.cc +++ b/src/core/lib/security/authorization/grpc_authorization_engine.cc @@ -20,7 +20,6 @@ #include "absl/log/check.h" -#include #include #include "src/core/lib/security/authorization/audit_logging.h" diff --git a/src/core/lib/security/authorization/rbac_translator.cc b/src/core/lib/security/authorization/rbac_translator.cc index 1dbbe8bf16d..d427ce8ea07 100644 --- a/src/core/lib/security/authorization/rbac_translator.cc +++ b/src/core/lib/security/authorization/rbac_translator.cc @@ -34,7 +34,6 @@ #include #include -#include #include #include "src/core/lib/matchers/matchers.h" diff --git a/src/core/lib/security/authorization/stdout_logger.cc b/src/core/lib/security/authorization/stdout_logger.cc index 8e2adb6dd17..9314d21a0e6 100644 --- a/src/core/lib/security/authorization/stdout_logger.cc +++ b/src/core/lib/security/authorization/stdout_logger.cc @@ -27,7 +27,6 @@ #include #include -#include #include namespace grpc_core { diff --git a/src/core/lib/security/credentials/alts/check_gcp_environment.cc b/src/core/lib/security/credentials/alts/check_gcp_environment.cc index 50406fb8a54..864620c9a5a 100644 --- a/src/core/lib/security/credentials/alts/check_gcp_environment.cc +++ b/src/core/lib/security/credentials/alts/check_gcp_environment.cc @@ -25,7 +25,6 @@ #include "absl/log/log.h" #include -#include #include const size_t kBiosDataBufferSize = 256; diff --git a/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc b/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc index b034ccaac79..85639e51840 100644 --- a/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc +++ b/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc @@ -26,7 +26,6 @@ #include #include -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/src/core/lib/security/credentials/call_creds_util.cc b/src/core/lib/security/credentials/call_creds_util.cc index c49dd918ab5..037d60196c9 100644 --- a/src/core/lib/security/credentials/call_creds_util.cc +++ b/src/core/lib/security/credentials/call_creds_util.cc @@ -22,7 +22,6 @@ #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include #include #include diff --git a/src/core/lib/security/credentials/composite/composite_credentials.cc b/src/core/lib/security/credentials/composite/composite_credentials.cc index 016565ceaa7..db5d3079cbc 100644 --- a/src/core/lib/security/credentials/composite/composite_credentials.cc +++ b/src/core/lib/security/credentials/composite/composite_credentials.cc @@ -26,7 +26,6 @@ #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" -#include #include #include "src/core/lib/debug/trace.h" diff --git a/src/core/lib/security/credentials/external/aws_external_account_credentials.cc b/src/core/lib/security/credentials/external/aws_external_account_credentials.cc index 27d1b88ef1a..34c4b4521dd 100644 --- a/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +++ b/src/core/lib/security/credentials/external/aws_external_account_credentials.cc @@ -34,7 +34,6 @@ #include #include #include -#include #include #include diff --git a/src/core/lib/security/credentials/external/url_external_account_credentials.cc b/src/core/lib/security/credentials/external/url_external_account_credentials.cc index b2a5359c596..faa6e19a108 100644 --- a/src/core/lib/security/credentials/external/url_external_account_credentials.cc +++ b/src/core/lib/security/credentials/external/url_external_account_credentials.cc @@ -33,7 +33,6 @@ #include #include #include -#include #include #include diff --git a/src/core/lib/security/credentials/iam/iam_credentials.cc b/src/core/lib/security/credentials/iam/iam_credentials.cc index 76e54d3dd80..876851555da 100644 --- a/src/core/lib/security/credentials/iam/iam_credentials.cc +++ b/src/core/lib/security/credentials/iam/iam_credentials.cc @@ -27,7 +27,6 @@ #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" -#include #include #include "src/core/lib/debug/trace.h" diff --git a/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc b/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc index 8b02a5a4446..2472244f2c5 100644 --- a/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +++ b/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc @@ -21,7 +21,6 @@ #include #include -#include #include void grpc_tls_certificate_distributor::SetKeyMaterials( diff --git a/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.cc b/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.cc index a3bd89996fa..f4c2c75bb44 100644 --- a/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.cc +++ b/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.cc @@ -25,7 +25,6 @@ #include "absl/strings/string_view.h" #include -#include #include #include diff --git a/src/core/lib/security/credentials/xds/xds_credentials.cc b/src/core/lib/security/credentials/xds/xds_credentials.cc index c2e5b925e6d..a0e017498e2 100644 --- a/src/core/lib/security/credentials/xds/xds_credentials.cc +++ b/src/core/lib/security/credentials/xds/xds_credentials.cc @@ -23,7 +23,6 @@ #include #include -#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/src/core/lib/security/security_connector/fake/fake_security_connector.cc b/src/core/lib/security/security_connector/fake/fake_security_connector.cc index 25f7bf736f7..b83eda46ee1 100644 --- a/src/core/lib/security/security_connector/fake/fake_security_connector.cc +++ b/src/core/lib/security/security_connector/fake/fake_security_connector.cc @@ -35,7 +35,6 @@ #include #include #include -#include #include #include diff --git a/src/core/lib/security/security_connector/insecure/insecure_security_connector.cc b/src/core/lib/security/security_connector/insecure/insecure_security_connector.cc index 97f3fff8718..08e897bebc3 100644 --- a/src/core/lib/security/security_connector/insecure/insecure_security_connector.cc +++ b/src/core/lib/security/security_connector/insecure/insecure_security_connector.cc @@ -23,7 +23,6 @@ #include "absl/log/check.h" #include -#include #include #include "src/core/handshaker/security/security_handshaker.h" diff --git a/src/core/lib/security/security_connector/load_system_roots_windows.cc b/src/core/lib/security/security_connector/load_system_roots_windows.cc index 74e5b664c6a..118f013c323 100644 --- a/src/core/lib/security/security_connector/load_system_roots_windows.cc +++ b/src/core/lib/security/security_connector/load_system_roots_windows.cc @@ -30,7 +30,6 @@ #include #include #include -#include #include "src/core/lib/security/security_connector/load_system_roots.h" #include "src/core/lib/slice/slice_internal.h" diff --git a/src/core/lib/security/transport/server_auth_filter.cc b/src/core/lib/security/transport/server_auth_filter.cc index 70fe059c980..5b332aa9875 100644 --- a/src/core/lib/security/transport/server_auth_filter.cc +++ b/src/core/lib/security/transport/server_auth_filter.cc @@ -131,12 +131,10 @@ struct ServerAuthFilter::RunApplicationCode::State { ServerAuthFilter::RunApplicationCode::RunApplicationCode( ServerAuthFilter* filter, ClientMetadata& metadata) : state_(GetContext()->ManagedNew(metadata)) { - if (GRPC_TRACE_FLAG_ENABLED(call)) { - LOG(ERROR) << GetContext()->DebugTag() - << "[server-auth]: Delegate to application: filter=" << filter - << " this=" << this - << " auth_ctx=" << filter->auth_context_.get(); - } + GRPC_TRACE_LOG(call, ERROR) + << GetContext()->DebugTag() + << "[server-auth]: Delegate to application: filter=" << filter + << " this=" << this << " auth_ctx=" << filter->auth_context_.get(); filter->server_credentials_->auth_metadata_processor().process( filter->server_credentials_->auth_metadata_processor().state, filter->auth_context_.get(), state_->md.metadata, state_->md.count, diff --git a/src/core/lib/slice/percent_encoding.cc b/src/core/lib/slice/percent_encoding.cc index 8931f1d716d..0d73ea3c06a 100644 --- a/src/core/lib/slice/percent_encoding.cc +++ b/src/core/lib/slice/percent_encoding.cc @@ -25,7 +25,6 @@ #include "absl/log/check.h" -#include #include #include "src/core/lib/gprpp/bitset.h" diff --git a/src/core/lib/slice/slice.cc b/src/core/lib/slice/slice.cc index f2d49e0bf47..c0143684dfb 100644 --- a/src/core/lib/slice/slice.cc +++ b/src/core/lib/slice/slice.cc @@ -26,7 +26,6 @@ #include #include -#include #include #include "src/core/lib/gprpp/memory.h" diff --git a/src/core/lib/slice/slice_buffer.cc b/src/core/lib/slice/slice_buffer.cc index 6ea05cbc157..3d07c32334b 100644 --- a/src/core/lib/slice/slice_buffer.cc +++ b/src/core/lib/slice/slice_buffer.cc @@ -27,7 +27,6 @@ #include #include #include -#include #include #include "src/core/lib/slice/slice_internal.h" diff --git a/src/core/lib/surface/byte_buffer_reader.cc b/src/core/lib/surface/byte_buffer_reader.cc index 2053bf3f8b5..0516b852a90 100644 --- a/src/core/lib/surface/byte_buffer_reader.cc +++ b/src/core/lib/surface/byte_buffer_reader.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include #include "src/core/lib/iomgr/exec_ctx.h" diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index f7a4e2d09f1..f8ee18a9f0c 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -336,11 +336,9 @@ void Call::HandleCompressionAlgorithmDisabled( void Call::UpdateDeadline(Timestamp deadline) { ReleasableMutexLock lock(&deadline_mu_); - if (GRPC_TRACE_FLAG_ENABLED(call)) { - LOG(INFO) << "[call " << this - << "] UpdateDeadline from=" << deadline_.ToString() - << " to=" << deadline.ToString(); - } + GRPC_TRACE_LOG(call, INFO) + << "[call " << this << "] UpdateDeadline from=" << deadline_.ToString() + << " to=" << deadline.ToString(); if (deadline >= deadline_) return; if (deadline < Timestamp::Now()) { lock.Release(); diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 3e19723838f..577ab734efa 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -22,7 +22,6 @@ #include #include #include -#include #include #include "src/core/channelz/channel_trace.h" diff --git a/src/core/lib/surface/channel_create.cc b/src/core/lib/surface/channel_create.cc index 4f9eb9ad9ed..ef0fd5ba2c6 100644 --- a/src/core/lib/surface/channel_create.cc +++ b/src/core/lib/surface/channel_create.cc @@ -20,7 +20,6 @@ #include #include -#include #include #include "src/core/channelz/channelz.h" diff --git a/src/core/lib/surface/client_call.cc b/src/core/lib/surface/client_call.cc index 42c40174b49..db329e66ffa 100644 --- a/src/core/lib/surface/client_call.cc +++ b/src/core/lib/surface/client_call.cc @@ -41,7 +41,6 @@ #include #include #include -#include #include #include diff --git a/src/core/lib/surface/completion_queue_factory.cc b/src/core/lib/surface/completion_queue_factory.cc index 486cc5f00ec..dae6695b712 100644 --- a/src/core/lib/surface/completion_queue_factory.cc +++ b/src/core/lib/surface/completion_queue_factory.cc @@ -21,7 +21,6 @@ #include "absl/log/check.h" #include -#include #include #include "src/core/lib/iomgr/exec_ctx.h" diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index 0adcbb39995..e134e673d8c 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include diff --git a/src/core/lib/surface/lame_client.cc b/src/core/lib/surface/lame_client.cc index e431024446b..3ac1321b6c7 100644 --- a/src/core/lib/surface/lame_client.cc +++ b/src/core/lib/surface/lame_client.cc @@ -27,7 +27,6 @@ #include #include #include -#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/src/core/lib/surface/server_call.cc b/src/core/lib/surface/server_call.cc index 3eeddfca866..0ac9064bedb 100644 --- a/src/core/lib/surface/server_call.cc +++ b/src/core/lib/surface/server_call.cc @@ -37,7 +37,6 @@ #include #include #include -#include #include #include diff --git a/src/core/lib/transport/connectivity_state.cc b/src/core/lib/transport/connectivity_state.cc index 5e9ff808bbe..503ff1f7ea1 100644 --- a/src/core/lib/transport/connectivity_state.cc +++ b/src/core/lib/transport/connectivity_state.cc @@ -72,12 +72,11 @@ class AsyncConnectivityStateWatcherInterface::Notifier { private: static void SendNotification(void* arg, grpc_error_handle /*ignored*/) { Notifier* self = static_cast(arg); - if (GRPC_TRACE_FLAG_ENABLED(connectivity_state)) { - LOG(INFO) << "watcher " << self->watcher_.get() - << ": delivering async notification for " - << ConnectivityStateName(self->state_) << " (" - << self->status_.ToString() << ")"; - } + GRPC_TRACE_LOG(connectivity_state, INFO) + << "watcher " << self->watcher_.get() + << ": delivering async notification for " + << ConnectivityStateName(self->state_) << " (" + << self->status_.ToString() << ")"; self->watcher_->OnConnectivityStateChange(self->state_, self->status_); delete self; } @@ -104,12 +103,11 @@ ConnectivityStateTracker::~ConnectivityStateTracker() { state_.load(std::memory_order_relaxed); if (current_state == GRPC_CHANNEL_SHUTDOWN) return; for (const auto& p : watchers_) { - if (GRPC_TRACE_FLAG_ENABLED(connectivity_state)) { - LOG(INFO) << "ConnectivityStateTracker " << name_ << "[" << this - << "]: notifying watcher " << p.first << ": " - << ConnectivityStateName(current_state) << " -> " - << ConnectivityStateName(GRPC_CHANNEL_SHUTDOWN); - } + GRPC_TRACE_LOG(connectivity_state, INFO) + << "ConnectivityStateTracker " << name_ << "[" << this + << "]: notifying watcher " << p.first << ": " + << ConnectivityStateName(current_state) << " -> " + << ConnectivityStateName(GRPC_CHANNEL_SHUTDOWN); p.second->Notify(GRPC_CHANNEL_SHUTDOWN, absl::Status()); } } @@ -123,12 +121,11 @@ void ConnectivityStateTracker::AddWatcher( grpc_connectivity_state current_state = state_.load(std::memory_order_relaxed); if (initial_state != current_state) { - if (GRPC_TRACE_FLAG_ENABLED(connectivity_state)) { - LOG(INFO) << "ConnectivityStateTracker " << name_ << "[" << this - << "]: notifying watcher " << watcher.get() << ": " - << ConnectivityStateName(initial_state) << " -> " - << ConnectivityStateName(current_state); - } + GRPC_TRACE_LOG(connectivity_state, INFO) + << "ConnectivityStateTracker " << name_ << "[" << this + << "]: notifying watcher " << watcher.get() << ": " + << ConnectivityStateName(initial_state) << " -> " + << ConnectivityStateName(current_state); watcher->Notify(current_state, status_); } // If we're in state SHUTDOWN, don't add the watcher, so that it will @@ -152,21 +149,19 @@ void ConnectivityStateTracker::SetState(grpc_connectivity_state state, grpc_connectivity_state current_state = state_.load(std::memory_order_relaxed); if (state == current_state) return; - if (GRPC_TRACE_FLAG_ENABLED(connectivity_state)) { - LOG(INFO) << "ConnectivityStateTracker " << name_ << "[" << this - << "]: " << ConnectivityStateName(current_state) << " -> " - << ConnectivityStateName(state) << " (" << reason << ", " - << status.ToString() << ")"; - } + GRPC_TRACE_LOG(connectivity_state, INFO) + << "ConnectivityStateTracker " << name_ << "[" << this + << "]: " << ConnectivityStateName(current_state) << " -> " + << ConnectivityStateName(state) << " (" << reason << ", " + << status.ToString() << ")"; state_.store(state, std::memory_order_relaxed); status_ = status; for (const auto& p : watchers_) { - if (GRPC_TRACE_FLAG_ENABLED(connectivity_state)) { - LOG(INFO) << "ConnectivityStateTracker " << name_ << "[" << this - << "]: notifying watcher " << p.first << ": " - << ConnectivityStateName(current_state) << " -> " - << ConnectivityStateName(state); - } + GRPC_TRACE_LOG(connectivity_state, INFO) + << "ConnectivityStateTracker " << name_ << "[" << this + << "]: notifying watcher " << p.first << ": " + << ConnectivityStateName(current_state) << " -> " + << ConnectivityStateName(state); p.second->Notify(state, status); } // If the new state is SHUTDOWN, orphan all of the watchers. This diff --git a/src/core/lib/transport/promise_endpoint.cc b/src/core/lib/transport/promise_endpoint.cc index 031f5194e02..355cf44333f 100644 --- a/src/core/lib/transport/promise_endpoint.cc +++ b/src/core/lib/transport/promise_endpoint.cc @@ -26,7 +26,6 @@ #include #include #include -#include #include #include "src/core/lib/gprpp/sync.h" diff --git a/src/core/lib/transport/timeout_encoding.cc b/src/core/lib/transport/timeout_encoding.cc index deb82cb2cdc..57621d835c0 100644 --- a/src/core/lib/transport/timeout_encoding.cc +++ b/src/core/lib/transport/timeout_encoding.cc @@ -23,7 +23,6 @@ #include "absl/base/attributes.h" #include "absl/log/check.h" -#include #include #include diff --git a/src/core/lib/transport/transport_op_string.cc b/src/core/lib/transport/transport_op_string.cc index 09222337537..40ea5bc2d8a 100644 --- a/src/core/lib/transport/transport_op_string.cc +++ b/src/core/lib/transport/transport_op_string.cc @@ -22,7 +22,6 @@ #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" -#include #include #include "src/core/lib/channel/channel_fwd.h" diff --git a/src/core/lib/uri/uri_parser.cc b/src/core/lib/uri/uri_parser.cc index dfb71286c41..95d92663194 100644 --- a/src/core/lib/uri/uri_parser.cc +++ b/src/core/lib/uri/uri_parser.cc @@ -36,7 +36,6 @@ #include "absl/strings/str_split.h" #include "absl/strings/strip.h" -#include #include namespace grpc_core { diff --git a/src/core/load_balancing/health_check_client.cc b/src/core/load_balancing/health_check_client.cc index da841baaff9..430c59f28f5 100644 --- a/src/core/load_balancing/health_check_client.cc +++ b/src/core/load_balancing/health_check_client.cc @@ -458,12 +458,11 @@ void HealthWatcher::SetSubchannel(Subchannel* subchannel) { if (created) producer_->Start(subchannel->Ref()); // Register ourself with the producer. producer_->AddWatcher(this, health_check_service_name_); - if (GRPC_TRACE_FLAG_ENABLED(health_check_client)) { - LOG(INFO) << "HealthWatcher " << this << ": registered with producer " - << producer_.get() << " (created=" << created - << ", health_check_service_name=\"" - << health_check_service_name_.value_or("N/A") << "\")"; - } + GRPC_TRACE_LOG(health_check_client, INFO) + << "HealthWatcher " << this << ": registered with producer " + << producer_.get() << " (created=" << created + << ", health_check_service_name=\"" + << health_check_service_name_.value_or("N/A") << "\")"; } void HealthWatcher::Notify(grpc_connectivity_state state, absl::Status status) { diff --git a/src/core/load_balancing/outlier_detection/outlier_detection.cc b/src/core/load_balancing/outlier_detection/outlier_detection.cc index 9141b2bef59..87cffdefe81 100644 --- a/src/core/load_balancing/outlier_detection/outlier_detection.cc +++ b/src/core/load_balancing/outlier_detection/outlier_detection.cc @@ -740,12 +740,11 @@ void OutlierDetectionLb::MaybeUpdatePickerLocked() { if (picker_ != nullptr) { auto outlier_detection_picker = MakeRefCounted(this, picker_, config_->CountingEnabled()); - if (GRPC_TRACE_FLAG_ENABLED(outlier_detection_lb)) { - LOG(INFO) << "[outlier_detection_lb " << this - << "] updating connectivity: state=" - << ConnectivityStateName(state_) << " status=(" << status_ - << ") picker=" << outlier_detection_picker.get(); - } + GRPC_TRACE_LOG(outlier_detection_lb, INFO) + << "[outlier_detection_lb " << this + << "] updating connectivity: state=" << ConnectivityStateName(state_) + << " status=(" << status_ + << ") picker=" << outlier_detection_picker.get(); channel_control_helper()->UpdateState(state_, status_, std::move(outlier_detection_picker)); } @@ -806,12 +805,11 @@ void OutlierDetectionLb::Helper::UpdateState( grpc_connectivity_state state, const absl::Status& status, RefCountedPtr picker) { if (parent()->shutting_down_) return; - if (GRPC_TRACE_FLAG_ENABLED(outlier_detection_lb)) { - LOG(INFO) << "[outlier_detection_lb " << parent() - << "] child connectivity state update: state=" - << ConnectivityStateName(state) << " (" << status - << ") picker=" << picker.get(); - } + GRPC_TRACE_LOG(outlier_detection_lb, INFO) + << "[outlier_detection_lb " << parent() + << "] child connectivity state update: state=" + << ConnectivityStateName(state) << " (" << status + << ") picker=" << picker.get(); // Save the state and picker. parent()->state_ = state; parent()->status_ = status; @@ -892,26 +890,24 @@ void OutlierDetectionLb::EjectionTimer::OnTimerLocked() { } } } - if (GRPC_TRACE_FLAG_ENABLED(outlier_detection_lb)) { - LOG(INFO) << "[outlier_detection_lb " << parent_.get() << "] found " - << success_rate_ejection_candidates.size() - << " success rate candidates and " - << failure_percentage_ejection_candidates.size() - << " failure percentage candidates; ejected_host_count=" - << ejected_host_count << "; success_rate_sum=" - << absl::StrFormat("%.3f", success_rate_sum); - } + GRPC_TRACE_LOG(outlier_detection_lb, INFO) + << "[outlier_detection_lb " << parent_.get() << "] found " + << success_rate_ejection_candidates.size() + << " success rate candidates and " + << failure_percentage_ejection_candidates.size() + << " failure percentage candidates; ejected_host_count=" + << ejected_host_count + << "; success_rate_sum=" << absl::StrFormat("%.3f", success_rate_sum); // success rate algorithm if (!success_rate_ejection_candidates.empty() && success_rate_ejection_candidates.size() >= config.success_rate_ejection->minimum_hosts) { - if (GRPC_TRACE_FLAG_ENABLED(outlier_detection_lb)) { - LOG(INFO) << "[outlier_detection_lb " << parent_.get() - << "] running success rate algorithm: " - << "stdev_factor=" << config.success_rate_ejection->stdev_factor - << ", enforcement_percentage=" - << config.success_rate_ejection->enforcement_percentage; - } + GRPC_TRACE_LOG(outlier_detection_lb, INFO) + << "[outlier_detection_lb " << parent_.get() + << "] running success rate algorithm: " + << "stdev_factor=" << config.success_rate_ejection->stdev_factor + << ", enforcement_percentage=" + << config.success_rate_ejection->enforcement_percentage; // calculate ejection threshold: (mean - stdev * // (success_rate_ejection.stdev_factor / 1000)) double mean = success_rate_sum / success_rate_ejection_candidates.size(); @@ -936,13 +932,11 @@ void OutlierDetectionLb::EjectionTimer::OnTimerLocked() { uint32_t random_key = absl::Uniform(bit_gen_, 1, 100); double current_percent = 100.0 * ejected_host_count / parent_->endpoint_state_map_.size(); - if (GRPC_TRACE_FLAG_ENABLED(outlier_detection_lb)) { - LOG(INFO) << "[outlier_detection_lb " << parent_.get() - << "] random_key=" << random_key - << " ejected_host_count=" << ejected_host_count - << " current_percent=" - << absl::StrFormat("%.3f", current_percent); - } + GRPC_TRACE_LOG(outlier_detection_lb, INFO) + << "[outlier_detection_lb " << parent_.get() + << "] random_key=" << random_key + << " ejected_host_count=" << ejected_host_count + << " current_percent=" << absl::StrFormat("%.3f", current_percent); if (random_key < config.success_rate_ejection->enforcement_percentage && (ejected_host_count == 0 || (current_percent < config.max_ejection_percent))) { @@ -961,13 +955,12 @@ void OutlierDetectionLb::EjectionTimer::OnTimerLocked() { if (!failure_percentage_ejection_candidates.empty() && failure_percentage_ejection_candidates.size() >= config.failure_percentage_ejection->minimum_hosts) { - if (GRPC_TRACE_FLAG_ENABLED(outlier_detection_lb)) { - LOG(INFO) << "[outlier_detection_lb " << parent_.get() - << "] running failure percentage algorithm: " - << "threshold=" << config.failure_percentage_ejection->threshold - << ", enforcement_percentage=" - << config.failure_percentage_ejection->enforcement_percentage; - } + GRPC_TRACE_LOG(outlier_detection_lb, INFO) + << "[outlier_detection_lb " << parent_.get() + << "] running failure percentage algorithm: " + << "threshold=" << config.failure_percentage_ejection->threshold + << ", enforcement_percentage=" + << config.failure_percentage_ejection->enforcement_percentage; for (auto& candidate : failure_percentage_ejection_candidates) { GRPC_TRACE_LOG(outlier_detection_lb, INFO) << "[outlier_detection_lb " << parent_.get() @@ -981,12 +974,11 @@ void OutlierDetectionLb::EjectionTimer::OnTimerLocked() { uint32_t random_key = absl::Uniform(bit_gen_, 1, 100); double current_percent = 100.0 * ejected_host_count / parent_->endpoint_state_map_.size(); - if (GRPC_TRACE_FLAG_ENABLED(outlier_detection_lb)) { - LOG(INFO) << "[outlier_detection_lb " << parent_.get() - << "] random_key=" << random_key - << " ejected_host_count=" << ejected_host_count - << " current_percent=" << current_percent; - } + GRPC_TRACE_LOG(outlier_detection_lb, INFO) + << "[outlier_detection_lb " << parent_.get() + << "] random_key=" << random_key + << " ejected_host_count=" << ejected_host_count + << " current_percent=" << current_percent; if (random_key < config.failure_percentage_ejection->enforcement_percentage && (ejected_host_count == 0 || diff --git a/src/core/load_balancing/pick_first/pick_first.cc b/src/core/load_balancing/pick_first/pick_first.cc index 038b074e216..f3280a9c9d8 100644 --- a/src/core/load_balancing/pick_first/pick_first.cc +++ b/src/core/load_balancing/pick_first/pick_first.cc @@ -735,15 +735,13 @@ void PickFirst::SubchannelList::SubchannelData::SubchannelState:: OnConnectivityStateChange(grpc_connectivity_state new_state, absl::Status status) { if (watcher_ == nullptr) return; - if (GRPC_TRACE_FLAG_ENABLED(pick_first)) { - LOG(INFO) << "[PF " << pick_first_.get() << "] subchannel state " << this - << " (subchannel " << subchannel_.get() - << "): connectivity changed: new_state=" - << ConnectivityStateName(new_state) << ", status=" << status - << ", watcher=" << watcher_ - << ", subchannel_data_=" << subchannel_data_ - << ", pick_first_->selected_=" << pick_first_->selected_.get(); - } + GRPC_TRACE_LOG(pick_first, INFO) + << "[PF " << pick_first_.get() << "] subchannel state " << this + << " (subchannel " << subchannel_.get() + << "): connectivity changed: new_state=" + << ConnectivityStateName(new_state) << ", status=" << status + << ", watcher=" << watcher_ << ", subchannel_data_=" << subchannel_data_ + << ", pick_first_->selected_=" << pick_first_->selected_.get(); // If we're still part of a subchannel list trying to connect, check // if we're connected. if (subchannel_data_ != nullptr) { @@ -944,12 +942,10 @@ void PickFirst::SubchannelList::SubchannelData::RequestConnectionWithTimer() { // If this is not the last subchannel in the list, start the timer. if (index_ != subchannel_list_->size() - 1) { PickFirst* p = subchannel_list_->policy_.get(); - if (GRPC_TRACE_FLAG_ENABLED(pick_first)) { - LOG(INFO) << "Pick First " << p << " subchannel list " << subchannel_list_ - << ": starting Connection Attempt Delay timer for " - << p->connection_attempt_delay_.millis() << "ms for index " - << index_; - } + GRPC_TRACE_LOG(pick_first, INFO) + << "Pick First " << p << " subchannel list " << subchannel_list_ + << ": starting Connection Attempt Delay timer for " + << p->connection_attempt_delay_.millis() << "ms for index " << index_; subchannel_list_->timer_handle_ = p->channel_control_helper()->GetEventEngine()->RunAfter( p->connection_attempt_delay_, @@ -960,15 +956,13 @@ void PickFirst::SubchannelList::SubchannelData::RequestConnectionWithTimer() { auto* sl = subchannel_list.get(); sl->policy_->work_serializer()->Run( [subchannel_list = std::move(subchannel_list)]() { - if (GRPC_TRACE_FLAG_ENABLED(pick_first)) { - LOG(INFO) - << "Pick First " << subchannel_list->policy_.get() - << " subchannel list " << subchannel_list.get() - << ": Connection Attempt Delay timer fired " - "(shutting_down=" - << subchannel_list->shutting_down_ << ", selected=" - << subchannel_list->policy_->selected_.get() << ")"; - } + GRPC_TRACE_LOG(pick_first, INFO) + << "Pick First " << subchannel_list->policy_.get() + << " subchannel list " << subchannel_list.get() + << ": Connection Attempt Delay timer fired " + "(shutting_down=" + << subchannel_list->shutting_down_ << ", selected=" + << subchannel_list->policy_->selected_.get() << ")"; if (subchannel_list->shutting_down_) return; if (subchannel_list->policy_->selected_ != nullptr) return; ++subchannel_list->attempting_index_; @@ -1588,13 +1582,11 @@ OldPickFirst::SubchannelList::SubchannelData::SubchannelData( void OldPickFirst::SubchannelList::SubchannelData::ShutdownLocked() { if (subchannel_ != nullptr) { - if (GRPC_TRACE_FLAG_ENABLED(pick_first)) { - LOG(INFO) << "[PF " << subchannel_list_->policy_.get() - << "] subchannel list " << subchannel_list_ << " index " - << index_ << " of " << subchannel_list_->size() - << " (subchannel " << subchannel_.get() - << "): cancelling watch and unreffing subchannel"; - } + GRPC_TRACE_LOG(pick_first, INFO) + << "[PF " << subchannel_list_->policy_.get() << "] subchannel list " + << subchannel_list_ << " index " << index_ << " of " + << subchannel_list_->size() << " (subchannel " << subchannel_.get() + << "): cancelling watch and unreffing subchannel"; subchannel_->CancelConnectivityStateWatch(pending_watcher_); pending_watcher_ = nullptr; subchannel_.reset(); @@ -1814,12 +1806,10 @@ void OldPickFirst::SubchannelList::SubchannelData:: // If this is not the last subchannel in the list, start the timer. if (index_ != subchannel_list_->size() - 1) { OldPickFirst* p = subchannel_list_->policy_.get(); - if (GRPC_TRACE_FLAG_ENABLED(pick_first)) { - LOG(INFO) << "Pick First " << p << " subchannel list " << subchannel_list_ - << ": starting Connection Attempt Delay timer for " - << p->connection_attempt_delay_.millis() << "ms for index " - << index_; - } + GRPC_TRACE_LOG(pick_first, INFO) + << "Pick First " << p << " subchannel list " << subchannel_list_ + << ": starting Connection Attempt Delay timer for " + << p->connection_attempt_delay_.millis() << "ms for index " << index_; subchannel_list_->timer_handle_ = p->channel_control_helper()->GetEventEngine()->RunAfter( p->connection_attempt_delay_, @@ -1830,15 +1820,13 @@ void OldPickFirst::SubchannelList::SubchannelData:: auto* sl = subchannel_list.get(); sl->policy_->work_serializer()->Run( [subchannel_list = std::move(subchannel_list)]() { - if (GRPC_TRACE_FLAG_ENABLED(pick_first)) { - LOG(INFO) - << "Pick First " << subchannel_list->policy_.get() - << " subchannel list " << subchannel_list.get() - << ": Connection Attempt Delay timer fired " - << "(shutting_down=" - << subchannel_list->shutting_down_ << ", selected=" - << subchannel_list->policy_->selected_ << ")"; - } + GRPC_TRACE_LOG(pick_first, INFO) + << "Pick First " << subchannel_list->policy_.get() + << " subchannel list " << subchannel_list.get() + << ": Connection Attempt Delay timer fired " + << "(shutting_down=" << subchannel_list->shutting_down_ + << ", selected=" << subchannel_list->policy_->selected_ + << ")"; if (subchannel_list->shutting_down_) return; if (subchannel_list->policy_->selected_ != nullptr) return; ++subchannel_list->attempting_index_; @@ -2004,12 +1992,11 @@ void OldPickFirst::SubchannelList::MaybeFinishHappyEyeballsPass() { // TRANSIENT_FAILURE and dropping the existing (working) connection, // but we can't ignore what the control plane has told us. if (policy_->latest_pending_subchannel_list_.get() == this) { - if (GRPC_TRACE_FLAG_ENABLED(pick_first)) { - LOG(INFO) << "Pick First " << policy_.get() - << " promoting pending subchannel list " - << policy_->latest_pending_subchannel_list_.get() - << " to replace " << this; - } + GRPC_TRACE_LOG(pick_first, INFO) + << "Pick First " << policy_.get() + << " promoting pending subchannel list " + << policy_->latest_pending_subchannel_list_.get() << " to replace " + << this; policy_->UnsetSelectedSubchannel(); policy_->subchannel_list_ = std::move(policy_->latest_pending_subchannel_list_); diff --git a/src/core/load_balancing/priority/priority.cc b/src/core/load_balancing/priority/priority.cc index 3a4de92a1a6..07f9a529ddb 100644 --- a/src/core/load_balancing/priority/priority.cc +++ b/src/core/load_balancing/priority/priority.cc @@ -435,12 +435,11 @@ void PriorityLb::ChoosePriorityLocked() { return; } // Child has been failing for a while. Move on to the next priority. - if (GRPC_TRACE_FLAG_ENABLED(priority_lb)) { - LOG(INFO) << "[priority_lb " << this << "] skipping priority " << priority - << ", child " << child_name << ": state=" - << ConnectivityStateName(child->connectivity_state()) - << ", failover timer not pending"; - } + GRPC_TRACE_LOG(priority_lb, INFO) + << "[priority_lb " << this << "] skipping priority " << priority + << ", child " << child_name + << ": state=" << ConnectivityStateName(child->connectivity_state()) + << ", failover timer not pending"; } // If we didn't find any priority to try, pick the first one in state // CONNECTING. @@ -472,12 +471,10 @@ void PriorityLb::ChoosePriorityLocked() { void PriorityLb::SetCurrentPriorityLocked(int32_t priority, bool deactivate_lower_priorities, const char* reason) { - if (GRPC_TRACE_FLAG_ENABLED(priority_lb)) { - LOG(INFO) << "[priority_lb " << this << "] selecting priority " << priority - << ", child " << config_->priorities()[priority] << " (" << reason - << ", deactivate_lower_priorities=" << deactivate_lower_priorities - << ")"; - } + GRPC_TRACE_LOG(priority_lb, INFO) + << "[priority_lb " << this << "] selecting priority " << priority + << ", child " << config_->priorities()[priority] << " (" << reason + << ", deactivate_lower_priorities=" << deactivate_lower_priorities << ")"; current_priority_ = priority; if (deactivate_lower_priorities) { for (uint32_t p = priority + 1; p < config_->priorities().size(); ++p) { @@ -500,12 +497,11 @@ void PriorityLb::SetCurrentPriorityLocked(int32_t priority, PriorityLb::ChildPriority::DeactivationTimer::DeactivationTimer( RefCountedPtr child_priority) : child_priority_(std::move(child_priority)) { - if (GRPC_TRACE_FLAG_ENABLED(priority_lb)) { - LOG(INFO) << "[priority_lb " << child_priority_->priority_policy_.get() - << "] child " << child_priority_->name_ << " (" - << child_priority_.get() << "): deactivating -- will remove in " - << kChildRetentionInterval.millis() << "ms"; - } + GRPC_TRACE_LOG(priority_lb, INFO) + << "[priority_lb " << child_priority_->priority_policy_.get() + << "] child " << child_priority_->name_ << " (" << child_priority_.get() + << "): deactivating -- will remove in " + << kChildRetentionInterval.millis() << "ms"; timer_handle_ = child_priority_->priority_policy_->channel_control_helper() ->GetEventEngine() @@ -537,12 +533,10 @@ void PriorityLb::ChildPriority::DeactivationTimer::Orphan() { void PriorityLb::ChildPriority::DeactivationTimer::OnTimerLocked() { if (timer_handle_.has_value()) { timer_handle_.reset(); - if (GRPC_TRACE_FLAG_ENABLED(priority_lb)) { - LOG(INFO) << "[priority_lb " << child_priority_->priority_policy_.get() - << "] child " << child_priority_->name_ << " (" - << child_priority_.get() - << "): deactivation timer fired, deleting child"; - } + GRPC_TRACE_LOG(priority_lb, INFO) + << "[priority_lb " << child_priority_->priority_policy_.get() + << "] child " << child_priority_->name_ << " (" << child_priority_.get() + << "): deactivation timer fired, deleting child"; child_priority_->priority_policy_->DeleteChild(child_priority_.get()); } } @@ -554,14 +548,12 @@ void PriorityLb::ChildPriority::DeactivationTimer::OnTimerLocked() { PriorityLb::ChildPriority::FailoverTimer::FailoverTimer( RefCountedPtr child_priority) : child_priority_(std::move(child_priority)) { - if (GRPC_TRACE_FLAG_ENABLED(priority_lb)) { - LOG(INFO) - << "[priority_lb " << child_priority_->priority_policy_.get() - << "] child " << child_priority_->name_ << " (" << child_priority_.get() - << "): starting failover timer for " - << child_priority_->priority_policy_->child_failover_timeout_.millis() - << "ms"; - } + GRPC_TRACE_LOG(priority_lb, INFO) + << "[priority_lb " << child_priority_->priority_policy_.get() + << "] child " << child_priority_->name_ << " (" << child_priority_.get() + << "): starting failover timer for " + << child_priority_->priority_policy_->child_failover_timeout_.millis() + << "ms"; timer_handle_ = child_priority_->priority_policy_->channel_control_helper() ->GetEventEngine() @@ -594,12 +586,10 @@ void PriorityLb::ChildPriority::FailoverTimer::Orphan() { void PriorityLb::ChildPriority::FailoverTimer::OnTimerLocked() { if (timer_handle_.has_value()) { timer_handle_.reset(); - if (GRPC_TRACE_FLAG_ENABLED(priority_lb)) { - LOG(INFO) << "[priority_lb " << child_priority_->priority_policy_.get() - << "] child " << child_priority_->name_ << " (" - << child_priority_.get() - << "): failover timer fired, reporting TRANSIENT_FAILURE"; - } + GRPC_TRACE_LOG(priority_lb, INFO) + << "[priority_lb " << child_priority_->priority_policy_.get() + << "] child " << child_priority_->name_ << " (" << child_priority_.get() + << "): failover timer fired, reporting TRANSIENT_FAILURE"; child_priority_->OnConnectivityStateUpdateLocked( GRPC_CHANNEL_TRANSIENT_FAILURE, absl::Status(absl::StatusCode::kUnavailable, "failover timer fired"), @@ -716,12 +706,10 @@ void PriorityLb::ChildPriority::ResetBackoffLocked() { void PriorityLb::ChildPriority::OnConnectivityStateUpdateLocked( grpc_connectivity_state state, const absl::Status& status, RefCountedPtr picker) { - if (GRPC_TRACE_FLAG_ENABLED(priority_lb)) { - LOG(INFO) << "[priority_lb " << priority_policy_.get() << "] child " - << name_ << " (" << this - << "): state update: " << ConnectivityStateName(state) << " (" - << status << ") picker " << picker.get(); - } + GRPC_TRACE_LOG(priority_lb, INFO) + << "[priority_lb " << priority_policy_.get() << "] child " << name_ + << " (" << this << "): state update: " << ConnectivityStateName(state) + << " (" << status << ") picker " << picker.get(); // Store the state and picker. connectivity_state_ = state; connectivity_status_ = status; diff --git a/src/core/load_balancing/ring_hash/ring_hash.cc b/src/core/load_balancing/ring_hash/ring_hash.cc index f32f16ca159..da108603a04 100644 --- a/src/core/load_balancing/ring_hash/ring_hash.cc +++ b/src/core/load_balancing/ring_hash/ring_hash.cc @@ -570,15 +570,13 @@ absl::Status RingHash::RingHashEndpoint::UpdateChildPolicyLocked() { void RingHash::RingHashEndpoint::OnStateUpdate( grpc_connectivity_state new_state, const absl::Status& status, RefCountedPtr picker) { - if (GRPC_TRACE_FLAG_ENABLED(ring_hash_lb)) { - LOG(INFO) << "[RH " << ring_hash_.get() - << "] connectivity changed for endpoint " << this << " (" - << ring_hash_->endpoints_[index_].ToString() - << ", child_policy=" << child_policy_.get() - << "): prev_state=" << ConnectivityStateName(connectivity_state_) - << " new_state=" << ConnectivityStateName(new_state) << " (" - << status << ")"; - } + GRPC_TRACE_LOG(ring_hash_lb, INFO) + << "[RH " << ring_hash_.get() << "] connectivity changed for endpoint " + << this << " (" << ring_hash_->endpoints_[index_].ToString() + << ", child_policy=" << child_policy_.get() + << "): prev_state=" << ConnectivityStateName(connectivity_state_) + << " new_state=" << ConnectivityStateName(new_state) << " (" << status + << ")"; if (child_policy_ == nullptr) return; // Already orphaned. // Update state. const bool entered_transient_failure = @@ -756,15 +754,13 @@ void RingHash::UpdateAggregatedConnectivityStateLocked( state = GRPC_CHANNEL_TRANSIENT_FAILURE; start_connection_attempt = true; } - if (GRPC_TRACE_FLAG_ENABLED(ring_hash_lb)) { - LOG(INFO) << "[RH " << this << "] setting connectivity state to " - << ConnectivityStateName(state) << " (num_idle=" << num_idle - << ", num_connecting=" << num_connecting - << ", num_ready=" << num_ready - << ", num_transient_failure=" << num_transient_failure - << ", size=" << endpoints_.size() - << ") -- start_connection_attempt=" << start_connection_attempt; - } + GRPC_TRACE_LOG(ring_hash_lb, INFO) + << "[RH " << this << "] setting connectivity state to " + << ConnectivityStateName(state) << " (num_idle=" << num_idle + << ", num_connecting=" << num_connecting << ", num_ready=" << num_ready + << ", num_transient_failure=" << num_transient_failure + << ", size=" << endpoints_.size() + << ") -- start_connection_attempt=" << start_connection_attempt; // In TRANSIENT_FAILURE, report the last reported failure. // Otherwise, report OK. if (state == GRPC_CHANNEL_TRANSIENT_FAILURE) { @@ -833,13 +829,12 @@ void RingHash::UpdateAggregatedConnectivityStateLocked( auto it = endpoint_map_.find( EndpointAddressSet(endpoints_[first_idle_index].addresses())); CHECK(it != endpoint_map_.end()); - if (GRPC_TRACE_FLAG_ENABLED(ring_hash_lb)) { - LOG(INFO) << "[RH " << this - << "] triggering internal connection attempt for endpoint " - << it->second.get() << " (" - << endpoints_[first_idle_index].ToString() << ") (index " - << first_idle_index << " of " << endpoints_.size() << ")"; - } + GRPC_TRACE_LOG(ring_hash_lb, INFO) + << "[RH " << this + << "] triggering internal connection attempt for endpoint " + << it->second.get() << " (" << endpoints_[first_idle_index].ToString() + << ") (index " << first_idle_index << " of " << endpoints_.size() + << ")"; it->second->RequestConnectionLocked(); } } diff --git a/src/core/load_balancing/rls/rls.cc b/src/core/load_balancing/rls/rls.cc index ef2d44c4d28..9138d94e974 100644 --- a/src/core/load_balancing/rls/rls.cc +++ b/src/core/load_balancing/rls/rls.cc @@ -353,7 +353,8 @@ class RlsLb final : public LoadBalancingPolicy { // is called after releasing it. // // Both methods grab the data they need from the parent object. - void StartUpdate() ABSL_EXCLUSIVE_LOCKS_REQUIRED(&RlsLb::mu_); + void StartUpdate(OrphanablePtr* child_policy_to_delete) + ABSL_EXCLUSIVE_LOCKS_REQUIRED(&RlsLb::mu_); absl::Status MaybeFinishUpdate() ABSL_LOCKS_EXCLUDED(&RlsLb::mu_); void ExitIdleLocked() { @@ -397,14 +398,14 @@ class RlsLb final : public LoadBalancingPolicy { }; // Note: We are forced to disable lock analysis here because - // Orphan() is called by Unref() which is called by RefCountedPtr<>, which + // Orphaned() is called by Unref() which is called by RefCountedPtr<>, which // cannot have lock annotations for this particular caller. void Orphaned() override ABSL_NO_THREAD_SAFETY_ANALYSIS; RefCountedPtr lb_policy_; std::string target_; - bool is_shutdown_ = false; + bool is_shutdown_ = false; // Protected by WorkSerializer OrphanablePtr child_policy_; RefCountedPtr pending_config_; @@ -503,12 +504,25 @@ class RlsLb final : public LoadBalancingPolicy { // Returns a list of child policy wrappers on which FinishUpdate() // needs to be called after releasing the lock. std::vector OnRlsResponseLocked( - ResponseInfo response, std::unique_ptr backoff_state) + ResponseInfo response, std::unique_ptr backoff_state, + OrphanablePtr* child_policy_to_delete) ABSL_EXCLUSIVE_LOCKS_REQUIRED(&RlsLb::mu_); // Moves entry to the end of the LRU list. void MarkUsed() ABSL_EXCLUSIVE_LOCKS_REQUIRED(&RlsLb::mu_); + // Takes entries from child_policy_wrappers_ and appends them to the end + // of \a child_policy_wrappers. + void TakeChildPolicyWrappers( + std::vector>* child_policy_wrappers) + ABSL_EXCLUSIVE_LOCKS_REQUIRED(&RlsLb::mu_) { + child_policy_wrappers->insert( + child_policy_wrappers->end(), + std::make_move_iterator(child_policy_wrappers_.begin()), + std::make_move_iterator(child_policy_wrappers_.end())); + child_policy_wrappers_.clear(); + } + private: class BackoffTimer final : public InternallyRefCounted { public: @@ -566,19 +580,24 @@ class RlsLb final : public LoadBalancingPolicy { // the caller. Otherwise, the entry found is returned to the caller. The // entry returned to the user is considered recently used and its order in // the LRU list of the cache is updated. - Entry* FindOrInsert(const RequestKey& key) + Entry* FindOrInsert(const RequestKey& key, + std::vector>* + child_policy_wrappers_to_delete) ABSL_EXCLUSIVE_LOCKS_REQUIRED(&RlsLb::mu_); // Resizes the cache. If the new cache size is greater than the current size // of the cache, do nothing. Otherwise, evict the oldest entries that // exceed the new size limit of the cache. - void Resize(size_t bytes) ABSL_EXCLUSIVE_LOCKS_REQUIRED(&RlsLb::mu_); + void Resize(size_t bytes, std::vector>* + child_policy_wrappers_to_delete) + ABSL_EXCLUSIVE_LOCKS_REQUIRED(&RlsLb::mu_); // Resets backoff of all the cache entries. void ResetAllBackoff() ABSL_EXCLUSIVE_LOCKS_REQUIRED(&RlsLb::mu_); // Shutdown the cache; clean-up and orphan all the stored cache entries. - void Shutdown() ABSL_EXCLUSIVE_LOCKS_REQUIRED(&RlsLb::mu_); + GRPC_MUST_USE_RESULT std::vector> + Shutdown() ABSL_EXCLUSIVE_LOCKS_REQUIRED(&RlsLb::mu_); void ReportMetricsLocked(CallbackMetricReporter& reporter) ABSL_EXCLUSIVE_LOCKS_REQUIRED(&RlsLb::mu_); @@ -594,7 +613,9 @@ class RlsLb final : public LoadBalancingPolicy { // Evicts oversized cache elements when the current size is greater than // the specified limit. - void MaybeShrinkSize(size_t bytes) + void MaybeShrinkSize(size_t bytes, + std::vector>* + child_policy_wrappers_to_delete) ABSL_EXCLUSIVE_LOCKS_REQUIRED(&RlsLb::mu_); RlsLb* lb_policy_; @@ -857,18 +878,17 @@ absl::optional InsertOrUpdateChildPolicyField(const std::string& field, return Json::FromArray(std::move(array)); } -void RlsLb::ChildPolicyWrapper::StartUpdate() { +void RlsLb::ChildPolicyWrapper::StartUpdate( + OrphanablePtr* child_policy_to_delete) { ValidationErrors errors; auto child_policy_config = InsertOrUpdateChildPolicyField( lb_policy_->config_->child_policy_config_target_field_name(), target_, lb_policy_->config_->child_policy_config(), &errors); CHECK(child_policy_config.has_value()); - if (GRPC_TRACE_FLAG_ENABLED(rls_lb)) { - LOG(INFO) << "[rlslb " << lb_policy_.get() - << "] ChildPolicyWrapper=" << this << " [" << target_ - << "]: validating update, config: " - << JsonDump(*child_policy_config); - } + GRPC_TRACE_LOG(rls_lb, INFO) + << "[rlslb " << lb_policy_.get() << "] ChildPolicyWrapper=" << this + << " [" << target_ + << "]: validating update, config: " << JsonDump(*child_policy_config); auto config = CoreConfiguration::Get().lb_policy_registry().ParseLoadBalancingConfig( *child_policy_config); @@ -880,7 +900,7 @@ void RlsLb::ChildPolicyWrapper::StartUpdate() { pending_config_.reset(); picker_ = MakeRefCounted( absl::UnavailableError(config.status().message())); - child_policy_.reset(); + *child_policy_to_delete = std::move(child_policy_); } else { pending_config_ = std::move(*config); } @@ -899,12 +919,10 @@ absl::Status RlsLb::ChildPolicyWrapper::MaybeFinishUpdate() { create_args.args = lb_policy_->channel_args_; child_policy_ = MakeOrphanable(std::move(create_args), &rls_lb_trace); - if (GRPC_TRACE_FLAG_ENABLED(rls_lb)) { - LOG(INFO) << "[rlslb " << lb_policy_.get() - << "] ChildPolicyWrapper=" << this << " [" << target_ - << "], created new child policy handler " - << child_policy_.get(); - } + GRPC_TRACE_LOG(rls_lb, INFO) + << "[rlslb " << lb_policy_.get() << "] ChildPolicyWrapper=" << this + << " [" << target_ << "], created new child policy handler " + << child_policy_.get(); grpc_pollset_set_add_pollset_set(child_policy_->interested_parties(), lb_policy_->interested_parties()); } @@ -927,16 +945,15 @@ absl::Status RlsLb::ChildPolicyWrapper::MaybeFinishUpdate() { void RlsLb::ChildPolicyWrapper::ChildPolicyHelper::UpdateState( grpc_connectivity_state state, const absl::Status& status, RefCountedPtr picker) { - if (GRPC_TRACE_FLAG_ENABLED(rls_lb)) { - LOG(INFO) << "[rlslb " << wrapper_->lb_policy_.get() - << "] ChildPolicyWrapper=" << wrapper_.get() << " [" - << wrapper_->target_ << "] ChildPolicyHelper=" << this - << ": UpdateState(state=" << ConnectivityStateName(state) - << ", status=" << status << ", picker=" << picker.get() << ")"; - } + GRPC_TRACE_LOG(rls_lb, INFO) + << "[rlslb " << wrapper_->lb_policy_.get() + << "] ChildPolicyWrapper=" << wrapper_.get() << " [" << wrapper_->target_ + << "] ChildPolicyHelper=" << this + << ": UpdateState(state=" << ConnectivityStateName(state) + << ", status=" << status << ", picker=" << picker.get() << ")"; + if (wrapper_->is_shutdown_) return; { MutexLock lock(&wrapper_->lb_policy_->mu_); - if (wrapper_->is_shutdown_) return; // TODO(roth): It looks like this ignores subsequent TF updates that // might change the status used to fail picks, which seems wrong. if (wrapper_->connectivity_state_ == GRPC_CHANNEL_TRANSIENT_FAILURE && @@ -946,7 +963,8 @@ void RlsLb::ChildPolicyWrapper::ChildPolicyHelper::UpdateState( wrapper_->connectivity_state_ = state; DCHECK(picker != nullptr); if (picker != nullptr) { - wrapper_->picker_ = std::move(picker); + // We want to unref the picker after we release the lock. + wrapper_->picker_.swap(picker); } } wrapper_->lb_policy_->UpdatePickerLocked(); @@ -1139,13 +1157,12 @@ void RlsLb::Cache::Entry::BackoffTimer::Orphan() { if (backoff_timer_task_handle_.has_value() && entry_->lb_policy_->channel_control_helper()->GetEventEngine()->Cancel( *backoff_timer_task_handle_)) { - if (GRPC_TRACE_FLAG_ENABLED(rls_lb)) { - LOG(INFO) << "[rlslb " << entry_->lb_policy_.get() - << "] cache entry=" << entry_.get() << " " - << (entry_->is_shutdown_ ? "(shut down)" - : entry_->lru_iterator_->ToString()) - << ", backoff timer canceled"; - } + GRPC_TRACE_LOG(rls_lb, INFO) + << "[rlslb " << entry_->lb_policy_.get() + << "] cache entry=" << entry_.get() << " " + << (entry_->is_shutdown_ ? "(shut down)" + : entry_->lru_iterator_->ToString()) + << ", backoff timer canceled"; } backoff_timer_task_handle_.reset(); Unref(DEBUG_LOCATION, "Orphan"); @@ -1154,13 +1171,12 @@ void RlsLb::Cache::Entry::BackoffTimer::Orphan() { void RlsLb::Cache::Entry::BackoffTimer::OnBackoffTimerLocked() { { MutexLock lock(&entry_->lb_policy_->mu_); - if (GRPC_TRACE_FLAG_ENABLED(rls_lb)) { - LOG(INFO) << "[rlslb " << entry_->lb_policy_.get() - << "] cache entry=" << entry_.get() << " " - << (entry_->is_shutdown_ ? "(shut down)" - : entry_->lru_iterator_->ToString()) - << ", backoff timer fired"; - } + GRPC_TRACE_LOG(rls_lb, INFO) + << "[rlslb " << entry_->lb_policy_.get() + << "] cache entry=" << entry_.get() << " " + << (entry_->is_shutdown_ ? "(shut down)" + : entry_->lru_iterator_->ToString()) + << ", backoff timer fired"; // Skip the update if Orphaned if (!backoff_timer_task_handle_.has_value()) return; backoff_timer_task_handle_.reset(); @@ -1194,18 +1210,19 @@ RlsLb::Cache::Entry::Entry(RefCountedPtr lb_policy, lb_policy_->cache_.lru_list_.end(), key)) {} void RlsLb::Cache::Entry::Orphan() { + // We should be holding RlsLB::mu_. GRPC_TRACE_LOG(rls_lb, INFO) << "[rlslb " << lb_policy_.get() << "] cache entry=" << this << " " << lru_iterator_->ToString() << ": cache entry evicted"; is_shutdown_ = true; lb_policy_->cache_.lru_list_.erase(lru_iterator_); lru_iterator_ = lb_policy_->cache_.lru_list_.end(); // Just in case. + CHECK(child_policy_wrappers_.empty()); backoff_state_.reset(); if (backoff_timer_ != nullptr) { backoff_timer_.reset(); lb_policy_->UpdatePickerAsync(); } - child_policy_wrappers_.clear(); Unref(DEBUG_LOCATION, "Orphan"); } @@ -1224,28 +1241,25 @@ LoadBalancingPolicy::PickResult RlsLb::Cache::Entry::Pick(PickArgs args) { if (child_policy_wrapper->connectivity_state() == GRPC_CHANNEL_TRANSIENT_FAILURE && i < child_policy_wrappers_.size() - 1) { - if (GRPC_TRACE_FLAG_ENABLED(rls_lb)) { - LOG(INFO) << "[rlslb " << lb_policy_.get() << "] cache entry=" << this - << " " << lru_iterator_->ToString() << ": target " - << child_policy_wrapper->target() << " (" << i << " of " - << child_policy_wrappers_.size() - << ") in state TRANSIENT_FAILURE; skipping"; - } + GRPC_TRACE_LOG(rls_lb, INFO) + << "[rlslb " << lb_policy_.get() << "] cache entry=" << this << " " + << lru_iterator_->ToString() << ": target " + << child_policy_wrapper->target() << " (" << i << " of " + << child_policy_wrappers_.size() + << ") in state TRANSIENT_FAILURE; skipping"; continue; } break; } // Child policy not in TRANSIENT_FAILURE or is the last target in // the list, so delegate. - if (GRPC_TRACE_FLAG_ENABLED(rls_lb)) { - LOG(INFO) << "[rlslb " << lb_policy_.get() << "] cache entry=" << this - << " " << lru_iterator_->ToString() << ": target " - << child_policy_wrapper->target() << " (" << i << " of " - << child_policy_wrappers_.size() << ") in state " - << ConnectivityStateName( - child_policy_wrapper->connectivity_state()) - << "; delegating"; - } + GRPC_TRACE_LOG(rls_lb, INFO) + << "[rlslb " << lb_policy_.get() << "] cache entry=" << this << " " + << lru_iterator_->ToString() << ": target " + << child_policy_wrapper->target() << " (" << i << " of " + << child_policy_wrappers_.size() << ") in state " + << ConnectivityStateName(child_policy_wrapper->connectivity_state()) + << "; delegating"; auto pick_result = child_policy_wrapper->Pick(args); lb_policy_->MaybeExportPickCount(kMetricTargetPicks, child_policy_wrapper->target(), pick_result); @@ -1284,7 +1298,8 @@ void RlsLb::Cache::Entry::MarkUsed() { std::vector RlsLb::Cache::Entry::OnRlsResponseLocked( - ResponseInfo response, std::unique_ptr backoff_state) { + ResponseInfo response, std::unique_ptr backoff_state, + OrphanablePtr* child_policy_to_delete) { // Move the entry to the end of the LRU list. MarkUsed(); // If the request failed, store the failed status and update the @@ -1345,7 +1360,7 @@ RlsLb::Cache::Entry::OnRlsResponseLocked( if (it == lb_policy_->child_policy_map_.end()) { auto new_child = MakeRefCounted( lb_policy_.Ref(DEBUG_LOCATION, "ChildPolicyWrapper"), target); - new_child->StartUpdate(); + new_child->StartUpdate(child_policy_to_delete); child_policies_to_finish_update.push_back(new_child.get()); new_child_policy_wrappers.emplace_back(std::move(new_child)); } else { @@ -1382,12 +1397,15 @@ RlsLb::Cache::Entry* RlsLb::Cache::Find(const RequestKey& key) { return it->second.get(); } -RlsLb::Cache::Entry* RlsLb::Cache::FindOrInsert(const RequestKey& key) { +RlsLb::Cache::Entry* RlsLb::Cache::FindOrInsert( + const RequestKey& key, std::vector>* + child_policy_wrappers_to_delete) { auto it = map_.find(key); // If not found, create new entry. if (it == map_.end()) { size_t entry_size = EntrySizeForKey(key); - MaybeShrinkSize(size_limit_ - std::min(size_limit_, entry_size)); + MaybeShrinkSize(size_limit_ - std::min(size_limit_, entry_size), + child_policy_wrappers_to_delete); Entry* entry = new Entry( lb_policy_->RefAsSubclass(DEBUG_LOCATION, "CacheEntry"), key); map_.emplace(key, OrphanablePtr(entry)); @@ -1405,11 +1423,13 @@ RlsLb::Cache::Entry* RlsLb::Cache::FindOrInsert(const RequestKey& key) { return it->second.get(); } -void RlsLb::Cache::Resize(size_t bytes) { +void RlsLb::Cache::Resize(size_t bytes, + std::vector>* + child_policy_wrappers_to_delete) { GRPC_TRACE_LOG(rls_lb, INFO) << "[rlslb " << lb_policy_ << "] resizing cache to " << bytes << " bytes"; size_limit_ = bytes; - MaybeShrinkSize(size_limit_); + MaybeShrinkSize(size_limit_, child_policy_wrappers_to_delete); } void RlsLb::Cache::ResetAllBackoff() { @@ -1419,7 +1439,12 @@ void RlsLb::Cache::ResetAllBackoff() { lb_policy_->UpdatePickerAsync(); } -void RlsLb::Cache::Shutdown() { +std::vector> RlsLb::Cache::Shutdown() { + std::vector> + child_policy_wrappers_to_delete; + for (auto& entry : map_) { + entry.second->TakeChildPolicyWrappers(&child_policy_wrappers_to_delete); + } map_.clear(); lru_list_.clear(); if (cleanup_timer_handle_.has_value() && @@ -1429,6 +1454,7 @@ void RlsLb::Cache::Shutdown() { << "[rlslb " << lb_policy_ << "] cache cleanup timer canceled"; } cleanup_timer_handle_.reset(); + return child_policy_wrappers_to_delete; } void RlsLb::Cache::ReportMetricsLocked(CallbackMetricReporter& reporter) { @@ -1464,12 +1490,15 @@ void RlsLb::Cache::StartCleanupTimer() { void RlsLb::Cache::OnCleanupTimer() { GRPC_TRACE_LOG(rls_lb, INFO) << "[rlslb " << lb_policy_ << "] cache cleanup timer fired"; + std::vector> + child_policy_wrappers_to_delete; MutexLock lock(&lb_policy_->mu_); if (!cleanup_timer_handle_.has_value()) return; if (lb_policy_->is_shutdown_) return; for (auto it = map_.begin(); it != map_.end();) { if (GPR_UNLIKELY(it->second->ShouldRemove() && it->second->CanEvict())) { size_ -= it->second->Size(); + it->second->TakeChildPolicyWrappers(&child_policy_wrappers_to_delete); it = map_.erase(it); } else { ++it; @@ -1483,7 +1512,9 @@ size_t RlsLb::Cache::EntrySizeForKey(const RequestKey& key) { return (key.Size() * 2) + sizeof(Entry); } -void RlsLb::Cache::MaybeShrinkSize(size_t bytes) { +void RlsLb::Cache::MaybeShrinkSize( + size_t bytes, std::vector>* + child_policy_wrappers_to_delete) { while (size_ > bytes) { auto lru_it = lru_list_.begin(); if (GPR_UNLIKELY(lru_it == lru_list_.end())) break; @@ -1494,6 +1525,7 @@ void RlsLb::Cache::MaybeShrinkSize(size_t bytes) { << "[rlslb " << lb_policy_ << "] LRU eviction: removing entry " << map_it->second.get() << " " << lru_it->ToString(); size_ -= map_it->second->Size(); + map_it->second->TakeChildPolicyWrappers(child_policy_wrappers_to_delete); map_.erase(map_it); } GRPC_TRACE_LOG(rls_lb, INFO) @@ -1814,13 +1846,18 @@ void RlsLb::RlsRequest::OnRlsCallCompleteLocked(grpc_error_handle error) { << "[rlslb " << lb_policy_.get() << "] rls_request=" << this << " " << key_.ToString() << ": response info: " << response.ToString(); std::vector child_policies_to_finish_update; + std::vector> + child_policy_wrappers_to_delete; + OrphanablePtr child_policy_to_delete; { MutexLock lock(&lb_policy_->mu_); if (lb_policy_->is_shutdown_) return; rls_channel_->ReportResponseLocked(response.status.ok()); - Cache::Entry* cache_entry = lb_policy_->cache_.FindOrInsert(key_); + Cache::Entry* cache_entry = + lb_policy_->cache_.FindOrInsert(key_, &child_policy_wrappers_to_delete); child_policies_to_finish_update = cache_entry->OnRlsResponseLocked( - std::move(response), std::move(backoff_state_)); + std::move(response), std::move(backoff_state_), + &child_policy_to_delete); lb_policy_->request_map_.erase(key_); } // Now that we've released the lock, finish the update on any newly @@ -1919,14 +1956,7 @@ RlsLb::RlsLb(Args args) instance_uuid_(channel_args() .GetOwnedString(GRPC_ARG_TEST_ONLY_RLS_INSTANCE_ID) .value_or(GenerateUUID())), - cache_(this), - registered_metric_callback_( - channel_control_helper()->GetStatsPluginGroup().RegisterCallback( - [this](CallbackMetricReporter& reporter) { - MutexLock lock(&mu_); - cache_.ReportMetricsLocked(reporter); - }, - Duration::Seconds(5), kMetricCacheSize, kMetricCacheEntries)) { + cache_(this) { GRPC_TRACE_LOG(rls_lb, INFO) << "[rlslb " << this << "] policy created"; } @@ -2006,6 +2036,9 @@ absl::Status RlsLb::UpdateLocked(UpdateArgs args) { } } // Now grab the lock to swap out the state it guards. + std::vector> + child_policy_wrappers_to_delete; + OrphanablePtr child_policy_to_delete; { MutexLock lock(&mu_); // Swap out RLS channel if needed. @@ -2017,19 +2050,20 @@ absl::Status RlsLb::UpdateLocked(UpdateArgs args) { // Resize cache if needed. if (old_config == nullptr || config_->cache_size_bytes() != old_config->cache_size_bytes()) { - cache_.Resize(static_cast(config_->cache_size_bytes())); + cache_.Resize(static_cast(config_->cache_size_bytes()), + &child_policy_wrappers_to_delete); } // Start update of child policies if needed. if (update_child_policies) { GRPC_TRACE_LOG(rls_lb, INFO) << "[rlslb " << this << "] starting child policy updates"; for (auto& p : child_policy_map_) { - p.second->StartUpdate(); + p.second->StartUpdate(&child_policy_to_delete); } } else if (created_default_child) { GRPC_TRACE_LOG(rls_lb, INFO) << "[rlslb " << this << "] starting default child policy update"; - default_child_policy_->StartUpdate(); + default_child_policy_->StartUpdate(&child_policy_to_delete); } } // Now that we've released the lock, finish update of child policies. @@ -2054,6 +2088,20 @@ absl::Status RlsLb::UpdateLocked(UpdateArgs args) { } } update_in_progress_ = false; + // On the initial update only, we set the gauge metric callback. We + // can't do this before the initial update, because otherwise the + // callback could be invoked before we've set state that we need for + // the label values (e.g., we'd add metrics with empty string for the + // RLS server name). + if (registered_metric_callback_ == nullptr) { + registered_metric_callback_ = + channel_control_helper()->GetStatsPluginGroup().RegisterCallback( + [this](CallbackMetricReporter& reporter) { + MutexLock lock(&mu_); + cache_.ReportMetricsLocked(reporter); + }, + Duration::Seconds(5), kMetricCacheSize, kMetricCacheEntries); + } // In principle, we need to update the picker here only if the config // fields used by the picker have changed. However, it seems fragile // to check individual fields, since the picker logic could change in @@ -2090,14 +2138,20 @@ void RlsLb::ResetBackoffLocked() { void RlsLb::ShutdownLocked() { GRPC_TRACE_LOG(rls_lb, INFO) << "[rlslb " << this << "] policy shutdown"; registered_metric_callback_.reset(); - MutexLock lock(&mu_); - is_shutdown_ = true; - config_.reset(DEBUG_LOCATION, "ShutdownLocked"); + RefCountedPtr child_policy_to_delete; + std::vector> + child_policy_wrappers_to_delete; + OrphanablePtr rls_channel_to_delete; + { + MutexLock lock(&mu_); + is_shutdown_ = true; + config_.reset(DEBUG_LOCATION, "ShutdownLocked"); + child_policy_wrappers_to_delete = cache_.Shutdown(); + request_map_.clear(); + rls_channel_to_delete = std::move(rls_channel_); + child_policy_to_delete = std::move(default_child_policy_); + } channel_args_ = ChannelArgs(); - cache_.Shutdown(); - request_map_.clear(); - rls_channel_.reset(); - default_child_policy_.reset(); } void RlsLb::UpdatePickerAsync() { diff --git a/src/core/load_balancing/round_robin/round_robin.cc b/src/core/load_balancing/round_robin/round_robin.cc index d3cc4579a48..64ff5c3e621 100644 --- a/src/core/load_balancing/round_robin/round_robin.cc +++ b/src/core/load_balancing/round_robin/round_robin.cc @@ -185,12 +185,11 @@ RoundRobin::Picker::Picker( // the picker, see https://github.com/grpc/grpc-go/issues/2580. size_t index = absl::Uniform(parent->bit_gen_, 0, pickers_.size()); last_picked_index_.store(index, std::memory_order_relaxed); - if (GRPC_TRACE_FLAG_ENABLED(round_robin)) { - LOG(INFO) << "[RR " << parent_ << " picker " << this - << "] created picker from endpoint_list=" - << parent_->endpoint_list_.get() << " with " << pickers_.size() - << " READY children; last_picked_index_=" << index; - } + GRPC_TRACE_LOG(round_robin, INFO) + << "[RR " << parent_ << " picker " << this + << "] created picker from endpoint_list=" << parent_->endpoint_list_.get() + << " with " << pickers_.size() + << " READY children; last_picked_index_=" << index; } RoundRobin::PickResult RoundRobin::Picker::Pick(PickArgs args) { @@ -292,16 +291,13 @@ void RoundRobin::RoundRobinEndpointList::RoundRobinEndpoint::OnStateUpdate( grpc_connectivity_state new_state, const absl::Status& status) { auto* rr_endpoint_list = endpoint_list(); auto* round_robin = policy(); - if (GRPC_TRACE_FLAG_ENABLED(round_robin)) { - LOG(INFO) << "[RR " << round_robin << "] connectivity changed for child " - << this << ", endpoint_list " << rr_endpoint_list << " (index " - << Index() << " of " << rr_endpoint_list->size() - << "): prev_state=" - << (old_state.has_value() ? ConnectivityStateName(*old_state) - : "N/A") - << " new_state=" << ConnectivityStateName(new_state) << " (" - << status << ")"; - } + GRPC_TRACE_LOG(round_robin, INFO) + << "[RR " << round_robin << "] connectivity changed for child " << this + << ", endpoint_list " << rr_endpoint_list << " (index " << Index() + << " of " << rr_endpoint_list->size() << "): prev_state=" + << (old_state.has_value() ? ConnectivityStateName(*old_state) : "N/A") + << " new_state=" << ConnectivityStateName(new_state) << " (" << status + << ")"; if (new_state == GRPC_CHANNEL_IDLE) { GRPC_TRACE_LOG(round_robin, INFO) << "[RR " << round_robin << "] child " << this diff --git a/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc b/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc index fe2d9721b37..144f1b00888 100644 --- a/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc +++ b/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc @@ -447,28 +447,24 @@ void WeightedRoundRobin::EndpointWeight::MaybeUpdateWeight( weight = qps / (utilization + penalty); } if (weight == 0) { - if (GRPC_TRACE_FLAG_ENABLED(weighted_round_robin_lb)) { - LOG(INFO) << "[WRR " << wrr_.get() << "] subchannel " << key_.ToString() - << ": qps=" << qps << ", eps=" << eps - << ", utilization=" << utilization - << ": error_util_penalty=" << error_utilization_penalty - << ", weight=" << weight << " (not updating)"; - } + GRPC_TRACE_LOG(weighted_round_robin_lb, INFO) + << "[WRR " << wrr_.get() << "] subchannel " << key_.ToString() + << ": qps=" << qps << ", eps=" << eps << ", utilization=" << utilization + << ": error_util_penalty=" << error_utilization_penalty + << ", weight=" << weight << " (not updating)"; return; } Timestamp now = Timestamp::Now(); // Grab the lock and update the data. MutexLock lock(&mu_); - if (GRPC_TRACE_FLAG_ENABLED(weighted_round_robin_lb)) { - LOG(INFO) << "[WRR " << wrr_.get() << "] subchannel " << key_.ToString() - << ": qps=" << qps << ", eps=" << eps - << ", utilization=" << utilization - << " error_util_penalty=" << error_utilization_penalty - << " : setting weight=" << weight << " weight_=" << weight_ - << " now=" << now.ToString() - << " last_update_time_=" << last_update_time_.ToString() - << " non_empty_since_=" << non_empty_since_.ToString(); - } + GRPC_TRACE_LOG(weighted_round_robin_lb, INFO) + << "[WRR " << wrr_.get() << "] subchannel " << key_.ToString() + << ": qps=" << qps << ", eps=" << eps << ", utilization=" << utilization + << " error_util_penalty=" << error_utilization_penalty + << " : setting weight=" << weight << " weight_=" << weight_ + << " now=" << now.ToString() + << " last_update_time_=" << last_update_time_.ToString() + << " non_empty_since_=" << non_empty_since_.ToString(); if (non_empty_since_ == Timestamp::InfFuture()) non_empty_since_ = now; weight_ = weight; last_update_time_ = now; @@ -478,16 +474,14 @@ float WeightedRoundRobin::EndpointWeight::GetWeight( Timestamp now, Duration weight_expiration_period, Duration blackout_period, uint64_t* num_not_yet_usable, uint64_t* num_stale) { MutexLock lock(&mu_); - if (GRPC_TRACE_FLAG_ENABLED(weighted_round_robin_lb)) { - LOG(INFO) << "[WRR " << wrr_.get() << "] subchannel " << key_.ToString() - << ": getting weight: now=" << now.ToString() - << " weight_expiration_period=" - << weight_expiration_period.ToString() - << " blackout_period=" << blackout_period.ToString() - << " last_update_time_=" << last_update_time_.ToString() - << " non_empty_since_=" << non_empty_since_.ToString() - << " weight_=" << weight_; - } + GRPC_TRACE_LOG(weighted_round_robin_lb, INFO) + << "[WRR " << wrr_.get() << "] subchannel " << key_.ToString() + << ": getting weight: now=" << now.ToString() + << " weight_expiration_period=" << weight_expiration_period.ToString() + << " blackout_period=" << blackout_period.ToString() + << " last_update_time_=" << last_update_time_.ToString() + << " non_empty_since_=" << non_empty_since_.ToString() + << " weight_=" << weight_; // If the most recent update was longer ago than the expiration // period, reset non_empty_since_ so that we apply the blackout period // again if we start getting data again in the future, and return 0. @@ -865,16 +859,13 @@ void WeightedRoundRobin::WrrEndpointList::WrrEndpoint::OnStateUpdate( grpc_connectivity_state new_state, const absl::Status& status) { auto* wrr_endpoint_list = endpoint_list(); auto* wrr = policy(); - if (GRPC_TRACE_FLAG_ENABLED(weighted_round_robin_lb)) { - LOG(INFO) << "[WRR " << wrr << "] connectivity changed for child " << this - << ", endpoint_list " << wrr_endpoint_list << " (index " - << Index() << " of " << wrr_endpoint_list->size() - << "): prev_state=" - << (old_state.has_value() ? ConnectivityStateName(*old_state) - : "N/A") - << " new_state=" << ConnectivityStateName(new_state) << " (" - << status << ")"; - } + GRPC_TRACE_LOG(weighted_round_robin_lb, INFO) + << "[WRR " << wrr << "] connectivity changed for child " << this + << ", endpoint_list " << wrr_endpoint_list << " (index " << Index() + << " of " << wrr_endpoint_list->size() << "): prev_state=" + << (old_state.has_value() ? ConnectivityStateName(*old_state) : "N/A") + << " new_state=" << ConnectivityStateName(new_state) << " (" << status + << ")"; if (new_state == GRPC_CHANNEL_IDLE) { GRPC_TRACE_LOG(weighted_round_robin_lb, INFO) << "[WRR " << wrr << "] child " << this diff --git a/src/core/load_balancing/weighted_target/weighted_target.cc b/src/core/load_balancing/weighted_target/weighted_target.cc index dc9e3f9ce11..9724720fc65 100644 --- a/src/core/load_balancing/weighted_target/weighted_target.cc +++ b/src/core/load_balancing/weighted_target/weighted_target.cc @@ -402,13 +402,10 @@ void WeightedTargetLb::UpdateStateLocked() { continue; } auto child_picker = child->picker(); - if (GRPC_TRACE_FLAG_ENABLED(weighted_target_lb)) { - LOG(INFO) << "[weighted_target_lb " << this << "] child=" << child_name - << " state=" - << ConnectivityStateName(child->connectivity_state()) - << " weight=" << child->weight() - << " picker=" << child_picker.get(); - } + GRPC_TRACE_LOG(weighted_target_lb, INFO) + << "[weighted_target_lb " << this << "] child=" << child_name + << " state=" << ConnectivityStateName(child->connectivity_state()) + << " weight=" << child->weight() << " picker=" << child_picker.get(); switch (child->connectivity_state()) { case GRPC_CHANNEL_READY: { CHECK_GT(child->weight(), 0u); @@ -488,13 +485,11 @@ WeightedTargetLb::WeightedChild::DelayedRemovalTimer::DelayedRemovalTimer( void WeightedTargetLb::WeightedChild::DelayedRemovalTimer::Orphan() { if (timer_handle_.has_value()) { - if (GRPC_TRACE_FLAG_ENABLED(weighted_target_lb)) { - LOG(INFO) << "[weighted_target_lb " - << weighted_child_->weighted_target_policy_.get() - << "] WeightedChild " << weighted_child_.get() << " " - << weighted_child_->name_ - << ": cancelling delayed removal timer"; - } + GRPC_TRACE_LOG(weighted_target_lb, INFO) + << "[weighted_target_lb " + << weighted_child_->weighted_target_policy_.get() << "] WeightedChild " + << weighted_child_.get() << " " << weighted_child_->name_ + << ": cancelling delayed removal timer"; weighted_child_->weighted_target_policy_->channel_control_helper() ->GetEventEngine() ->Cancel(*timer_handle_); @@ -619,13 +614,11 @@ void WeightedTargetLb::WeightedChild::OnConnectivityStateUpdateLocked( RefCountedPtr picker) { // Cache the picker in the WeightedChild. picker_ = std::move(picker); - if (GRPC_TRACE_FLAG_ENABLED(weighted_target_lb)) { - LOG(INFO) << "[weighted_target_lb " << weighted_target_policy_.get() - << "] WeightedChild " << this << " " << name_ - << ": connectivity state update: state=" - << ConnectivityStateName(state) << " (" << status - << ") picker=" << picker_.get(); - } + GRPC_TRACE_LOG(weighted_target_lb, INFO) + << "[weighted_target_lb " << weighted_target_policy_.get() + << "] WeightedChild " << this << " " << name_ + << ": connectivity state update: state=" << ConnectivityStateName(state) + << " (" << status << ") picker=" << picker_.get(); // If the child reports IDLE, immediately tell it to exit idle. if (state == GRPC_CHANNEL_IDLE) child_policy_->ExitIdleLocked(); // Decide what state to report for aggregation purposes. diff --git a/src/core/load_balancing/xds/xds_cluster_impl.cc b/src/core/load_balancing/xds/xds_cluster_impl.cc index 9a06ab8eeb1..78ba63d16fe 100644 --- a/src/core/load_balancing/xds/xds_cluster_impl.cc +++ b/src/core/load_balancing/xds/xds_cluster_impl.cc @@ -741,12 +741,10 @@ void XdsClusterImplLb::MaybeUpdatePickerLocked() { // Otherwise, update only if we have a child picker. if (picker_ != nullptr) { auto drop_picker = MakeRefCounted(this, picker_); - if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_impl_lb)) { - LOG(INFO) << "[xds_cluster_impl_lb " << this - << "] updating connectivity: state=" - << ConnectivityStateName(state_) << " status=(" << status_ - << ") picker=" << drop_picker.get(); - } + GRPC_TRACE_LOG(xds_cluster_impl_lb, INFO) + << "[xds_cluster_impl_lb " << this + << "] updating connectivity: state=" << ConnectivityStateName(state_) + << " status=(" << status_ << ") picker=" << drop_picker.get(); channel_control_helper()->UpdateState(state_, status_, std::move(drop_picker)); } @@ -841,12 +839,11 @@ void XdsClusterImplLb::Helper::UpdateState( grpc_connectivity_state state, const absl::Status& status, RefCountedPtr picker) { if (parent()->shutting_down_) return; - if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_impl_lb)) { - LOG(INFO) << "[xds_cluster_impl_lb " << parent() - << "] child connectivity state update: state=" - << ConnectivityStateName(state) << " (" << status - << ") picker=" << picker.get(); - } + GRPC_TRACE_LOG(xds_cluster_impl_lb, INFO) + << "[xds_cluster_impl_lb " << parent() + << "] child connectivity state update: state=" + << ConnectivityStateName(state) << " (" << status + << ") picker=" << picker.get(); // Save the state and picker. parent()->state_ = state; parent()->status_ = status; diff --git a/src/core/load_balancing/xds/xds_cluster_manager.cc b/src/core/load_balancing/xds/xds_cluster_manager.cc index ec5aeb47b62..5d3dfd9e8bc 100644 --- a/src/core/load_balancing/xds/xds_cluster_manager.cc +++ b/src/core/load_balancing/xds/xds_cluster_manager.cc @@ -531,13 +531,12 @@ void XdsClusterManagerLb::ClusterChild::OnDelayedRemovalTimerLocked() { void XdsClusterManagerLb::ClusterChild::Helper::UpdateState( grpc_connectivity_state state, const absl::Status& status, RefCountedPtr picker) { - if (GRPC_TRACE_FLAG_ENABLED(xds_cluster_manager_lb)) { - LOG(INFO) << "[xds_cluster_manager_lb " - << xds_cluster_manager_child_->xds_cluster_manager_policy_.get() - << "] child " << xds_cluster_manager_child_->name_ - << ": received update: state=" << ConnectivityStateName(state) - << " (" << status << ") picker=" << picker.get(); - } + GRPC_TRACE_LOG(xds_cluster_manager_lb, INFO) + << "[xds_cluster_manager_lb " + << xds_cluster_manager_child_->xds_cluster_manager_policy_.get() + << "] child " << xds_cluster_manager_child_->name_ + << ": received update: state=" << ConnectivityStateName(state) << " (" + << status << ") picker=" << picker.get(); if (xds_cluster_manager_child_->xds_cluster_manager_policy_->shutting_down_) { return; } diff --git a/src/core/load_balancing/xds/xds_override_host.cc b/src/core/load_balancing/xds/xds_override_host.cc index dbd8ff9b479..a3de3e6b97c 100644 --- a/src/core/load_balancing/xds/xds_override_host.cc +++ b/src/core/load_balancing/xds/xds_override_host.cc @@ -759,13 +759,10 @@ absl::Status XdsOverrideHostLb::UpdateLocked(UpdateArgs args) { args_ = std::move(args.args); override_host_status_set_ = it->second->cluster->override_host_statuses; connection_idle_timeout_ = it->second->cluster->connection_idle_timeout; - if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) { - LOG(INFO) << "[xds_override_host_lb " << this - << "] override host status set: " - << override_host_status_set_.ToString() - << " connection idle timeout: " - << connection_idle_timeout_.ToString(); - } + GRPC_TRACE_LOG(xds_override_host_lb, INFO) + << "[xds_override_host_lb " << this + << "] override host status set: " << override_host_status_set_.ToString() + << " connection idle timeout: " << connection_idle_timeout_.ToString(); // Update address map and wrap endpoint iterator for child policy. if (args.addresses.ok()) { UpdateAddressMap(**args.addresses); @@ -796,12 +793,11 @@ void XdsOverrideHostLb::MaybeUpdatePickerLocked() { if (picker_ != nullptr) { auto xds_override_host_picker = MakeRefCounted( RefAsSubclass(), picker_, override_host_status_set_); - if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) { - LOG(INFO) << "[xds_override_host_lb " << this - << "] updating connectivity: state=" - << ConnectivityStateName(state_) << " status=(" << status_ - << ") picker=" << xds_override_host_picker.get(); - } + GRPC_TRACE_LOG(xds_override_host_lb, INFO) + << "[xds_override_host_lb " << this + << "] updating connectivity: state=" << ConnectivityStateName(state_) + << " status=(" << status_ + << ") picker=" << xds_override_host_picker.get(); channel_control_helper()->UpdateState(state_, status_, std::move(xds_override_host_picker)); } @@ -843,12 +839,11 @@ void XdsOverrideHostLb::UpdateAddressMap( // Skip draining hosts if not in the override status set. if (status.status() == XdsHealthStatus::kDraining && !override_host_status_set_.Contains(status)) { - if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) { - LOG(INFO) << "[xds_override_host_lb " << this << "] endpoint " - << endpoint.ToString() - << ": draining but not in override_host_status set -- " - "ignoring"; - } + GRPC_TRACE_LOG(xds_override_host_lb, INFO) + << "[xds_override_host_lb " << this << "] endpoint " + << endpoint.ToString() + << ": draining but not in override_host_status set -- " + "ignoring"; return; } std::vector addresses; @@ -905,13 +900,11 @@ void XdsOverrideHostLb::UpdateAddressMap( it = subchannel_map_.emplace(address, MakeRefCounted()) .first; } - if (GRPC_TRACE_FLAG_ENABLED(xds_override_host_lb)) { - LOG(INFO) << "[xds_override_host_lb " << this << "] map key " << address - << ": setting " - << "eds_health_status=" - << address_info.eds_health_status.ToString() - << " address_list=" << address_info.address_list.c_str(); - } + GRPC_TRACE_LOG(xds_override_host_lb, INFO) + << "[xds_override_host_lb " << this << "] map key " << address + << ": setting " + << "eds_health_status=" << address_info.eds_health_status.ToString() + << " address_list=" << address_info.address_list.c_str(); it->second->set_eds_health_status(address_info.eds_health_status); it->second->set_address_list(std::move(address_info.address_list)); // Check the entry's last_used_time to determine the next time at diff --git a/src/core/resolver/xds/xds_resolver.cc b/src/core/resolver/xds/xds_resolver.cc index 53c218a29ec..a8880674c4d 100644 --- a/src/core/resolver/xds/xds_resolver.cc +++ b/src/core/resolver/xds/xds_resolver.cc @@ -1076,12 +1076,11 @@ void XdsResolver::GenerateResult() { Result result; result.addresses.emplace(); result.service_config = CreateServiceConfig(); - if (GRPC_TRACE_FLAG_ENABLED(xds_resolver)) { - LOG(INFO) << "[xds_resolver " << this << "] generated service config: " - << (result.service_config.ok() - ? ((*result.service_config)->json_string()) - : result.service_config.status().ToString()); - } + GRPC_TRACE_LOG(xds_resolver, INFO) + << "[xds_resolver " << this << "] generated service config: " + << (result.service_config.ok() + ? ((*result.service_config)->json_string()) + : result.service_config.status().ToString()); result.args = args_.SetObject(xds_client_.Ref(DEBUG_LOCATION, "xds resolver result")) .SetObject(config_selector) diff --git a/src/core/util/alloc.cc b/src/core/util/alloc.cc index a8b92260a92..6afba483d4c 100644 --- a/src/core/util/alloc.cc +++ b/src/core/util/alloc.cc @@ -24,7 +24,6 @@ #include "absl/log/check.h" #include -#include #include "src/core/lib/gprpp/crash.h" diff --git a/src/core/util/gcp_metadata_query.cc b/src/core/util/gcp_metadata_query.cc index db2c382bead..351f6e7a578 100644 --- a/src/core/util/gcp_metadata_query.cc +++ b/src/core/util/gcp_metadata_query.cc @@ -35,7 +35,6 @@ #include #include #include -#include #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" diff --git a/src/core/util/http_client/httpcli.cc b/src/core/util/http_client/httpcli.cc index d60b1cd68b1..e262e149ea9 100644 --- a/src/core/util/http_client/httpcli.cc +++ b/src/core/util/http_client/httpcli.cc @@ -33,7 +33,6 @@ #include #include #include -#include #include "src/core/handshaker/handshaker.h" #include "src/core/handshaker/handshaker_registry.h" diff --git a/src/core/util/json/json_reader.cc b/src/core/util/json/json_reader.cc index 291e96544d6..20a1a04a75c 100644 --- a/src/core/util/json/json_reader.cc +++ b/src/core/util/json/json_reader.cc @@ -36,7 +36,6 @@ #include "absl/types/variant.h" #include -#include #include "src/core/lib/gprpp/match.h" #include "src/core/util/json/json.h" diff --git a/src/core/util/latent_see.cc b/src/core/util/latent_see.cc index 585a072c5b3..6bb250b445f 100644 --- a/src/core/util/latent_see.cc +++ b/src/core/util/latent_see.cc @@ -35,16 +35,25 @@ thread_local uint64_t Log::thread_id_ = Log::Get().next_thread_id_.fetch_add(1); thread_local Bin* Log::bin_ = nullptr; thread_local void* Log::bin_owner_ = nullptr; std::atomic Flow::next_flow_id_{1}; -std::atomic Log::free_bins_; +std::atomic Log::free_bins_{0}; std::string Log::GenerateJson() { std::vector events; + RingBuffer* other; for (auto& fragment : fragments_) { - MutexLock lock(&fragment.mu); - for (auto it = fragment.events.begin(); it != fragment.events.end(); ++it) { + { + MutexLock lock(&fragment.mu); + other = fragment.active; + if (fragment.active == &fragment.primary) { + fragment.active = &fragment.secondary; + } else { + fragment.active = &fragment.primary; + } + } + for (auto it = other->begin(); it != other->end(); ++it) { events.push_back(*it); } - fragment.events.Clear(); + other->Clear(); } absl::optional start_time; for (auto& event : events) { @@ -113,7 +122,7 @@ void Log::FlushBin(Bin* bin) { { MutexLock lock(&fragment.mu); for (auto event : bin->events) { - fragment.events.Append(RecordedEvent{thread_id, batch_id, event}); + fragment.active->Append(RecordedEvent{thread_id, batch_id, event}); } } bin->events.clear(); diff --git a/src/core/util/latent_see.h b/src/core/util/latent_see.h index b4f11d2960b..cf499caa84b 100644 --- a/src/core/util/latent_see.h +++ b/src/core/util/latent_see.h @@ -18,6 +18,9 @@ #include #ifdef GRPC_ENABLE_LATENT_SEE +#include +#include + #include #include #include @@ -27,12 +30,17 @@ #include #include +#include "absl/base/thread_annotations.h" +#include "absl/functional/any_invocable.h" #include "absl/log/log.h" +#include "absl/strings/string_view.h" #include "src/core/lib/gprpp/per_cpu.h" #include "src/core/lib/gprpp/sync.h" #include "src/core/util/ring_buffer.h" +#define TAGGED_POINTER_SIZE_BITS 48 + namespace grpc_core { namespace latent_see { @@ -59,47 +67,59 @@ struct Bin { } std::vector events; - Bin* next_free; + uintptr_t next_free = 0; }; class Log { public: static constexpr int kMaxEventsPerCpu = 50000; - static Bin* MaybeStartBin(void* owner) { - if (bin_ != nullptr) return bin_; - Bin* bin = free_bins_.load(std::memory_order_acquire); + static constexpr uintptr_t kTagMask = (1ULL << TAGGED_POINTER_SIZE_BITS) - 1; + + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION static uintptr_t IncrementTag( + uintptr_t input) { + return input + (1UL << TAGGED_POINTER_SIZE_BITS); + } + + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION static Bin* ToBin(uintptr_t ptr) { + return reinterpret_cast(ptr & kTagMask); + } + + static uintptr_t StartBin(void* owner) { + uintptr_t bin_descriptor = free_bins_.load(std::memory_order_acquire); + Bin* bin; do { - if (bin == nullptr) { + if (bin_descriptor == 0) { bin = new Bin(); break; } - } while (!free_bins_.compare_exchange_weak(bin, bin->next_free, - std::memory_order_acq_rel)); + bin = ToBin(bin_descriptor); + } while (!free_bins_.compare_exchange_strong(bin_descriptor, bin->next_free, + std::memory_order_acq_rel)); bin_ = bin; bin_owner_ = owner; - return bin; + return reinterpret_cast(bin); } - static void EndBin(void* owner) { - if (bin_owner_ != owner) return; - FlushBin(bin_); - bin_->next_free = free_bins_.load(std::memory_order_acquire); - while (!free_bins_.compare_exchange_weak(bin_->next_free, bin_, - std::memory_order_acq_rel)) { + static void EndBin(uintptr_t bin_descriptor, void* owner) { + if (bin_owner_ != owner || bin_descriptor == 0) return; + FlushBin(ToBin(bin_descriptor)); + uintptr_t next_free = free_bins_.load(std::memory_order_acquire); + while (!free_bins_.compare_exchange_strong( + next_free, IncrementTag(bin_descriptor), std::memory_order_acq_rel)) { } bin_ = nullptr; + bin_owner_ = nullptr; } static Bin* CurrentThreadBin() { return bin_; } - private: - Log() = default; - - static void FlushBin(Bin* bin); - GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION static Log& Get() { static Log* log = []() { atexit([] { + if (log->stats_flusher_ != nullptr) { + log->stats_flusher_(log->GenerateJson()); + return; + } LOG(INFO) << "Writing latent_see.json in " << get_current_dir_name(); FILE* f = fopen("latent_see.json", "w"); if (f == nullptr) return; @@ -113,6 +133,16 @@ class Log { std::string GenerateJson(); + void OverrideStatsFlusher( + absl::AnyInvocable stats_exporter) { + stats_flusher_ = std::move(stats_exporter); + } + + private: + Log() = default; + + static void FlushBin(Bin* bin); + struct RecordedEvent { uint64_t thread_id; uint64_t batch_id; @@ -123,10 +153,15 @@ class Log { static thread_local uint64_t thread_id_; static thread_local Bin* bin_; static thread_local void* bin_owner_; - static std::atomic free_bins_; + static std::atomic free_bins_; + absl::AnyInvocable stats_flusher_ = nullptr; struct Fragment { + Fragment() : active(&primary){}; Mutex mu; - RingBuffer events ABSL_GUARDED_BY(mu); + RingBuffer* active + ABSL_GUARDED_BY(mu); + RingBuffer primary; + RingBuffer secondary; }; PerCpu fragments_{PerCpuOptions()}; }; @@ -136,11 +171,17 @@ class Scope { public: GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION explicit Scope(const Metadata* metadata) : metadata_(metadata) { + bin_ = Log::CurrentThreadBin(); + if (kParent && bin_ == nullptr) { + bin_descriptor_ = Log::StartBin(this); + bin_ = Log::ToBin(bin_descriptor_); + } + CHECK_NE(bin_, nullptr); bin_->Append(metadata_, EventType::kBegin, 0); } GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION ~Scope() { bin_->Append(metadata_, EventType::kEnd, 0); - if (kParent) Log::EndBin(this); + if (kParent) Log::EndBin(bin_descriptor_, this); } Scope(const Scope&) = delete; @@ -148,8 +189,8 @@ class Scope { private: const Metadata* const metadata_; - Bin* const bin_ = - kParent ? Log::MaybeStartBin(this) : Log::CurrentThreadBin(); + uintptr_t bin_descriptor_ = 0; + Bin* bin_ = nullptr; }; using ParentScope = Scope; diff --git a/src/core/util/log.cc b/src/core/util/log.cc index c34c1503d3c..d32c8373787 100644 --- a/src/core/util/log.cc +++ b/src/core/util/log.cc @@ -40,8 +40,6 @@ void gpr_unreachable_code(const char* reason, const char* file, int line) { grpc_core::SourceLocation(file, line)); } -int absl_vlog2_enabled() { return ABSL_VLOG_IS_ON(2); } - int gpr_should_log(gpr_log_severity severity) { switch (severity) { case GPR_LOG_SEVERITY_ERROR: @@ -85,10 +83,6 @@ void gpr_log_message(const char* file, int line, gpr_log_severity severity, } void gpr_log_verbosity_init(void) { -// This is enabled in Github only. -// This ifndef is converted to ifdef internally by copybara. -// Internally grpc verbosity is managed using absl settings. -// So internally we avoid setting it like this. #ifndef GRPC_VERBOSITY_MACRO // SetMinLogLevel sets the value for the entire binary, not just gRPC. // This setting will change things for other libraries/code that is unrelated diff --git a/src/core/util/msys/tmpfile.cc b/src/core/util/msys/tmpfile.cc index 41a04f1c75d..dc1cdf7bc34 100644 --- a/src/core/util/msys/tmpfile.cc +++ b/src/core/util/msys/tmpfile.cc @@ -26,7 +26,6 @@ #include #include -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/src/core/util/posix/sync.cc b/src/core/util/posix/sync.cc index 912a1a6b48e..1ccaa281996 100644 --- a/src/core/util/posix/sync.cc +++ b/src/core/util/posix/sync.cc @@ -27,7 +27,6 @@ #include "absl/log/check.h" #include -#include #include #include diff --git a/src/core/util/posix/time.cc b/src/core/util/posix/time.cc index 6624b0fd656..5fea711d59f 100644 --- a/src/core/util/posix/time.cc +++ b/src/core/util/posix/time.cc @@ -31,7 +31,6 @@ #include "absl/log/check.h" #include -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/src/core/util/string.cc b/src/core/util/string.cc index 7efbd09f51f..31ffb9eb4bf 100644 --- a/src/core/util/string.cc +++ b/src/core/util/string.cc @@ -31,7 +31,6 @@ #include "absl/strings/str_cat.h" #include -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/src/core/util/sync.cc b/src/core/util/sync.cc index b70435a992b..dd3db7e6423 100644 --- a/src/core/util/sync.cc +++ b/src/core/util/sync.cc @@ -25,7 +25,6 @@ #include "absl/log/check.h" #include -#include #include // Number of mutexes to allocate for events, to avoid lock contention. diff --git a/src/core/util/sync_abseil.cc b/src/core/util/sync_abseil.cc index cc23c3d1cd3..1d826f6565c 100644 --- a/src/core/util/sync_abseil.cc +++ b/src/core/util/sync_abseil.cc @@ -29,7 +29,6 @@ #include "absl/time/time.h" #include -#include #include #include diff --git a/src/core/util/time.cc b/src/core/util/time.cc index a46e95ef352..d71cee90ca9 100644 --- a/src/core/util/time.cc +++ b/src/core/util/time.cc @@ -26,7 +26,6 @@ #include "absl/log/check.h" -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/src/core/util/windows/cpu.cc b/src/core/util/windows/cpu.cc index 94af1e419c6..a8ba5952f88 100644 --- a/src/core/util/windows/cpu.cc +++ b/src/core/util/windows/cpu.cc @@ -20,7 +20,6 @@ #ifdef GPR_WINDOWS #include -#include #include "src/core/lib/gprpp/crash.h" diff --git a/src/core/util/windows/sync.cc b/src/core/util/windows/sync.cc index 800188bf29d..0f7fd78868d 100644 --- a/src/core/util/windows/sync.cc +++ b/src/core/util/windows/sync.cc @@ -25,7 +25,6 @@ #include "absl/log/check.h" -#include #include #include diff --git a/src/core/util/windows/time.cc b/src/core/util/windows/time.cc index b80a4a5a14b..21cfed52a13 100644 --- a/src/core/util/windows/time.cc +++ b/src/core/util/windows/time.cc @@ -28,7 +28,6 @@ #include "absl/log/check.h" -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/src/core/util/windows/tmpfile.cc b/src/core/util/windows/tmpfile.cc index cd3838bc4ee..23d647a2b8e 100644 --- a/src/core/util/windows/tmpfile.cc +++ b/src/core/util/windows/tmpfile.cc @@ -26,7 +26,6 @@ #include #include -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/src/core/xds/grpc/xds_transport_grpc.cc b/src/core/xds/grpc/xds_transport_grpc.cc index f2759b251a6..6af60f0516d 100644 --- a/src/core/xds/grpc/xds_transport_grpc.cc +++ b/src/core/xds/grpc/xds_transport_grpc.cc @@ -34,7 +34,6 @@ #include #include #include -#include #include #include "src/core/client_channel/client_channel_filter.h" diff --git a/src/core/xds/xds_client/xds_client.cc b/src/core/xds/xds_client/xds_client.cc index 6f1575c1146..7c4cef0dd17 100644 --- a/src/core/xds/xds_client/xds_client.cc +++ b/src/core/xds/xds_client/xds_client.cc @@ -250,16 +250,14 @@ class XdsClient::XdsChannel::AdsCall final } void OnTimer() { - if (GRPC_TRACE_FLAG_ENABLED(xds_client)) { - LOG(INFO) << "[xds_client " << ads_call_->xds_client() - << "] xds server " - << ads_call_->xds_channel()->server_.server_uri() - << ": timeout obtaining resource {type=" << type_->type_url() - << " name=" - << XdsClient::ConstructFullXdsResourceName( - name_.authority, type_->type_url(), name_.key) - << "} from xds server"; - } + GRPC_TRACE_LOG(xds_client, INFO) + << "[xds_client " << ads_call_->xds_client() << "] xds server " + << ads_call_->xds_channel()->server_.server_uri() + << ": timeout obtaining resource {type=" << type_->type_url() + << " name=" + << XdsClient::ConstructFullXdsResourceName( + name_.authority, type_->type_url(), name_.key) + << "} from xds server"; { MutexLock lock(&ads_call_->xds_client()->mu_); timer_handle_.reset(); @@ -571,13 +569,10 @@ bool XdsClient::XdsChannel::MaybeFallbackLocked( type_resource.first, {authority, key_state.first}); } } - if (GRPC_TRACE_FLAG_ENABLED(xds_client)) { - LOG(INFO) << "[xds_client " << xds_client_.get() << "] authority " - << authority << ": added fallback server " - << xds_servers[i]->server_uri() << " (" - << authority_state.xds_channels.back()->status().ToString() - << ")"; - } + GRPC_TRACE_LOG(xds_client, INFO) + << "[xds_client " << xds_client_.get() << "] authority " << authority + << ": added fallback server " << xds_servers[i]->server_uri() << " (" + << authority_state.xds_channels.back()->status().ToString() << ")"; if (authority_state.xds_channels.back()->status().ok()) return true; } GRPC_TRACE_LOG(xds_client, INFO) @@ -723,12 +718,11 @@ void XdsClient::XdsChannel::RetryableCall::StartRetryTimerLocked() { const Timestamp next_attempt_time = backoff_.NextAttemptTime(); const Duration timeout = std::max(next_attempt_time - Timestamp::Now(), Duration::Zero()); - if (GRPC_TRACE_FLAG_ENABLED(xds_client)) { - LOG(INFO) << "[xds_client " << xds_channel()->xds_client() - << "] xds server " << xds_channel()->server_.server_uri() - << ": call attempt failed; retry timer will fire in " - << timeout.millis() << "ms."; - } + GRPC_TRACE_LOG(xds_client, INFO) + << "[xds_client " << xds_channel()->xds_client() << "] xds server " + << xds_channel()->server_.server_uri() + << ": call attempt failed; retry timer will fire in " << timeout.millis() + << "ms."; timer_handle_ = xds_channel()->xds_client()->engine()->RunAfter( timeout, [self = this->Ref(DEBUG_LOCATION, "RetryableCall+retry_timer_start")]() { @@ -779,13 +773,12 @@ class XdsClient::XdsChannel::AdsCall::AdsReadDelayHandle final absl::Status XdsClient::XdsChannel::AdsCall::AdsResponseParser::ProcessAdsResponseFields( AdsResponseFields fields) { - if (GRPC_TRACE_FLAG_ENABLED(xds_client)) { - LOG(INFO) << "[xds_client " << ads_call_->xds_client() << "] xds server " - << ads_call_->xds_channel()->server_.server_uri() - << ": received ADS response: type_url=" << fields.type_url - << ", version=" << fields.version << ", nonce=" << fields.nonce - << ", num_resources=" << fields.num_resources; - } + GRPC_TRACE_LOG(xds_client, INFO) + << "[xds_client " << ads_call_->xds_client() << "] xds server " + << ads_call_->xds_channel()->server_.server_uri() + << ": received ADS response: type_url=" << fields.type_url + << ", version=" << fields.version << ", nonce=" << fields.nonce + << ", num_resources=" << fields.num_resources; result_.type = ads_call_->xds_client()->GetResourceTypeLocked(fields.type_url); if (result_.type == nullptr) { @@ -991,12 +984,11 @@ XdsClient::XdsChannel::AdsCall::AdsCall( RefCountedPtr(this))); CHECK(streaming_call_ != nullptr); // Start the call. - if (GRPC_TRACE_FLAG_ENABLED(xds_client)) { - LOG(INFO) << "[xds_client " << xds_client() << "] xds server " - << xds_channel()->server_.server_uri() - << ": starting ADS call (ads_call: " << this - << ", streaming_call: " << streaming_call_.get() << ")"; - } + GRPC_TRACE_LOG(xds_client, INFO) + << "[xds_client " << xds_client() << "] xds server " + << xds_channel()->server_.server_uri() + << ": starting ADS call (ads_call: " << this + << ", streaming_call: " << streaming_call_.get() << ")"; // If this is a reconnect, add any necessary subscriptions from what's // already in the cache. for (auto& a : xds_client()->authority_state_map_) { @@ -1044,13 +1036,12 @@ void XdsClient::XdsChannel::AdsCall::SendMessageLocked( state.nonce, ResourceNamesForRequest(type), state.status, !sent_initial_message_); sent_initial_message_ = true; - if (GRPC_TRACE_FLAG_ENABLED(xds_client)) { - LOG(INFO) << "[xds_client " << xds_client() << "] xds server " - << xds_channel()->server_.server_uri() - << ": sending ADS request: type=" << type->type_url() - << " version=" << xds_channel()->resource_type_version_map_[type] - << " nonce=" << state.nonce << " error=" << state.status; - } + GRPC_TRACE_LOG(xds_client, INFO) + << "[xds_client " << xds_client() << "] xds server " + << xds_channel()->server_.server_uri() + << ": sending ADS request: type=" << type->type_url() + << " version=" << xds_channel()->resource_type_version_map_[type] + << " nonce=" << state.nonce << " error=" << state.status; state.status = absl::OkStatus(); streaming_call_->SendMessage(std::move(serialized_message)); send_message_pending_ = type; @@ -1228,14 +1219,12 @@ void XdsClient::XdsChannel::AdsCall::OnRecvMessage(absl::string_view payload) { void XdsClient::XdsChannel::AdsCall::OnStatusReceived(absl::Status status) { { MutexLock lock(&xds_client()->mu_); - if (GRPC_TRACE_FLAG_ENABLED(xds_client)) { - LOG(INFO) << "[xds_client " << xds_client() << "] xds server " - << xds_channel()->server_.server_uri() - << ": ADS call status received (xds_channel=" << xds_channel() - << ", ads_call=" << this - << ", streaming_call=" << streaming_call_.get() - << "): " << status; - } + GRPC_TRACE_LOG(xds_client, INFO) + << "[xds_client " << xds_client() << "] xds server " + << xds_channel()->server_.server_uri() + << ": ADS call status received (xds_channel=" << xds_channel() + << ", ads_call=" << this << ", streaming_call=" << streaming_call_.get() + << "): " << status; // Cancel any does-not-exist timers that may be pending. for (const auto& p : state_map_) { for (const auto& q : p.second.subscribed_resources) { @@ -1301,12 +1290,11 @@ void XdsClient::XdsChannel::LrsCall::Timer::Orphan() { } void XdsClient::XdsChannel::LrsCall::Timer::ScheduleNextReportLocked() { - if (GRPC_TRACE_FLAG_ENABLED(xds_client)) { - LOG(INFO) << "[xds_client " << xds_client() << "] xds server " - << lrs_call_->xds_channel()->server_.server_uri() - << ": scheduling next load report in " - << lrs_call_->load_reporting_interval_; - } + GRPC_TRACE_LOG(xds_client, INFO) + << "[xds_client " << xds_client() << "] xds server " + << lrs_call_->xds_channel()->server_.server_uri() + << ": scheduling next load report in " + << lrs_call_->load_reporting_interval_; timer_handle_ = xds_client()->engine()->RunAfter( lrs_call_->load_reporting_interval_, [self = Ref(DEBUG_LOCATION, "timer")]() { @@ -1344,12 +1332,11 @@ XdsClient::XdsChannel::LrsCall::LrsCall( RefCountedPtr(this))); CHECK(streaming_call_ != nullptr); // Start the call. - if (GRPC_TRACE_FLAG_ENABLED(xds_client)) { - LOG(INFO) << "[xds_client " << xds_client() << "] xds server " - << xds_channel()->server_.server_uri() - << ": starting LRS call (lrs_call=" << this - << ", streaming_call=" << streaming_call_.get() << ")"; - } + GRPC_TRACE_LOG(xds_client, INFO) + << "[xds_client " << xds_client() << "] xds server " + << xds_channel()->server_.server_uri() + << ": starting LRS call (lrs_call=" << this + << ", streaming_call=" << streaming_call_.get() << ")"; // Send the initial request. std::string serialized_payload = xds_client()->api_.CreateLrsInitialRequest(); SendMessageLocked(std::move(serialized_payload)); @@ -1473,12 +1460,11 @@ void XdsClient::XdsChannel::LrsCall::OnRecvMessage(absl::string_view payload) { Duration::Milliseconds(GRPC_XDS_MIN_CLIENT_LOAD_REPORTING_INTERVAL_MS)) { new_load_reporting_interval = Duration::Milliseconds(GRPC_XDS_MIN_CLIENT_LOAD_REPORTING_INTERVAL_MS); - if (GRPC_TRACE_FLAG_ENABLED(xds_client)) { - LOG(INFO) << "[xds_client " << xds_client() << "] xds server " - << xds_channel()->server_.server_uri() - << ": increased load_report_interval to minimum value " - << GRPC_XDS_MIN_CLIENT_LOAD_REPORTING_INTERVAL_MS << "ms"; - } + GRPC_TRACE_LOG(xds_client, INFO) + << "[xds_client " << xds_client() << "] xds server " + << xds_channel()->server_.server_uri() + << ": increased load_report_interval to minimum value " + << GRPC_XDS_MIN_CLIENT_LOAD_REPORTING_INTERVAL_MS << "ms"; } // Ignore identical update. if (send_all_clusters == send_all_clusters_ && @@ -1506,14 +1492,12 @@ void XdsClient::XdsChannel::LrsCall::OnRecvMessage(absl::string_view payload) { void XdsClient::XdsChannel::LrsCall::OnStatusReceived(absl::Status status) { MutexLock lock(&xds_client()->mu_); - if (GRPC_TRACE_FLAG_ENABLED(xds_client)) { - LOG(INFO) << "[xds_client " << xds_client() << "] xds server " - << xds_channel()->server_.server_uri() - << ": LRS call status received (xds_channel=" << xds_channel() - << ", lrs_call=" << this - << ", streaming_call=" << streaming_call_.get() - << "): " << status; - } + GRPC_TRACE_LOG(xds_client, INFO) + << "[xds_client " << xds_client() << "] xds server " + << xds_channel()->server_.server_uri() + << ": LRS call status received (xds_channel=" << xds_channel() + << ", lrs_call=" << this << ", streaming_call=" << streaming_call_.get() + << "): " << status; // Ignore status from a stale call. if (IsCurrentCallOnChannel()) { // Try to restart the call. @@ -2076,14 +2060,12 @@ XdsApi::ClusterLoadReportMap XdsClient::BuildLoadReportSnapshotLocked( if (locality_state.locality_stats != nullptr) { locality_snapshot += locality_state.locality_stats->GetSnapshotAndReset(); - if (GRPC_TRACE_FLAG_ENABLED(xds_client)) { - LOG(INFO) << "[xds_client " << this - << "] cluster=" << cluster_key.first.c_str() - << " eds_service_name=" << cluster_key.second.c_str() - << " locality=" - << locality_name->human_readable_string().c_str() - << " locality_stats=" << locality_state.locality_stats; - } + GRPC_TRACE_LOG(xds_client, INFO) + << "[xds_client " << this + << "] cluster=" << cluster_key.first.c_str() + << " eds_service_name=" << cluster_key.second.c_str() + << " locality=" << locality_name->human_readable_string().c_str() + << " locality_stats=" << locality_state.locality_stats; } // If the only thing left in this entry was final snapshots from // deleted locality stats objects, remove the entry. diff --git a/src/core/xds/xds_client/xds_client_stats.cc b/src/core/xds/xds_client/xds_client_stats.cc index b78dbce775b..3219b224a9e 100644 --- a/src/core/xds/xds_client/xds_client_stats.cc +++ b/src/core/xds/xds_client/xds_client_stats.cc @@ -100,26 +100,21 @@ XdsClusterLocalityStats::XdsClusterLocalityStats( cluster_name_(cluster_name), eds_service_name_(eds_service_name), name_(std::move(name)) { - if (GRPC_TRACE_FLAG_ENABLED(xds_client)) { - LOG(INFO) << "[xds_client " << xds_client_.get() - << "] created locality stats " << this << " for {" << lrs_server_ - << ", " << cluster_name_ << ", " << eds_service_name_ << ", " - << (name_ == nullptr ? "" - : name_->human_readable_string().c_str()) - << "}"; - } + GRPC_TRACE_LOG(xds_client, INFO) + << "[xds_client " << xds_client_.get() << "] created locality stats " + << this << " for {" << lrs_server_ << ", " << cluster_name_ << ", " + << eds_service_name_ << ", " + << (name_ == nullptr ? "" : name_->human_readable_string().c_str()) + << "}"; } XdsClusterLocalityStats::~XdsClusterLocalityStats() { - if (GRPC_TRACE_FLAG_ENABLED(xds_client)) { - LOG(INFO) << "[xds_client " << xds_client_.get() - << "] destroying locality stats " << this << " for {" - << lrs_server_ << ", " << cluster_name_ << ", " - << eds_service_name_ << ", " - << (name_ == nullptr ? "" - : name_->human_readable_string().c_str()) - << "}"; - } + GRPC_TRACE_LOG(xds_client, INFO) + << "[xds_client " << xds_client_.get() << "] destroying locality stats " + << this << " for {" << lrs_server_ << ", " << cluster_name_ << ", " + << eds_service_name_ << ", " + << (name_ == nullptr ? "" : name_->human_readable_string().c_str()) + << "}"; xds_client_->RemoveClusterLocalityStats(lrs_server_, cluster_name_, eds_service_name_, name_, this); xds_client_.reset(DEBUG_LOCATION, "LocalityStats"); diff --git a/src/cpp/client/channel_cc.cc b/src/cpp/client/channel_cc.cc index 8b8e37fc9f2..457f9db37aa 100644 --- a/src/cpp/client/channel_cc.cc +++ b/src/cpp/client/channel_cc.cc @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc index 76bee4cb6b8..78c0bd16002 100644 --- a/src/cpp/client/client_context.cc +++ b/src/cpp/client/client_context.cc @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include diff --git a/src/cpp/client/global_callback_hook.cc b/src/cpp/client/global_callback_hook.cc new file mode 100644 index 00000000000..2431508b7b3 --- /dev/null +++ b/src/cpp/client/global_callback_hook.cc @@ -0,0 +1,36 @@ +// Copyright 2024 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include "absl/base/no_destructor.h" +#include "absl/log/check.h" + +#include + +namespace grpc { + +static absl::NoDestructor> g_callback_hook( + std::make_shared()); + +std::shared_ptr GetGlobalCallbackHook() { + return *g_callback_hook; +} + +void SetGlobalCallbackHook(GlobalCallbackHook* hook) { + CHECK(hook != nullptr); + CHECK(hook != (*g_callback_hook).get()); + *g_callback_hook = std::shared_ptr(hook); +} +} // namespace grpc diff --git a/src/cpp/client/xds_credentials.cc b/src/cpp/client/xds_credentials.cc index d7878e5cb5b..e3fefd04c47 100644 --- a/src/cpp/client/xds_credentials.cc +++ b/src/cpp/client/xds_credentials.cc @@ -22,7 +22,6 @@ #include #include -#include #include namespace grpc { diff --git a/src/cpp/common/alarm.cc b/src/cpp/common/alarm.cc index 918922eb235..041584eb489 100644 --- a/src/cpp/common/alarm.cc +++ b/src/cpp/common/alarm.cc @@ -25,7 +25,6 @@ #include #include -#include #include #include #include diff --git a/src/cpp/common/channel_arguments.cc b/src/cpp/common/channel_arguments.cc index 3eb56c32806..fc09938b99f 100644 --- a/src/cpp/common/channel_arguments.cc +++ b/src/cpp/common/channel_arguments.cc @@ -24,7 +24,6 @@ #include #include -#include #include #include #include diff --git a/src/cpp/common/tls_certificate_provider.cc b/src/cpp/common/tls_certificate_provider.cc index b94a807bfdb..7d841b38fd5 100644 --- a/src/cpp/common/tls_certificate_provider.cc +++ b/src/cpp/common/tls_certificate_provider.cc @@ -21,7 +21,6 @@ #include #include -#include #include namespace grpc { diff --git a/src/cpp/common/tls_certificate_verifier.cc b/src/cpp/common/tls_certificate_verifier.cc index a642760a4a9..d298cf26773 100644 --- a/src/cpp/common/tls_certificate_verifier.cc +++ b/src/cpp/common/tls_certificate_verifier.cc @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include diff --git a/src/cpp/common/tls_credentials_options.cc b/src/cpp/common/tls_credentials_options.cc index ef260b86908..74e74128322 100644 --- a/src/cpp/common/tls_credentials_options.cc +++ b/src/cpp/common/tls_credentials_options.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include diff --git a/src/cpp/ext/filters/census/client_filter.cc b/src/cpp/ext/filters/census/client_filter.cc index daffd3e78a2..cf0aac4c0d2 100644 --- a/src/cpp/ext/filters/census/client_filter.cc +++ b/src/cpp/ext/filters/census/client_filter.cc @@ -44,7 +44,6 @@ #include "opencensus/trace/status_code.h" #include -#include #include #include #include diff --git a/src/cpp/ext/gcp/environment_autodetect.cc b/src/cpp/ext/gcp/environment_autodetect.cc index f9d121635cb..ceee1c249bd 100644 --- a/src/cpp/ext/gcp/environment_autodetect.cc +++ b/src/cpp/ext/gcp/environment_autodetect.cc @@ -248,14 +248,12 @@ class EnvironmentAutoDetectHelper queries_.push_back(grpc_core::MakeOrphanable( element.first, &pollent_, [this](std::string attribute, absl::StatusOr result) { - if (GRPC_TRACE_FLAG_ENABLED(environment_autodetect)) { - LOG(INFO) << "Environment AutoDetect: Attribute: \"" << attribute - << "\" Result: \"" - << (result.ok() - ? result.value() + GRPC_TRACE_LOG(environment_autodetect, INFO) + << "Environment AutoDetect: Attribute: \"" << attribute + << "\" Result: \"" + << (result.ok() ? result.value() : grpc_core::StatusToString(result.status())) - << "\""; - } + << "\""; absl::optional resource; { grpc_core::MutexLock lock(&mu_); diff --git a/src/cpp/ext/otel/otel_client_call_tracer.cc b/src/cpp/ext/otel/otel_client_call_tracer.cc index 822a96ea9cf..8e75cb82bba 100644 --- a/src/cpp/ext/otel/otel_client_call_tracer.cc +++ b/src/cpp/ext/otel/otel_client_call_tracer.cc @@ -40,7 +40,6 @@ #include "opentelemetry/metrics/sync_instruments.h" #include -#include #include #include diff --git a/src/cpp/ext/otel/otel_plugin.cc b/src/cpp/ext/otel/otel_plugin.cc index 6ae99378296..44c653d58b8 100644 --- a/src/cpp/ext/otel/otel_plugin.cc +++ b/src/cpp/ext/otel/otel_plugin.cc @@ -563,6 +563,38 @@ OpenTelemetryPluginImpl::OpenTelemetryPluginImpl( }); } +OpenTelemetryPluginImpl::~OpenTelemetryPluginImpl() { + for (const auto& instrument_data : instruments_data_) { + grpc_core::Match( + instrument_data.instrument, [](const Disabled&) {}, + [](const std::unique_ptr>&) {}, + [](const std::unique_ptr>&) { + }, + [](const std::unique_ptr< + opentelemetry::metrics::Histogram>&) {}, + [](const std::unique_ptr>&) { + }, + [](const std::unique_ptr>& state) { + CHECK(state->caches.empty()); + if (state->ot_callback_registered) { + state->instrument->RemoveCallback( + &CallbackGaugeState::CallbackGaugeCallback, + state.get()); + state->ot_callback_registered = false; + } + }, + [](const std::unique_ptr>& state) { + CHECK(state->caches.empty()); + if (state->ot_callback_registered) { + state->instrument->RemoveCallback( + &CallbackGaugeState::CallbackGaugeCallback, + state.get()); + state->ot_callback_registered = false; + } + }); + } +} + namespace { constexpr absl::string_view kLocality = "grpc.lb.locality"; } @@ -823,9 +855,6 @@ void OpenTelemetryPluginImpl::AddCallback( void OpenTelemetryPluginImpl::RemoveCallback( grpc_core::RegisteredMetricCallback* callback) { - std::vector< - absl::variant*, CallbackGaugeState*>> - gauges_that_need_to_remove_callback; { grpc_core::MutexLock lock(&mu_); callback_timestamps_.erase(callback); @@ -848,11 +877,6 @@ void OpenTelemetryPluginImpl::RemoveCallback( CHECK_NE(callback_gauge_state, nullptr); CHECK((*callback_gauge_state)->ot_callback_registered); CHECK_EQ((*callback_gauge_state)->caches.erase(callback), 1u); - if ((*callback_gauge_state)->caches.empty()) { - gauges_that_need_to_remove_callback.push_back( - callback_gauge_state->get()); - (*callback_gauge_state)->ot_callback_registered = false; - } break; } case grpc_core::GlobalInstrumentsRegistry::ValueType::kDouble: { @@ -867,11 +891,6 @@ void OpenTelemetryPluginImpl::RemoveCallback( CHECK_NE(callback_gauge_state, nullptr); CHECK((*callback_gauge_state)->ot_callback_registered); CHECK_EQ((*callback_gauge_state)->caches.erase(callback), 1u); - if ((*callback_gauge_state)->caches.empty()) { - gauges_that_need_to_remove_callback.push_back( - callback_gauge_state->get()); - (*callback_gauge_state)->ot_callback_registered = false; - } break; } default: @@ -880,21 +899,13 @@ void OpenTelemetryPluginImpl::RemoveCallback( } } } - // RemoveCallback internally grabs OpenTelemetry's observable_registry's - // lock. So we need to call it without our plugin lock otherwise we may - // deadlock. - for (const auto& gauge : gauges_that_need_to_remove_callback) { - grpc_core::Match( - gauge, - [](CallbackGaugeState* gauge) { - gauge->instrument->RemoveCallback( - &CallbackGaugeState::CallbackGaugeCallback, gauge); - }, - [](CallbackGaugeState* gauge) { - gauge->instrument->RemoveCallback( - &CallbackGaugeState::CallbackGaugeCallback, gauge); - }); - } + // Note that we are not removing the callback from OpenTelemetry immediately, + // and instead remove it when the plugin is destroyed. We just have a single + // callback per OpenTelemetry instrument which is a small number. If we decide + // to remove the callback immediately at this point, we need to make sure that + // 1) the callback is removed without holding mu_ and 2) we make sure that + // this does not race against a possible `AddCallback` operation. A potential + // way to do this is to use WorkSerializer. } template diff --git a/src/cpp/ext/otel/otel_plugin.h b/src/cpp/ext/otel/otel_plugin.h index 70321fb021d..9b0c4328673 100644 --- a/src/cpp/ext/otel/otel_plugin.h +++ b/src/cpp/ext/otel/otel_plugin.h @@ -223,6 +223,7 @@ class OpenTelemetryPluginImpl absl::AnyInvocable< bool(const OpenTelemetryPluginBuilder::ChannelScope& /*scope*/) const> channel_scope_filter); + ~OpenTelemetryPluginImpl() override; private: class ClientCallTracer; diff --git a/src/cpp/server/backend_metric_recorder.cc b/src/cpp/server/backend_metric_recorder.cc index e686fa9d0e3..40a19f3a72f 100644 --- a/src/cpp/server/backend_metric_recorder.cc +++ b/src/cpp/server/backend_metric_recorder.cc @@ -26,7 +26,6 @@ #include "absl/log/log.h" -#include #include #include @@ -368,15 +367,13 @@ BackendMetricData BackendMetricState::GetBackendMetricData() { data.named_metrics[r.first] = r.second; } } - if (GRPC_TRACE_FLAG_ENABLED(backend_metric)) { - LOG(INFO) << "[" << this - << "] Backend metric data returned: cpu:" << data.cpu_utilization - << " mem:" << data.mem_utilization << " qps:" << data.qps - << " eps:" << data.eps - << " utilization size:" << data.utilization.size() - << " request_cost size:" << data.request_cost.size() - << "named_metrics size:" << data.named_metrics.size(); - } + GRPC_TRACE_LOG(backend_metric, INFO) + << "[" << this + << "] Backend metric data returned: cpu:" << data.cpu_utilization + << " mem:" << data.mem_utilization << " qps:" << data.qps + << " eps:" << data.eps << " utilization size:" << data.utilization.size() + << " request_cost size:" << data.request_cost.size() + << "named_metrics size:" << data.named_metrics.size(); return data; } diff --git a/src/cpp/server/insecure_server_credentials.cc b/src/cpp/server/insecure_server_credentials.cc index ed14ac3def9..a48b9cb93c7 100644 --- a/src/cpp/server/insecure_server_credentials.cc +++ b/src/cpp/server/insecure_server_credentials.cc @@ -20,7 +20,6 @@ #include #include -#include #include #include diff --git a/src/cpp/server/orca/orca_service.cc b/src/cpp/server/orca/orca_service.cc index 05a86fdfd08..9cc09c9909e 100644 --- a/src/cpp/server/orca/orca_service.cc +++ b/src/cpp/server/orca/orca_service.cc @@ -32,7 +32,6 @@ #include "xds/service/orca/v3/orca.upb.h" #include -#include #include #include #include diff --git a/src/cpp/server/xds_server_credentials.cc b/src/cpp/server/xds_server_credentials.cc index eb7f6ddfda8..df05e254d45 100644 --- a/src/cpp/server/xds_server_credentials.cc +++ b/src/cpp/server/xds_server_credentials.cc @@ -22,7 +22,6 @@ #include #include -#include #include namespace grpc { diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.mm b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.mm index 7f29485fee3..93919d0f5ec 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.mm +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.mm @@ -18,8 +18,6 @@ #import "GRPCChannel.h" -#include - #import "../../internal/GRPCCallOptions+Internal.h" #import "../GRPCTransport+Private.h" #import "ChannelArgsUtil.h" diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.mm b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.mm index b42fd6e0a1c..a261300cd52 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.mm +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.mm @@ -28,8 +28,6 @@ #import "GRPCSecureChannelFactory.h" #import "GRPCWrappedCall.h" -#include - extern const char *kCFStreamVarName; static GRPCChannelPool *gChannelPool; diff --git a/src/ruby/ext/grpc/rb_call_credentials.c b/src/ruby/ext/grpc/rb_call_credentials.c index 8dd2530cbc8..14bce49d37f 100644 --- a/src/ruby/ext/grpc/rb_call_credentials.c +++ b/src/ruby/ext/grpc/rb_call_credentials.c @@ -60,30 +60,30 @@ static VALUE grpc_rb_call_credentials_callback(VALUE args) { VALUE callback_func = rb_ary_entry(args, 0); VALUE callback_args = rb_ary_entry(args, 1); VALUE md_ary_obj = rb_ary_entry(args, 2); - if (absl_vlog2_enabled()) { - VALUE callback_func_str = rb_funcall(callback_func, rb_intern("to_s"), 0); - VALUE callback_args_str = rb_funcall(callback_args, rb_intern("to_s"), 0); - VALUE callback_source_info = - rb_funcall(callback_func, rb_intern("source_location"), 0); - if (callback_source_info != Qnil) { - VALUE source_filename = rb_ary_entry(callback_source_info, 0); - VALUE source_line_number = rb_funcall( - rb_ary_entry(callback_source_info, 1), rb_intern("to_s"), 0); - gpr_log(GPR_DEBUG, - "GRPC_RUBY: grpc_rb_call_credentials invoking user callback:|%s| " - "source_filename:%s line_number:%s with arguments:|%s|", - StringValueCStr(callback_func_str), - StringValueCStr(source_filename), - StringValueCStr(source_line_number), - StringValueCStr(callback_args_str)); - } else { - gpr_log(GPR_DEBUG, - "GRPC_RUBY: grpc_rb_call_credentials invoking user callback:|%s| " - "(failed to get source filename and line) with arguments:|%s|", - StringValueCStr(callback_func_str), - StringValueCStr(callback_args_str)); - } + + VALUE callback_func_str = rb_funcall(callback_func, rb_intern("to_s"), 0); + VALUE callback_args_str = rb_funcall(callback_args, rb_intern("to_s"), 0); + VALUE callback_source_info = + rb_funcall(callback_func, rb_intern("source_location"), 0); + if (callback_source_info != Qnil) { + VALUE source_filename = rb_ary_entry(callback_source_info, 0); + VALUE source_line_number = + rb_funcall(rb_ary_entry(callback_source_info, 1), rb_intern("to_s"), 0); + gpr_log(GPR_DEBUG, + "GRPC_RUBY: grpc_rb_call_credentials invoking user callback:|%s| " + "source_filename:%s line_number:%s with arguments:|%s|", + StringValueCStr(callback_func_str), + StringValueCStr(source_filename), + StringValueCStr(source_line_number), + StringValueCStr(callback_args_str)); + } else { + gpr_log(GPR_DEBUG, + "GRPC_RUBY: grpc_rb_call_credentials invoking user callback:|%s| " + "(failed to get source filename and line) with arguments:|%s|", + StringValueCStr(callback_func_str), + StringValueCStr(callback_args_str)); } + VALUE metadata = rb_funcall(callback_func, rb_intern("call"), 1, callback_args); grpc_metadata_array* md_ary = NULL; diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c index 36e66f82b86..31cb6523097 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c @@ -254,7 +254,6 @@ gpr_free_aligned_type gpr_free_aligned_import; gpr_cpu_num_cores_type gpr_cpu_num_cores_import; gpr_cpu_current_cpu_type gpr_cpu_current_cpu_import; gpr_log_type gpr_log_import; -absl_vlog2_enabled_type absl_vlog2_enabled_import; gpr_log_verbosity_init_type gpr_log_verbosity_init_import; gpr_format_message_type gpr_format_message_import; gpr_strdup_type gpr_strdup_import; @@ -539,7 +538,6 @@ void grpc_rb_load_imports(HMODULE library) { gpr_cpu_num_cores_import = (gpr_cpu_num_cores_type) GetProcAddress(library, "gpr_cpu_num_cores"); gpr_cpu_current_cpu_import = (gpr_cpu_current_cpu_type) GetProcAddress(library, "gpr_cpu_current_cpu"); gpr_log_import = (gpr_log_type) GetProcAddress(library, "gpr_log"); - absl_vlog2_enabled_import = (absl_vlog2_enabled_type) GetProcAddress(library, "absl_vlog2_enabled"); gpr_log_verbosity_init_import = (gpr_log_verbosity_init_type) GetProcAddress(library, "gpr_log_verbosity_init"); gpr_format_message_import = (gpr_format_message_type) GetProcAddress(library, "gpr_format_message"); gpr_strdup_import = (gpr_strdup_type) GetProcAddress(library, "gpr_strdup"); diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index 8ddd62a7ce9..02aee5008a7 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -738,9 +738,6 @@ extern gpr_cpu_current_cpu_type gpr_cpu_current_cpu_import; typedef void(*gpr_log_type)(const char* file, int line, gpr_log_severity severity, const char* format, ...) GPR_PRINT_FORMAT_CHECK(4, 5); extern gpr_log_type gpr_log_import; #define gpr_log gpr_log_import -typedef int(*absl_vlog2_enabled_type)(); -extern absl_vlog2_enabled_type absl_vlog2_enabled_import; -#define absl_vlog2_enabled absl_vlog2_enabled_import typedef void(*gpr_log_verbosity_init_type)(void); extern gpr_log_verbosity_init_type gpr_log_verbosity_init_import; #define gpr_log_verbosity_init gpr_log_verbosity_init_import diff --git a/test/core/address_utils/sockaddr_utils_fuzzer_test.cc b/test/core/address_utils/sockaddr_utils_fuzzer_test.cc index 09cf4e5244d..593d99dd0e3 100644 --- a/test/core/address_utils/sockaddr_utils_fuzzer_test.cc +++ b/test/core/address_utils/sockaddr_utils_fuzzer_test.cc @@ -22,8 +22,6 @@ #include "absl/log/check.h" #include "absl/status/statusor.h" -#include - #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/resolved_address.h" diff --git a/test/core/address_utils/sockaddr_utils_test.cc b/test/core/address_utils/sockaddr_utils_test.cc index e06223a7649..83de472f102 100644 --- a/test/core/address_utils/sockaddr_utils_test.cc +++ b/test/core/address_utils/sockaddr_utils_test.cc @@ -44,8 +44,6 @@ #include "absl/log/check.h" -#include - #include "src/core/lib/address_utils/parse_address.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/socket_utils.h" diff --git a/test/core/bad_client/tests/bad_streaming_id.cc b/test/core/bad_client/tests/bad_streaming_id.cc index a29c64cea1a..4cd7cbc5778 100644 --- a/test/core/bad_client/tests/bad_streaming_id.cc +++ b/test/core/bad_client/tests/bad_streaming_id.cc @@ -23,7 +23,6 @@ #include "absl/log/check.h" #include -#include #include "src/core/server/server.h" #include "test/core/bad_client/bad_client.h" diff --git a/test/core/bad_client/tests/badreq.cc b/test/core/bad_client/tests/badreq.cc index 4d595b9f4e2..27a01496d97 100644 --- a/test/core/bad_client/tests/badreq.cc +++ b/test/core/bad_client/tests/badreq.cc @@ -19,7 +19,6 @@ #include "absl/log/check.h" #include -#include #include "src/core/server/server.h" #include "test/core/bad_client/bad_client.h" diff --git a/test/core/bad_client/tests/connection_prefix.cc b/test/core/bad_client/tests/connection_prefix.cc index 993e799839e..1aa899ab707 100644 --- a/test/core/bad_client/tests/connection_prefix.cc +++ b/test/core/bad_client/tests/connection_prefix.cc @@ -19,7 +19,6 @@ #include "absl/log/check.h" #include -#include #include "src/core/server/server.h" #include "test/core/bad_client/bad_client.h" diff --git a/test/core/bad_client/tests/duplicate_header.cc b/test/core/bad_client/tests/duplicate_header.cc index 12c5dfd58cb..c4ed690c5b2 100644 --- a/test/core/bad_client/tests/duplicate_header.cc +++ b/test/core/bad_client/tests/duplicate_header.cc @@ -23,7 +23,6 @@ #include #include #include -#include #include "src/core/lib/gprpp/time.h" #include "test/core/bad_client/bad_client.h" diff --git a/test/core/bad_client/tests/head_of_line_blocking.cc b/test/core/bad_client/tests/head_of_line_blocking.cc index 75615687d86..2a46c836780 100644 --- a/test/core/bad_client/tests/head_of_line_blocking.cc +++ b/test/core/bad_client/tests/head_of_line_blocking.cc @@ -26,7 +26,6 @@ #include #include #include -#include #include #include "test/core/bad_client/bad_client.h" diff --git a/test/core/bad_client/tests/out_of_bounds.cc b/test/core/bad_client/tests/out_of_bounds.cc index 1d03c4f8b56..04cdf739c41 100644 --- a/test/core/bad_client/tests/out_of_bounds.cc +++ b/test/core/bad_client/tests/out_of_bounds.cc @@ -23,7 +23,6 @@ #include "absl/log/check.h" #include -#include #include "src/core/server/server.h" #include "test/core/bad_client/bad_client.h" diff --git a/test/core/bad_client/tests/server_registered_method.cc b/test/core/bad_client/tests/server_registered_method.cc index 32f69f20a40..731eeb91acc 100644 --- a/test/core/bad_client/tests/server_registered_method.cc +++ b/test/core/bad_client/tests/server_registered_method.cc @@ -20,7 +20,6 @@ #include #include -#include #include #include "src/core/server/server.h" diff --git a/test/core/bad_client/tests/simple_request.cc b/test/core/bad_client/tests/simple_request.cc index 7fa0065b6e5..6732d76147d 100644 --- a/test/core/bad_client/tests/simple_request.cc +++ b/test/core/bad_client/tests/simple_request.cc @@ -16,7 +16,6 @@ #include #include -#include #include "src/core/server/server.h" #include "test/core/bad_client/bad_client.h" diff --git a/test/core/bad_client/tests/unknown_frame.cc b/test/core/bad_client/tests/unknown_frame.cc index 7b3e1364ba5..a7c908ca483 100644 --- a/test/core/bad_client/tests/unknown_frame.cc +++ b/test/core/bad_client/tests/unknown_frame.cc @@ -23,7 +23,6 @@ #include "absl/log/check.h" #include -#include #include "src/core/server/server.h" #include "test/core/bad_client/bad_client.h" diff --git a/test/core/bad_client/tests/window_overflow.cc b/test/core/bad_client/tests/window_overflow.cc index b58ca84febe..3137921591e 100644 --- a/test/core/bad_client/tests/window_overflow.cc +++ b/test/core/bad_client/tests/window_overflow.cc @@ -21,7 +21,6 @@ #include #include -#include #include "src/core/server/server.h" #include "test/core/bad_client/bad_client.h" diff --git a/test/core/bad_ssl/bad_ssl_test.cc b/test/core/bad_ssl/bad_ssl_test.cc index ade42a80c68..c548e188706 100644 --- a/test/core/bad_ssl/bad_ssl_test.cc +++ b/test/core/bad_ssl/bad_ssl_test.cc @@ -31,7 +31,6 @@ #include #include #include -#include #include #include diff --git a/test/core/bad_ssl/servers/alpn.cc b/test/core/bad_ssl/servers/alpn.cc index b3894767b01..285488747c8 100644 --- a/test/core/bad_ssl/servers/alpn.cc +++ b/test/core/bad_ssl/servers/alpn.cc @@ -26,7 +26,6 @@ #include #include #include -#include #include "src/core/lib/iomgr/error.h" #include "src/core/util/useful.h" diff --git a/test/core/bad_ssl/servers/cert.cc b/test/core/bad_ssl/servers/cert.cc index f2fd81fa35d..30d1b7fc8fd 100644 --- a/test/core/bad_ssl/servers/cert.cc +++ b/test/core/bad_ssl/servers/cert.cc @@ -22,7 +22,6 @@ #include #include #include -#include #include "src/core/lib/iomgr/error.h" #include "test/core/bad_ssl/server_common.h" diff --git a/test/core/call/yodel/fuzzer_main.cc b/test/core/call/yodel/fuzzer_main.cc index f88cda36333..ce9075485f9 100644 --- a/test/core/call/yodel/fuzzer_main.cc +++ b/test/core/call/yodel/fuzzer_main.cc @@ -19,7 +19,6 @@ #include "absl/log/check.h" #include -#include #include "src/core/lib/config/config_vars.h" #include "src/core/lib/event_engine/default_event_engine.h" diff --git a/test/core/channel/minimal_stack_is_minimal_test.cc b/test/core/channel/minimal_stack_is_minimal_test.cc index cf1a7b08339..d06f98fba2e 100644 --- a/test/core/channel/minimal_stack_is_minimal_test.cc +++ b/test/core/channel/minimal_stack_is_minimal_test.cc @@ -41,7 +41,6 @@ #include #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_stack.h" diff --git a/test/core/end2end/end2end_test_fuzzer.cc b/test/core/end2end/end2end_test_fuzzer.cc index c0f5cb3bbf9..98cad6424b5 100644 --- a/test/core/end2end/end2end_test_fuzzer.cc +++ b/test/core/end2end/end2end_test_fuzzer.cc @@ -29,7 +29,6 @@ #include "absl/log/check.h" #include -#include #include "src/core/lib/config/config_vars.h" #include "src/core/lib/event_engine/default_event_engine.h" diff --git a/test/core/end2end/end2end_test_suites.cc b/test/core/end2end/end2end_test_suites.cc index 047c2a7f3d9..61bc29cdb19 100644 --- a/test/core/end2end/end2end_test_suites.cc +++ b/test/core/end2end/end2end_test_suites.cc @@ -43,7 +43,6 @@ #include #include #include -#include #include #include "src/core/ext/transport/chaotic_good/client/chaotic_good_connector.h" diff --git a/test/core/end2end/fixtures/local_util.cc b/test/core/end2end/fixtures/local_util.cc index 12e05139a85..63bc96b9052 100644 --- a/test/core/end2end/fixtures/local_util.cc +++ b/test/core/end2end/fixtures/local_util.cc @@ -27,7 +27,6 @@ #include #include #include -#include static void process_auth_failure(void* state, grpc_auth_context* /*ctx*/, const grpc_metadata* /*md*/, diff --git a/test/core/end2end/fuzzers/api_fuzzer.cc b/test/core/end2end/fuzzers/api_fuzzer.cc index 712f225d8bc..b92fdb5655c 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.cc +++ b/test/core/end2end/fuzzers/api_fuzzer.cc @@ -42,7 +42,6 @@ #include #include #include -#include #include #include "src/core/ext/transport/inproc/inproc_transport.h" diff --git a/test/core/end2end/fuzzers/client_fuzzer.cc b/test/core/end2end/fuzzers/client_fuzzer.cc index f924c302241..3d9d1778d8f 100644 --- a/test/core/end2end/fuzzers/client_fuzzer.cc +++ b/test/core/end2end/fuzzers/client_fuzzer.cc @@ -21,7 +21,6 @@ #include #include #include -#include #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/fuzzers/server_fuzzer.cc b/test/core/end2end/fuzzers/server_fuzzer.cc index a161815f51a..05fef731cc4 100644 --- a/test/core/end2end/fuzzers/server_fuzzer.cc +++ b/test/core/end2end/fuzzers/server_fuzzer.cc @@ -20,7 +20,6 @@ #include #include #include -#include #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/experiments/config.h" diff --git a/test/core/end2end/h2_ssl_session_reuse_test.cc b/test/core/end2end/h2_ssl_session_reuse_test.cc index e419096114d..6fd220719e5 100644 --- a/test/core/end2end/h2_ssl_session_reuse_test.cc +++ b/test/core/end2end/h2_ssl_session_reuse_test.cc @@ -33,7 +33,6 @@ #include #include #include -#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/h2_tls_peer_property_external_verifier_test.cc b/test/core/end2end/h2_tls_peer_property_external_verifier_test.cc index e3982feaa4f..24fc3e7c3c0 100644 --- a/test/core/end2end/h2_tls_peer_property_external_verifier_test.cc +++ b/test/core/end2end/h2_tls_peer_property_external_verifier_test.cc @@ -33,7 +33,6 @@ #include #include #include -#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/grpc_authz.cc b/test/core/end2end/tests/grpc_authz.cc index fa8c54ccec1..710535ea5d3 100644 --- a/test/core/end2end/tests/grpc_authz.cc +++ b/test/core/end2end/tests/grpc_authz.cc @@ -22,7 +22,6 @@ #include #include #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/notification.h" diff --git a/test/core/end2end/tests/http2_stats.cc b/test/core/end2end/tests/http2_stats.cc index 5535e72153a..a8de51639f7 100644 --- a/test/core/end2end/tests/http2_stats.cc +++ b/test/core/end2end/tests/http2_stats.cc @@ -25,7 +25,6 @@ #include "gtest/gtest.h" #include -#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_lb_drop.cc b/test/core/end2end/tests/retry_lb_drop.cc index 6a9e4b413b0..d53c680037d 100644 --- a/test/core/end2end/tests/retry_lb_drop.cc +++ b/test/core/end2end/tests/retry_lb_drop.cc @@ -28,7 +28,6 @@ #include #include #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/config/core_configuration.h" diff --git a/test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc b/test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc index 4dec816f1e9..913da903038 100644 --- a/test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc +++ b/test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc @@ -28,7 +28,6 @@ #include "absl/strings/str_cat.h" #include -#include #include #include "src/core/lib/debug/trace.h" diff --git a/test/core/event_engine/posix/timer_heap_test.cc b/test/core/event_engine/posix/timer_heap_test.cc index cfc50cdcd3f..e9249444dd4 100644 --- a/test/core/event_engine/posix/timer_heap_test.cc +++ b/test/core/event_engine/posix/timer_heap_test.cc @@ -28,8 +28,6 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -#include - #include "src/core/lib/event_engine/posix_engine/timer.h" #include "src/core/lib/gprpp/bitset.h" diff --git a/test/core/event_engine/posix/traced_buffer_list_test.cc b/test/core/event_engine/posix/traced_buffer_list_test.cc index 1ae3a05cb94..b6c8c0b7b3d 100644 --- a/test/core/event_engine/posix/traced_buffer_list_test.cc +++ b/test/core/event_engine/posix/traced_buffer_list_test.cc @@ -22,7 +22,6 @@ #include "gtest/gtest.h" #include -#include #include #include "src/core/lib/gprpp/time.h" diff --git a/test/core/event_engine/slice_buffer_test.cc b/test/core/event_engine/slice_buffer_test.cc index 4e2ade3eefd..0a0c26f9520 100644 --- a/test/core/event_engine/slice_buffer_test.cc +++ b/test/core/event_engine/slice_buffer_test.cc @@ -24,7 +24,6 @@ #include #include #include -#include #include using ::grpc_event_engine::experimental::Slice; diff --git a/test/core/event_engine/tcp_socket_utils_test.cc b/test/core/event_engine/tcp_socket_utils_test.cc index 4826782e9f6..53ce735e478 100644 --- a/test/core/event_engine/tcp_socket_utils_test.cc +++ b/test/core/event_engine/tcp_socket_utils_test.cc @@ -51,7 +51,6 @@ #include "gtest/gtest.h" #include -#include #include "src/core/lib/iomgr/sockaddr.h" diff --git a/test/core/event_engine/test_suite/tests/client_test.cc b/test/core/event_engine/test_suite/tests/client_test.cc index 29c4ce35084..331d59a6c57 100644 --- a/test/core/event_engine/test_suite/tests/client_test.cc +++ b/test/core/event_engine/test_suite/tests/client_test.cc @@ -33,7 +33,6 @@ #include #include #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/event_engine/channel_args_endpoint_config.h" diff --git a/test/core/event_engine/test_suite/tests/server_test.cc b/test/core/event_engine/test_suite/tests/server_test.cc index 0ff5bfb411c..e71bcd58cb8 100644 --- a/test/core/event_engine/test_suite/tests/server_test.cc +++ b/test/core/event_engine/test_suite/tests/server_test.cc @@ -33,7 +33,6 @@ #include #include #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/event_engine/channel_args_endpoint_config.h" diff --git a/test/core/event_engine/test_suite/tools/windows_event_engine_factory.cc b/test/core/event_engine/test_suite/tools/windows_event_engine_factory.cc index 4b1bf530495..98f591fe604 100644 --- a/test/core/event_engine/test_suite/tools/windows_event_engine_factory.cc +++ b/test/core/event_engine/test_suite/tools/windows_event_engine_factory.cc @@ -18,7 +18,6 @@ #include "absl/log/check.h" #include -#include #include #ifdef GPR_WINDOWS diff --git a/test/core/ext/filters/event_engine_client_channel_resolver/resolver_fuzzer.cc b/test/core/ext/filters/event_engine_client_channel_resolver/resolver_fuzzer.cc index d655fedcf35..a363e872eac 100644 --- a/test/core/ext/filters/event_engine_client_channel_resolver/resolver_fuzzer.cc +++ b/test/core/ext/filters/event_engine_client_channel_resolver/resolver_fuzzer.cc @@ -27,7 +27,6 @@ #include "absl/strings/string_view.h" #include -#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/gprpp/chunked_vector_fuzzer.cc b/test/core/gprpp/chunked_vector_fuzzer.cc index 2a83b3df935..d857208c2e5 100644 --- a/test/core/gprpp/chunked_vector_fuzzer.cc +++ b/test/core/gprpp/chunked_vector_fuzzer.cc @@ -23,7 +23,6 @@ #include "absl/log/check.h" #include -#include #include "src/core/lib/gprpp/chunked_vector.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" diff --git a/test/core/gprpp/ref_counted_ptr_test.cc b/test/core/gprpp/ref_counted_ptr_test.cc index 12f619e5673..5c3e0f0f6c7 100644 --- a/test/core/gprpp/ref_counted_ptr_test.cc +++ b/test/core/gprpp/ref_counted_ptr_test.cc @@ -24,8 +24,6 @@ #include "absl/log/check.h" #include "gtest/gtest.h" -#include - #include "src/core/lib/gprpp/dual_ref_counted.h" #include "src/core/lib/gprpp/ref_counted.h" #include "test/core/test_util/test_config.h" diff --git a/test/core/iomgr/combiner_test.cc b/test/core/iomgr/combiner_test.cc index 0a8c0a45066..bdd625adad5 100644 --- a/test/core/iomgr/combiner_test.cc +++ b/test/core/iomgr/combiner_test.cc @@ -24,7 +24,6 @@ #include #include -#include #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/notification.h" diff --git a/test/core/iomgr/fd_conservation_posix_test.cc b/test/core/iomgr/fd_conservation_posix_test.cc index 28676454923..4a37f512a06 100644 --- a/test/core/iomgr/fd_conservation_posix_test.cc +++ b/test/core/iomgr/fd_conservation_posix_test.cc @@ -21,7 +21,6 @@ #include "absl/log/check.h" #include -#include #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/iomgr/endpoint_pair.h" diff --git a/test/core/iomgr/grpc_ipv6_loopback_available_test.cc b/test/core/iomgr/grpc_ipv6_loopback_available_test.cc index 34a2c59f7ce..2b8ae366778 100644 --- a/test/core/iomgr/grpc_ipv6_loopback_available_test.cc +++ b/test/core/iomgr/grpc_ipv6_loopback_available_test.cc @@ -19,7 +19,6 @@ #include #include -#include #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/iomgr/port.h" diff --git a/test/core/iomgr/socket_utils_test.cc b/test/core/iomgr/socket_utils_test.cc index edec3943f7c..6d56ad9d65c 100644 --- a/test/core/iomgr/socket_utils_test.cc +++ b/test/core/iomgr/socket_utils_test.cc @@ -31,7 +31,6 @@ #include "absl/log/check.h" #include -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/test/core/json/fuzzer.cc b/test/core/json/fuzzer.cc index 1ae8ad25429..bc17d74af3d 100644 --- a/test/core/json/fuzzer.cc +++ b/test/core/json/fuzzer.cc @@ -24,7 +24,6 @@ #include "absl/strings/string_view.h" #include -#include #include "src/core/util/json/json_reader.h" #include "src/core/util/json/json_writer.h" diff --git a/test/core/load_balancing/static_stride_scheduler_benchmark.cc b/test/core/load_balancing/static_stride_scheduler_benchmark.cc index ca882c63247..7ae3973637b 100644 --- a/test/core/load_balancing/static_stride_scheduler_benchmark.cc +++ b/test/core/load_balancing/static_stride_scheduler_benchmark.cc @@ -27,8 +27,6 @@ #include "absl/types/optional.h" #include "absl/types/span.h" -#include - #include "src/core/lib/gprpp/no_destruct.h" #include "src/core/load_balancing/weighted_round_robin/static_stride_scheduler.h" diff --git a/test/core/memory_usage/memstats.cc b/test/core/memory_usage/memstats.cc index 4a479ca5edd..cfac08bcf31 100644 --- a/test/core/memory_usage/memstats.cc +++ b/test/core/memory_usage/memstats.cc @@ -22,8 +22,6 @@ #include "absl/log/check.h" #include "absl/strings/str_cat.h" -#include - long GetMemUsage(absl::optional pid) { // Default is getting memory usage for self (calling process) std::string path = "/proc/self/stat"; diff --git a/test/core/nanopb/fuzzer_response.cc b/test/core/nanopb/fuzzer_response.cc index 9dd8ebbce7a..a952cf558dc 100644 --- a/test/core/nanopb/fuzzer_response.cc +++ b/test/core/nanopb/fuzzer_response.cc @@ -20,7 +20,6 @@ #include #include -#include #include "test/core/test_util/test_config.h" diff --git a/test/core/nanopb/fuzzer_serverlist.cc b/test/core/nanopb/fuzzer_serverlist.cc index 4e22041dfe5..278f4c4cbfa 100644 --- a/test/core/nanopb/fuzzer_serverlist.cc +++ b/test/core/nanopb/fuzzer_serverlist.cc @@ -20,7 +20,6 @@ #include #include -#include #include "test/core/test_util/test_config.h" diff --git a/test/core/promise/mpsc_test.cc b/test/core/promise/mpsc_test.cc index 0a486edff72..10fec6927a4 100644 --- a/test/core/promise/mpsc_test.cc +++ b/test/core/promise/mpsc_test.cc @@ -21,8 +21,6 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -#include - #include "src/core/lib/promise/activity.h" #include "src/core/lib/promise/promise.h" #include "test/core/promise/poll_matcher.h" diff --git a/test/core/promise/promise_fuzzer.cc b/test/core/promise/promise_fuzzer.cc index d74ad045ec4..0b70153d023 100644 --- a/test/core/promise/promise_fuzzer.cc +++ b/test/core/promise/promise_fuzzer.cc @@ -24,8 +24,6 @@ #include "absl/status/status.h" #include "absl/types/optional.h" -#include - #include "src/core/lib/promise/activity.h" #include "src/core/lib/promise/join.h" #include "src/core/lib/promise/map.h" diff --git a/test/core/resolver/endpoint_addresses_test.cc b/test/core/resolver/endpoint_addresses_test.cc index 236e26fe8e9..d5f14f624da 100644 --- a/test/core/resolver/endpoint_addresses_test.cc +++ b/test/core/resolver/endpoint_addresses_test.cc @@ -24,7 +24,6 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -#include #include #include "src/core/lib/address_utils/parse_address.h" diff --git a/test/core/resource_quota/memory_quota_fuzzer.cc b/test/core/resource_quota/memory_quota_fuzzer.cc index 2fb432cbe28..5fd70e8b59c 100644 --- a/test/core/resource_quota/memory_quota_fuzzer.cc +++ b/test/core/resource_quota/memory_quota_fuzzer.cc @@ -27,7 +27,6 @@ #include #include -#include #include "src/core/lib/debug/trace.h" #include "src/core/lib/experiments/config.h" diff --git a/test/core/resource_quota/periodic_update_test.cc b/test/core/resource_quota/periodic_update_test.cc index 90d98913693..1edc9b69420 100644 --- a/test/core/resource_quota/periodic_update_test.cc +++ b/test/core/resource_quota/periodic_update_test.cc @@ -22,7 +22,6 @@ #include "gtest/gtest.h" -#include #include #include "src/core/lib/iomgr/exec_ctx.h" diff --git a/test/core/security/alts_credentials_fuzzer.cc b/test/core/security/alts_credentials_fuzzer.cc index 224a5ea9859..4913a3b29c9 100644 --- a/test/core/security/alts_credentials_fuzzer.cc +++ b/test/core/security/alts_credentials_fuzzer.cc @@ -24,7 +24,6 @@ #include #include #include -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/test/core/security/check_gcp_environment_linux_test.cc b/test/core/security/check_gcp_environment_linux_test.cc index 1627aa67b67..4217c0eb346 100644 --- a/test/core/security/check_gcp_environment_linux_test.cc +++ b/test/core/security/check_gcp_environment_linux_test.cc @@ -22,7 +22,6 @@ #include #include -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/test/core/security/check_gcp_environment_windows_test.cc b/test/core/security/check_gcp_environment_windows_test.cc index d046565d8ab..8a1cbbb3fba 100644 --- a/test/core/security/check_gcp_environment_windows_test.cc +++ b/test/core/security/check_gcp_environment_windows_test.cc @@ -22,7 +22,6 @@ #include #include -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/test/core/security/create_jwt.cc b/test/core/security/create_jwt.cc index a8f48a9d179..79be2b68e1c 100644 --- a/test/core/security/create_jwt.cc +++ b/test/core/security/create_jwt.cc @@ -22,7 +22,6 @@ #include #include #include -#include #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/security/credentials/jwt/jwt_credentials.h" diff --git a/test/core/security/grpc_alts_credentials_options_test.cc b/test/core/security/grpc_alts_credentials_options_test.cc index 4168ffe7244..9c53cd25bf3 100644 --- a/test/core/security/grpc_alts_credentials_options_test.cc +++ b/test/core/security/grpc_alts_credentials_options_test.cc @@ -25,7 +25,6 @@ #include #include -#include #include "src/core/lib/gprpp/crash.h" diff --git a/test/core/security/grpc_tls_certificate_distributor_test.cc b/test/core/security/grpc_tls_certificate_distributor_test.cc index f43b15f38a9..e0fbd238468 100644 --- a/test/core/security/grpc_tls_certificate_distributor_test.cc +++ b/test/core/security/grpc_tls_certificate_distributor_test.cc @@ -27,7 +27,6 @@ #include "absl/log/check.h" #include -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/test/core/security/grpc_tls_certificate_provider_test.cc b/test/core/security/grpc_tls_certificate_provider_test.cc index ed0621fef74..31e7a06bd63 100644 --- a/test/core/security/grpc_tls_certificate_provider_test.cc +++ b/test/core/security/grpc_tls_certificate_provider_test.cc @@ -25,7 +25,6 @@ #include "absl/log/check.h" #include -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/test/core/security/grpc_tls_credentials_options_test.cc b/test/core/security/grpc_tls_credentials_options_test.cc index 4dde2e18b97..8270f7955dd 100644 --- a/test/core/security/grpc_tls_credentials_options_test.cc +++ b/test/core/security/grpc_tls_credentials_options_test.cc @@ -24,7 +24,6 @@ #include #include #include -#include #include #include "src/core/lib/config/config_vars.h" diff --git a/test/core/security/jwt_verifier_test.cc b/test/core/security/jwt_verifier_test.cc index 792fbe670cf..95d2d912a9c 100644 --- a/test/core/security/jwt_verifier_test.cc +++ b/test/core/security/jwt_verifier_test.cc @@ -27,7 +27,6 @@ #include #include #include -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/test/core/security/print_google_default_creds_token.cc b/test/core/security/print_google_default_creds_token.cc index b1636f0b5d5..305ea25eb59 100644 --- a/test/core/security/print_google_default_creds_token.cc +++ b/test/core/security/print_google_default_creds_token.cc @@ -26,7 +26,6 @@ #include #include #include -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/test/core/security/ssl_credentials_test.cc b/test/core/security/ssl_credentials_test.cc index 2a62fe4a8d8..5d1de6b08b0 100644 --- a/test/core/security/ssl_credentials_test.cc +++ b/test/core/security/ssl_credentials_test.cc @@ -25,7 +25,6 @@ #include #include -#include #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/security/security_connector/ssl_utils.h" diff --git a/test/core/security/ssl_server_fuzzer.cc b/test/core/security/ssl_server_fuzzer.cc index b2905467bc8..214a40812ec 100644 --- a/test/core/security/ssl_server_fuzzer.cc +++ b/test/core/security/ssl_server_fuzzer.cc @@ -23,7 +23,6 @@ #include #include #include -#include #include "src/core/lib/event_engine/default_event_engine.h" #include "src/core/lib/gprpp/notification.h" diff --git a/test/core/security/system_roots_test.cc b/test/core/security/system_roots_test.cc index 7dfaae7b92d..5bb566d89b1 100644 --- a/test/core/security/system_roots_test.cc +++ b/test/core/security/system_roots_test.cc @@ -31,7 +31,6 @@ #include #include -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/test/core/security/tls_security_connector_test.cc b/test/core/security/tls_security_connector_test.cc index 9bc1961b3e7..7c602c37750 100644 --- a/test/core/security/tls_security_connector_test.cc +++ b/test/core/security/tls_security_connector_test.cc @@ -28,7 +28,6 @@ #include #include -#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/security/verify_jwt.cc b/test/core/security/verify_jwt.cc index 5a322f39fa8..cf5a2581c92 100644 --- a/test/core/security/verify_jwt.cc +++ b/test/core/security/verify_jwt.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/test/core/slice/percent_encode_fuzzer.cc b/test/core/slice/percent_encode_fuzzer.cc index fc566f51db6..6deef7b8786 100644 --- a/test/core/slice/percent_encode_fuzzer.cc +++ b/test/core/slice/percent_encode_fuzzer.cc @@ -24,7 +24,6 @@ #include "absl/log/check.h" #include -#include #include "src/core/lib/slice/percent_encoding.h" #include "src/core/lib/slice/slice.h" diff --git a/test/core/slice/slice_buffer_test.cc b/test/core/slice/slice_buffer_test.cc index 3070b7a4a00..08bcf0429b7 100644 --- a/test/core/slice/slice_buffer_test.cc +++ b/test/core/slice/slice_buffer_test.cc @@ -24,7 +24,6 @@ #include #include -#include #include #include "src/core/lib/slice/slice.h" diff --git a/test/core/test_util/cmdline.cc b/test/core/test_util/cmdline.cc index b635870c384..f3bf0abbc69 100644 --- a/test/core/test_util/cmdline.cc +++ b/test/core/test_util/cmdline.cc @@ -32,7 +32,6 @@ #include "absl/strings/str_join.h" #include -#include #include "src/core/lib/gprpp/memory.h" diff --git a/test/core/test_util/histogram.cc b/test/core/test_util/histogram.cc index fae3d993347..c1b88b99268 100644 --- a/test/core/test_util/histogram.cc +++ b/test/core/test_util/histogram.cc @@ -24,7 +24,6 @@ #include "absl/log/check.h" #include -#include #include #include "src/core/util/useful.h" diff --git a/test/core/test_util/mock_endpoint.cc b/test/core/test_util/mock_endpoint.cc index eeae6858a83..e09fb191cb6 100644 --- a/test/core/test_util/mock_endpoint.cc +++ b/test/core/test_util/mock_endpoint.cc @@ -26,7 +26,6 @@ #include #include -#include #include #include "src/core/lib/event_engine/tcp_socket_utils.h" diff --git a/test/core/test_util/one_corpus_entry_fuzzer.cc b/test/core/test_util/one_corpus_entry_fuzzer.cc index 0737b779d1b..ffde40a4f0f 100644 --- a/test/core/test_util/one_corpus_entry_fuzzer.cc +++ b/test/core/test_util/one_corpus_entry_fuzzer.cc @@ -21,7 +21,6 @@ #include "absl/log/check.h" #include -#include #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/iomgr/exec_ctx.h" diff --git a/test/core/test_util/parse_hexstring.cc b/test/core/test_util/parse_hexstring.cc index e41b37ca86c..0ede85e2c09 100644 --- a/test/core/test_util/parse_hexstring.cc +++ b/test/core/test_util/parse_hexstring.cc @@ -24,7 +24,6 @@ #include "absl/log/check.h" #include -#include namespace grpc_core { Slice ParseHexstring(absl::string_view hexstring) { diff --git a/test/core/test_util/port.cc b/test/core/test_util/port.cc index ddecc426eb0..123608d61c2 100644 --- a/test/core/test_util/port.cc +++ b/test/core/test_util/port.cc @@ -27,7 +27,6 @@ #include #include -#include #include #include "src/core/lib/gprpp/sync.h" diff --git a/test/core/test_util/port_isolated_runtime_environment.cc b/test/core/test_util/port_isolated_runtime_environment.cc index b037ab70e79..8e841cf1b4d 100644 --- a/test/core/test_util/port_isolated_runtime_environment.cc +++ b/test/core/test_util/port_isolated_runtime_environment.cc @@ -27,7 +27,6 @@ #include "absl/log/check.h" #include -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/test/core/test_util/resolve_localhost_ip46.cc b/test/core/test_util/resolve_localhost_ip46.cc index a16de23f770..ba58738b8e4 100644 --- a/test/core/test_util/resolve_localhost_ip46.cc +++ b/test/core/test_util/resolve_localhost_ip46.cc @@ -25,7 +25,6 @@ #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" -#include #include #include "src/core/lib/iomgr/resolve_address.h" diff --git a/test/core/test_util/tls_utils.cc b/test/core/test_util/tls_utils.cc index 376ce9615ec..aca44f0fbb8 100644 --- a/test/core/test_util/tls_utils.cc +++ b/test/core/test_util/tls_utils.cc @@ -22,7 +22,6 @@ #include #include -#include #include #include diff --git a/test/core/transport/chttp2/flow_control_fuzzer.cc b/test/core/transport/chttp2/flow_control_fuzzer.cc index de541fed56e..99e82f4853a 100644 --- a/test/core/transport/chttp2/flow_control_fuzzer.cc +++ b/test/core/transport/chttp2/flow_control_fuzzer.cc @@ -32,7 +32,6 @@ #include "absl/types/optional.h" #include -#include #include #include "src/core/ext/transport/chttp2/transport/flow_control.h" diff --git a/test/core/transport/chttp2/graceful_shutdown_test.cc b/test/core/transport/chttp2/graceful_shutdown_test.cc index f4e4da7268f..4f24b8d65af 100644 --- a/test/core/transport/chttp2/graceful_shutdown_test.cc +++ b/test/core/transport/chttp2/graceful_shutdown_test.cc @@ -41,7 +41,6 @@ #include #include #include -#include #include #include "src/core/channelz/channelz.h" diff --git a/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc b/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc index a6296636b8e..538988ebf9f 100644 --- a/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc +++ b/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc @@ -28,7 +28,6 @@ #include #include -#include #include "src/core/ext/transport/chttp2/transport/hpack_parser.h" #include "src/core/lib/experiments/config.h" diff --git a/test/core/transport/chttp2/hpack_sync_fuzzer.cc b/test/core/transport/chttp2/hpack_sync_fuzzer.cc index bcc5a50c32f..2697029928d 100644 --- a/test/core/transport/chttp2/hpack_sync_fuzzer.cc +++ b/test/core/transport/chttp2/hpack_sync_fuzzer.cc @@ -27,8 +27,6 @@ #include "absl/strings/escaping.h" #include "absl/strings/match.h" -#include - #include "src/core/ext/transport/chttp2/transport/hpack_encoder.h" #include "src/core/ext/transport/chttp2/transport/hpack_encoder_table.h" #include "src/core/ext/transport/chttp2/transport/hpack_parser.h" diff --git a/test/core/transport/chttp2/streams_not_seen_test.cc b/test/core/transport/chttp2/streams_not_seen_test.cc index 98b78b3d628..cc296008f84 100644 --- a/test/core/transport/chttp2/streams_not_seen_test.cc +++ b/test/core/transport/chttp2/streams_not_seen_test.cc @@ -47,7 +47,6 @@ #include #include #include -#include #include #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" diff --git a/test/core/transport/chttp2/too_many_pings_test.cc b/test/core/transport/chttp2/too_many_pings_test.cc index 0beb9e2d0a8..8fd0570616f 100644 --- a/test/core/transport/chttp2/too_many_pings_test.cc +++ b/test/core/transport/chttp2/too_many_pings_test.cc @@ -40,7 +40,6 @@ #include #include #include -#include #include #include diff --git a/test/core/transport/parsed_metadata_test.cc b/test/core/transport/parsed_metadata_test.cc index bc8a59fab92..df6bc391f84 100644 --- a/test/core/transport/parsed_metadata_test.cc +++ b/test/core/transport/parsed_metadata_test.cc @@ -23,8 +23,6 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -#include - #include "src/core/lib/transport/metadata_batch.h" #include "test/core/test_util/test_config.h" diff --git a/test/core/tsi/alts/crypt/aes_gcm_test.cc b/test/core/tsi/alts/crypt/aes_gcm_test.cc index 2929d5bee5a..93ac19732c4 100644 --- a/test/core/tsi/alts/crypt/aes_gcm_test.cc +++ b/test/core/tsi/alts/crypt/aes_gcm_test.cc @@ -23,7 +23,6 @@ #include "absl/types/span.h" #include -#include #include "src/core/tsi/alts/crypt/gsec.h" #include "test/core/test_util/test_config.h" diff --git a/test/core/tsi/alts/frame_protector/alts_counter_test.cc b/test/core/tsi/alts/frame_protector/alts_counter_test.cc index baa516d27f6..b36700c9f27 100644 --- a/test/core/tsi/alts/frame_protector/alts_counter_test.cc +++ b/test/core/tsi/alts/frame_protector/alts_counter_test.cc @@ -21,7 +21,6 @@ #include #include -#include #include "src/core/lib/gprpp/crash.h" #include "test/core/tsi/alts/crypt/gsec_test_util.h" diff --git a/test/core/tsi/alts/frame_protector/alts_crypter_test.cc b/test/core/tsi/alts/frame_protector/alts_crypter_test.cc index fe930e63d70..2f834e411b7 100644 --- a/test/core/tsi/alts/frame_protector/alts_crypter_test.cc +++ b/test/core/tsi/alts/frame_protector/alts_crypter_test.cc @@ -29,7 +29,6 @@ #include "absl/types/span.h" #include -#include #include "test/core/tsi/alts/crypt/gsec_test_util.h" diff --git a/test/core/tsi/alts/frame_protector/alts_frame_protector_test.cc b/test/core/tsi/alts/frame_protector/alts_frame_protector_test.cc index 132fea59e69..e513caf0678 100644 --- a/test/core/tsi/alts/frame_protector/alts_frame_protector_test.cc +++ b/test/core/tsi/alts/frame_protector/alts_frame_protector_test.cc @@ -23,7 +23,6 @@ #include #include -#include #include "src/core/lib/gprpp/crash.h" #include "src/core/tsi/alts/crypt/gsec.h" diff --git a/test/core/tsi/alts/frame_protector/frame_handler_test.cc b/test/core/tsi/alts/frame_protector/frame_handler_test.cc index b5ddb31b9b6..feb7a5310aa 100644 --- a/test/core/tsi/alts/frame_protector/frame_handler_test.cc +++ b/test/core/tsi/alts/frame_protector/frame_handler_test.cc @@ -27,7 +27,6 @@ #include #include -#include #include "src/core/lib/gprpp/crash.h" #include "src/core/util/useful.h" diff --git a/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc b/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc index dd4a9ea42e6..51c08b6cce8 100644 --- a/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc +++ b/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc @@ -25,7 +25,6 @@ #include "absl/types/span.h" #include -#include #include "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.h" #include "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.h" diff --git a/test/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol_test.cc b/test/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol_test.cc index 833223e5f1c..248a496bd27 100644 --- a/test/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol_test.cc +++ b/test/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol_test.cc @@ -25,7 +25,6 @@ #include "absl/types/span.h" #include -#include #include "test/core/tsi/alts/crypt/gsec_test_util.h" diff --git a/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc b/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc index 108b4e9ec7e..aaab8c892cf 100644 --- a/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc +++ b/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc @@ -24,7 +24,6 @@ #include #include -#include #include "src/core/tsi/alts/crypt/gsec.h" #include "src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.h" diff --git a/test/core/tsi/crl_ssl_transport_security_test.cc b/test/core/tsi/crl_ssl_transport_security_test.cc index e314218e2d2..37f0f905b16 100644 --- a/test/core/tsi/crl_ssl_transport_security_test.cc +++ b/test/core/tsi/crl_ssl_transport_security_test.cc @@ -29,7 +29,6 @@ #include #include -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/test/core/tsi/fake_transport_security_test.cc b/test/core/tsi/fake_transport_security_test.cc index 711a8f2cdbe..69c280717a4 100644 --- a/test/core/tsi/fake_transport_security_test.cc +++ b/test/core/tsi/fake_transport_security_test.cc @@ -26,7 +26,6 @@ #include #include -#include #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/security/security_connector/security_connector.h" diff --git a/test/core/tsi/ssl_session_cache_test.cc b/test/core/tsi/ssl_session_cache_test.cc index 91af924adb9..f9711f2eba1 100644 --- a/test/core/tsi/ssl_session_cache_test.cc +++ b/test/core/tsi/ssl_session_cache_test.cc @@ -26,7 +26,6 @@ #include "absl/log/check.h" #include -#include #include "src/core/lib/gprpp/crash.h" #include "test/core/test_util/test_config.h" diff --git a/test/core/tsi/transport_security_test_lib.cc b/test/core/tsi/transport_security_test_lib.cc index bf0d7415d9a..1c744415db2 100644 --- a/test/core/tsi/transport_security_test_lib.cc +++ b/test/core/tsi/transport_security_test_lib.cc @@ -36,7 +36,6 @@ #include #include -#include #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/memory.h" diff --git a/test/core/xds/certificate_provider_store_test.cc b/test/core/xds/certificate_provider_store_test.cc index adcd41f3833..3cbd6146059 100644 --- a/test/core/xds/certificate_provider_store_test.cc +++ b/test/core/xds/certificate_provider_store_test.cc @@ -27,7 +27,6 @@ #include "gtest/gtest.h" #include -#include #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/gprpp/unique_type_name.h" diff --git a/test/core/xds/xds_client_test.cc b/test/core/xds/xds_client_test.cc index be135ae5dab..a970e217360 100644 --- a/test/core/xds/xds_client_test.cc +++ b/test/core/xds/xds_client_test.cc @@ -44,7 +44,6 @@ #include #include -#include #include #include "src/core/lib/event_engine/default_event_engine.h" diff --git a/test/core/xds/xds_http_filters_test.cc b/test/core/xds/xds_http_filters_test.cc index eb2339e4e33..d57d5f5650c 100644 --- a/test/core/xds/xds_http_filters_test.cc +++ b/test/core/xds/xds_http_filters_test.cc @@ -34,7 +34,6 @@ #include #include #include -#include #include #include "src/core/ext/filters/fault_injection/fault_injection_filter.h" diff --git a/test/cpp/client/destroy_grpclb_channel_with_active_connect_stress_test.cc b/test/cpp/client/destroy_grpclb_channel_with_active_connect_stress_test.cc index a41aa0011a0..9331d2042c6 100644 --- a/test/cpp/client/destroy_grpclb_channel_with_active_connect_stress_test.cc +++ b/test/cpp/client/destroy_grpclb_channel_with_active_connect_stress_test.cc @@ -27,7 +27,6 @@ #include #include -#include #include #include #include diff --git a/test/cpp/end2end/client_crash_test.cc b/test/cpp/end2end/client_crash_test.cc index 21a118e9e72..fbd98164931 100644 --- a/test/cpp/end2end/client_crash_test.cc +++ b/test/cpp/end2end/client_crash_test.cc @@ -22,7 +22,6 @@ #include "absl/memory/memory.h" #include -#include #include #include #include diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc index 324720902de..e4b3de512ae 100644 --- a/test/cpp/end2end/client_lb_end2end_test.cc +++ b/test/cpp/end2end/client_lb_end2end_test.cc @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc index ef1cfc1382d..a640d8b499a 100644 --- a/test/cpp/end2end/grpclb_end2end_test.cc +++ b/test/cpp/end2end/grpclb_end2end_test.cc @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include diff --git a/test/cpp/end2end/health_service_end2end_test.cc b/test/cpp/end2end/health_service_end2end_test.cc index 002fa26218b..48209bb5e49 100644 --- a/test/cpp/end2end/health_service_end2end_test.cc +++ b/test/cpp/end2end/health_service_end2end_test.cc @@ -24,7 +24,6 @@ #include #include -#include #include #include #include diff --git a/test/cpp/end2end/raw_end2end_test.cc b/test/cpp/end2end/raw_end2end_test.cc index 8c304bc4a08..c41bb7a60df 100644 --- a/test/cpp/end2end/raw_end2end_test.cc +++ b/test/cpp/end2end/raw_end2end_test.cc @@ -26,7 +26,6 @@ #include #include -#include #include #include #include diff --git a/test/cpp/end2end/server_early_return_test.cc b/test/cpp/end2end/server_early_return_test.cc index 010b9d480af..2489b09341c 100644 --- a/test/cpp/end2end/server_early_return_test.cc +++ b/test/cpp/end2end/server_early_return_test.cc @@ -20,7 +20,6 @@ #include #include -#include #include #include #include diff --git a/test/cpp/end2end/time_change_test.cc b/test/cpp/end2end/time_change_test.cc index af74f8bdd50..fa7dff06028 100644 --- a/test/cpp/end2end/time_change_test.cc +++ b/test/cpp/end2end/time_change_test.cc @@ -26,7 +26,6 @@ #include "absl/memory/memory.h" #include -#include #include #include #include diff --git a/test/cpp/ext/otel/otel_plugin_test.cc b/test/cpp/ext/otel/otel_plugin_test.cc index cbc9b18fc42..22b971ac370 100644 --- a/test/cpp/ext/otel/otel_plugin_test.cc +++ b/test/cpp/ext/otel/otel_plugin_test.cc @@ -1715,14 +1715,8 @@ TEST_F(OpenTelemetryPluginNPCMetricsTest, InstrumentsEnabledTest) { EXPECT_FALSE(stats_plugins.IsInstrumentEnabled(counter_handle)); } -class OpenTelemetryPluginCallbackMetricsTest - : public OpenTelemetryPluginEnd2EndTest { - protected: - OpenTelemetryPluginCallbackMetricsTest() - : endpoint_config_(grpc_core::ChannelArgs()) {} - - grpc_event_engine::experimental::ChannelArgsEndpointConfig endpoint_config_; -}; +using OpenTelemetryPluginCallbackMetricsTest = + OpenTelemetryPluginNPCMetricsTest; // The callback minimal interval is longer than the OT reporting interval, so we // expect to collect duplicated (cached) values. @@ -1775,14 +1769,11 @@ TEST_F(OpenTelemetryPluginCallbackMetricsTest, auto registered_metric_callback_1 = stats_plugins.RegisterCallback( [&](grpc_core::CallbackMetricReporter& reporter) { ++report_count_1; - reporter.Report(integer_gauge_handle, int_value_1, kLabelValuesSet1, + reporter.Report(integer_gauge_handle, int_value_1++, kLabelValuesSet1, kOptionalLabelValuesSet1); - reporter.Report(integer_gauge_handle, int_value_1++, kLabelValuesSet2, - kOptionalLabelValuesSet2); - reporter.Report(double_gauge_handle, double_value_1, kLabelValuesSet1, + reporter.Report(double_gauge_handle, double_value_1++, kLabelValuesSet1, kOptionalLabelValuesSet1); - reporter.Report(double_gauge_handle, double_value_1++, kLabelValuesSet2, - kOptionalLabelValuesSet2); + ; }, grpc_core::Duration::Milliseconds(100) * grpc_test_slowdown_factor(), integer_gauge_handle, double_gauge_handle); @@ -1792,12 +1783,8 @@ TEST_F(OpenTelemetryPluginCallbackMetricsTest, auto registered_metric_callback_2 = stats_plugins.RegisterCallback( [&](grpc_core::CallbackMetricReporter& reporter) { ++report_count_2; - reporter.Report(integer_gauge_handle, int_value_2, kLabelValuesSet1, - kOptionalLabelValuesSet1); reporter.Report(integer_gauge_handle, int_value_2++, kLabelValuesSet2, kOptionalLabelValuesSet2); - reporter.Report(double_gauge_handle, double_value_2, kLabelValuesSet1, - kOptionalLabelValuesSet1); reporter.Report(double_gauge_handle, double_value_2++, kLabelValuesSet2, kOptionalLabelValuesSet2); }, @@ -1910,14 +1897,10 @@ TEST_F(OpenTelemetryPluginCallbackMetricsTest, auto registered_metric_callback_1 = stats_plugins.RegisterCallback( [&](grpc_core::CallbackMetricReporter& reporter) { ++report_count_1; - reporter.Report(integer_gauge_handle, int_value_1, kLabelValuesSet1, + reporter.Report(integer_gauge_handle, int_value_1++, kLabelValuesSet1, kOptionalLabelValuesSet1); - reporter.Report(integer_gauge_handle, int_value_1++, kLabelValuesSet2, - kOptionalLabelValuesSet2); - reporter.Report(double_gauge_handle, double_value_1, kLabelValuesSet1, + reporter.Report(double_gauge_handle, double_value_1++, kLabelValuesSet1, kOptionalLabelValuesSet1); - reporter.Report(double_gauge_handle, double_value_1++, kLabelValuesSet2, - kOptionalLabelValuesSet2); }, grpc_core::Duration::Milliseconds(50) * grpc_test_slowdown_factor(), integer_gauge_handle, double_gauge_handle); @@ -1927,12 +1910,8 @@ TEST_F(OpenTelemetryPluginCallbackMetricsTest, auto registered_metric_callback_2 = stats_plugins.RegisterCallback( [&](grpc_core::CallbackMetricReporter& reporter) { ++report_count_2; - reporter.Report(integer_gauge_handle, int_value_2, kLabelValuesSet1, - kOptionalLabelValuesSet1); reporter.Report(integer_gauge_handle, int_value_2++, kLabelValuesSet2, kOptionalLabelValuesSet2); - reporter.Report(double_gauge_handle, double_value_2, kLabelValuesSet1, - kOptionalLabelValuesSet1); reporter.Report(double_gauge_handle, double_value_2++, kLabelValuesSet2, kOptionalLabelValuesSet2); }, @@ -1996,6 +1975,116 @@ TEST_F(OpenTelemetryPluginCallbackMetricsTest, kOptionalLabelKeys, kOptionalLabelValuesSet2, 0.0, true)); } +// Verifies that callbacks are cleaned up when the OpenTelemetry plugin is +// destroyed. +TEST_F(OpenTelemetryPluginCallbackMetricsTest, VerifyCallbacksAreCleanedUp) { + constexpr absl::string_view kInt64CallbackGaugeMetric = + "yet_another_int64_callback_gauge"; + constexpr absl::string_view kDoubleCallbackGaugeMetric = + "yet_another_double_callback_gauge"; + auto integer_gauge_handle = + grpc_core::GlobalInstrumentsRegistry::RegisterCallbackInt64Gauge( + kInt64CallbackGaugeMetric, "An int64 callback gauge.", "unit", + /*enable_by_default=*/true) + .Build(); + auto double_gauge_handle = + grpc_core::GlobalInstrumentsRegistry::RegisterCallbackDoubleGauge( + kDoubleCallbackGaugeMetric, "A double callback gauge.", "unit", + /*enable_by_default=*/true) + .Build(); + Init(std::move(Options().set_metric_names( + {kInt64CallbackGaugeMetric, kDoubleCallbackGaugeMetric}))); + auto stats_plugins = + grpc_core::GlobalStatsPluginRegistry::GetStatsPluginsForChannel( + grpc_core::experimental::StatsPluginChannelScope( + "dns:///localhost:8080", "", endpoint_config_)); + // Multiple callbacks for the same metrics, each reporting different + // label values. + int report_count_1 = 0; + int64_t int_value_1 = 1; + double double_value_1 = 0.5; + auto registered_metric_callback_1 = stats_plugins.RegisterCallback( + [&](grpc_core::CallbackMetricReporter& reporter) { + ++report_count_1; + reporter.Report(integer_gauge_handle, int_value_1++, {}, {}); + reporter.Report(double_gauge_handle, double_value_1++, {}, {}); + }, + grpc_core::Duration::Milliseconds(50) * grpc_test_slowdown_factor(), + integer_gauge_handle, double_gauge_handle); + int report_count_2 = 0; + int64_t int_value_2 = 1; + double double_value_2 = 0.5; + auto registered_metric_callback_2 = stats_plugins.RegisterCallback( + [&](grpc_core::CallbackMetricReporter& reporter) { + ++report_count_2; + reporter.Report(integer_gauge_handle, int_value_2++, {}, {}); + reporter.Report(double_gauge_handle, double_value_2++, {}, {}); + }, + grpc_core::Duration::Milliseconds(50) * grpc_test_slowdown_factor(), + integer_gauge_handle, double_gauge_handle); + constexpr int kIterations = 50; + { + MetricsCollectorThread collector{ + this, + grpc_core::Duration::Milliseconds(100) * grpc_test_slowdown_factor(), + kIterations, + [&](const absl::flat_hash_map< + std::string, + std::vector>& + data) { + return !data.contains(kInt64CallbackGaugeMetric) || + !data.contains(kDoubleCallbackGaugeMetric); + }}; + } + // Verify that callbacks are invoked + EXPECT_EQ(report_count_1, kIterations); + EXPECT_EQ(report_count_2, kIterations); + // Remove one of the callbacks + registered_metric_callback_1.reset(); + { + MetricsCollectorThread new_collector{ + this, + grpc_core::Duration::Milliseconds(100) * grpc_test_slowdown_factor(), + kIterations, + [&](const absl::flat_hash_map< + std::string, + std::vector>& + data) { return false; }}; + } + EXPECT_EQ(report_count_1, kIterations); // No change since previous + EXPECT_EQ(report_count_2, 2 * kIterations); // Gets another kIterations + // Remove the other callback as well + registered_metric_callback_2.reset(); + MetricsCollectorThread new_new_collector{ + this, + grpc_core::Duration::Milliseconds(100) * grpc_test_slowdown_factor(), + kIterations, + [&](const absl::flat_hash_map< + std::string, + std::vector>& + data) { return false; }}; + // We shouldn't get any new callbacks + EXPECT_THAT(new_new_collector.Stop(), ::testing::IsEmpty()); + EXPECT_EQ(report_count_1, kIterations); + EXPECT_EQ(report_count_2, 2 * kIterations); + // Reset stats plugins as well + grpc_core::GlobalStatsPluginRegistryTestPeer:: + ResetGlobalStatsPluginRegistry(); + registered_metric_callback_2.reset(); + MetricsCollectorThread new_new_new_collector{ + this, + grpc_core::Duration::Milliseconds(100) * grpc_test_slowdown_factor(), + kIterations, + [&](const absl::flat_hash_map< + std::string, + std::vector>& + data) { return false; }}; + // Still no new callbacks + EXPECT_THAT(new_new_new_collector.Stop(), ::testing::IsEmpty()); + EXPECT_EQ(report_count_1, kIterations); + EXPECT_EQ(report_count_2, 2 * kIterations); +} + TEST(OpenTelemetryPluginMetricsEnablingDisablingTest, TestEnableDisableAPIs) { grpc::internal::OpenTelemetryPluginBuilderImpl builder; // First disable all metrics diff --git a/test/cpp/interop/metrics_client.cc b/test/cpp/interop/metrics_client.cc index f15466edcc4..c42208fd46c 100644 --- a/test/cpp/interop/metrics_client.cc +++ b/test/cpp/interop/metrics_client.cc @@ -21,7 +21,6 @@ #include "absl/flags/flag.h" -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/test/cpp/microbenchmarks/bm_basic_work_queue.cc b/test/cpp/microbenchmarks/bm_basic_work_queue.cc index d76f0767861..320c8fc5093 100644 --- a/test/cpp/microbenchmarks/bm_basic_work_queue.cc +++ b/test/cpp/microbenchmarks/bm_basic_work_queue.cc @@ -18,7 +18,6 @@ #include "absl/log/check.h" #include -#include #include #include "src/core/lib/event_engine/common_closures.h" diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc index 0cd5de5c2c4..6b769f7da7f 100644 --- a/test/cpp/microbenchmarks/bm_cq.cc +++ b/test/cpp/microbenchmarks/bm_cq.cc @@ -24,7 +24,6 @@ #include "absl/log/check.h" #include -#include #include #include diff --git a/test/cpp/naming/cancel_ares_query_test.cc b/test/cpp/naming/cancel_ares_query_test.cc index cf8d813f623..775dc1961ce 100644 --- a/test/cpp/naming/cancel_ares_query_test.cc +++ b/test/cpp/naming/cancel_ares_query_test.cc @@ -32,7 +32,6 @@ #include #include #include -#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/cpp/qps/benchmark_config.cc b/test/cpp/qps/benchmark_config.cc index 906f128d746..39cfbe6b18f 100644 --- a/test/cpp/qps/benchmark_config.cc +++ b/test/cpp/qps/benchmark_config.cc @@ -21,7 +21,6 @@ #include "absl/flags/flag.h" #include "absl/log/check.h" -#include #include #include diff --git a/test/cpp/util/channel_trace_proto_helper.cc b/test/cpp/util/channel_trace_proto_helper.cc index 677862fbf12..8acb762a889 100644 --- a/test/cpp/util/channel_trace_proto_helper.cc +++ b/test/cpp/util/channel_trace_proto_helper.cc @@ -21,7 +21,6 @@ #include #include -#include #include #include #include diff --git a/test/cpp/util/cli_call.cc b/test/cpp/util/cli_call.cc index df765c64a49..3cae389d898 100644 --- a/test/cpp/util/cli_call.cc +++ b/test/cpp/util/cli_call.cc @@ -26,7 +26,6 @@ #include #include -#include #include #include #include diff --git a/test/cpp/util/cli_credentials.cc b/test/cpp/util/cli_credentials.cc index 8b178524df8..d0c355a09cc 100644 --- a/test/cpp/util/cli_credentials.cc +++ b/test/cpp/util/cli_credentials.cc @@ -22,7 +22,6 @@ #include "absl/log/log.h" #include -#include #include #include "src/core/lib/gprpp/crash.h" diff --git a/test/cpp/util/create_test_channel.cc b/test/cpp/util/create_test_channel.cc index f5c3a9a037e..a355c15ce20 100644 --- a/test/cpp/util/create_test_channel.cc +++ b/test/cpp/util/create_test_channel.cc @@ -21,7 +21,6 @@ #include "absl/flags/flag.h" #include "absl/log/check.h" -#include #include #include diff --git a/test/cpp/util/metrics_server.cc b/test/cpp/util/metrics_server.cc index 59d3dcead15..57a3abf3ea7 100644 --- a/test/cpp/util/metrics_server.cc +++ b/test/cpp/util/metrics_server.cc @@ -20,7 +20,6 @@ #include "absl/log/log.h" -#include #include #include diff --git a/test/cpp/util/test_credentials_provider.cc b/test/cpp/util/test_credentials_provider.cc index c94f0a054bd..0198a3f14ff 100644 --- a/test/cpp/util/test_credentials_provider.cc +++ b/test/cpp/util/test_credentials_provider.cc @@ -29,7 +29,6 @@ #include "absl/log/check.h" #include "absl/log/log.h" -#include #include #include diff --git a/test/cpp/util/windows/manifest_file.cc b/test/cpp/util/windows/manifest_file.cc index 0bf2c9d3f01..a1f377032fd 100644 --- a/test/cpp/util/windows/manifest_file.cc +++ b/test/cpp/util/windows/manifest_file.cc @@ -29,8 +29,6 @@ #include "absl/strings/str_replace.h" #include "absl/strings/str_split.h" -#include - #include "src/core/lib/gprpp/crash.h" namespace grpc { diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 40501c821bc..af16cffbd10 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -1073,6 +1073,7 @@ include/grpcpp/support/channel_arguments.h \ include/grpcpp/support/client_callback.h \ include/grpcpp/support/client_interceptor.h \ include/grpcpp/support/config.h \ +include/grpcpp/support/global_callback_hook.h \ include/grpcpp/support/interceptor.h \ include/grpcpp/support/message_allocator.h \ include/grpcpp/support/method_handler.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 68987e28551..7843c17dae2 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1073,6 +1073,7 @@ include/grpcpp/support/channel_arguments.h \ include/grpcpp/support/client_callback.h \ include/grpcpp/support/client_interceptor.h \ include/grpcpp/support/config.h \ +include/grpcpp/support/global_callback_hook.h \ include/grpcpp/support/interceptor.h \ include/grpcpp/support/message_allocator.h \ include/grpcpp/support/method_handler.h \ @@ -3046,6 +3047,7 @@ src/cpp/client/create_channel.cc \ src/cpp/client/create_channel_internal.cc \ src/cpp/client/create_channel_internal.h \ src/cpp/client/create_channel_posix.cc \ +src/cpp/client/global_callback_hook.cc \ src/cpp/client/insecure_credentials.cc \ src/cpp/client/secure_credentials.cc \ src/cpp/client/secure_credentials.h \ diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index ab43a6c0868..4363c0482dc 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -134,6 +134,7 @@ LANG_RELEASE_MATRIX = { ("v1.62.0", ReleaseInfo()), ("v1.63.1", ReleaseInfo()), ("v1.64.1", ReleaseInfo()), + ("v1.65.0", ReleaseInfo()), ] ), "go": OrderedDict( @@ -799,6 +800,12 @@ LANG_RELEASE_MATRIX = { runtimes=["python"], testcases_file="python__master" ), ), + ( + "v1.65.0", + ReleaseInfo( + runtimes=["python"], testcases_file="python__master" + ), + ), ] ), "node": OrderedDict( @@ -897,6 +904,7 @@ LANG_RELEASE_MATRIX = { ("v1.62.0", ReleaseInfo()), ("v1.63.0", ReleaseInfo()), ("v1.64.0", ReleaseInfo()), + ("v1.65.0", ReleaseInfo()), ] ), "php": OrderedDict( @@ -959,6 +967,7 @@ LANG_RELEASE_MATRIX = { ("v1.62.0", ReleaseInfo()), ("v1.63.0", ReleaseInfo()), ("v1.64.0", ReleaseInfo()), + ("v1.65.0", ReleaseInfo()), ] ), "csharp": OrderedDict( diff --git a/tools/run_tests/sanity/banned_functions.py b/tools/run_tests/sanity/banned_functions.py index ec8e8b2ec14..762c8349ba6 100755 --- a/tools/run_tests/sanity/banned_functions.py +++ b/tools/run_tests/sanity/banned_functions.py @@ -37,11 +37,6 @@ os.chdir(os.path.join(os.path.dirname(sys.argv[0]), "../../..")) # Map of deprecated functions to allowlist files DEPRECATED_FUNCTION_TEMP_ALLOW_LIST = { - "absl_vlog2_enabled(": [ - "./include/grpc/support/log.h", - "./src/core/util/log.cc", - "./src/ruby/ext/grpc/rb_call_credentials.c", - ], "gpr_log_severity": [ "./include/grpc/support/log.h", "./src/core/util/android/log.cc", @@ -93,10 +88,6 @@ DEPRECATED_FUNCTION_TEMP_ALLOW_LIST = { errors = 0 num_files = 0 for root, dirs, files in os.walk("."): - if root.startswith( - "./tools/distrib/python/grpcio_tools" - ) or root.startswith("./src/python"): - continue for filename in files: num_files += 1 path = os.path.join(root, filename) @@ -112,7 +103,7 @@ for root, dirs, files in os.walk("."): if deprecated in text: print( ( - 'Illegal use of "%s" in %s . Use absl functions instead.' + 'Illegal use of "%s" in %s. Use absl functions instead.' % (deprecated, path) ) )