Add a trace to list which filters are contained in a channel stack (#28530)

* Add a trace to emit what a channel stack looks like

* Add a trace to emit what a channel stack looks like

* x
pull/28534/head
Craig Tiller 3 years ago committed by GitHub
parent d2d2d0650a
commit 2bdd5bd8e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      src/core/ext/filters/client_channel/subchannel.cc
  2. 8
      src/core/lib/channel/channel_stack.cc
  3. 10
      src/core/lib/channel/channel_stack_builder.cc
  4. 9
      src/core/lib/channel/channel_stack_builder.h
  5. 4
      src/core/lib/surface/channel.cc
  6. 3
      test/core/channel/minimal_stack_is_minimal_test.cc
  7. 6
      test/core/xds/xds_channel_stack_modifier_test.cc
  8. 4
      test/cpp/microbenchmarks/bm_call_create.cc

@ -964,7 +964,8 @@ void ConnectionDestroy(void* arg, grpc_error_handle /*error*/) {
bool Subchannel::PublishTransportLocked() {
// Construct channel stack.
grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create();
grpc_channel_stack_builder* builder =
grpc_channel_stack_builder_create("subchannel");
grpc_channel_stack_builder_set_channel_arguments(
builder, connecting_result_.channel_args);
grpc_channel_stack_builder_set_transport(builder,

@ -29,6 +29,7 @@
#include "src/core/lib/gpr/alloc.h"
grpc_core::TraceFlag grpc_trace_channel(false, "channel");
grpc_core::TraceFlag grpc_trace_channel_stack(false, "channel_stack");
/* Memory layouts.
@ -105,6 +106,13 @@ grpc_error_handle grpc_channel_stack_init(
const grpc_channel_filter** filters, size_t filter_count,
const grpc_channel_args* channel_args, grpc_transport* optional_transport,
const char* name, grpc_channel_stack* stack) {
if (grpc_trace_channel_stack.enabled()) {
gpr_log(GPR_INFO, "CHANNEL_STACK: init %s", name);
for (size_t i = 0; i < filter_count; i++) {
gpr_log(GPR_INFO, "CHANNEL_STACK: filter %s", filters[i]->name);
}
}
size_t call_size =
GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_call_stack)) +
GPR_ROUND_UP_TO_ALIGNMENT_SIZE(filter_count * sizeof(grpc_call_element));

@ -51,7 +51,8 @@ struct grpc_channel_stack_builder_iterator {
filter_node* node;
};
grpc_channel_stack_builder* grpc_channel_stack_builder_create(void) {
grpc_channel_stack_builder* grpc_channel_stack_builder_create(
const char* name) {
grpc_channel_stack_builder* b =
grpc_core::Zalloc<grpc_channel_stack_builder>();
b->begin.filter = nullptr;
@ -60,6 +61,7 @@ grpc_channel_stack_builder* grpc_channel_stack_builder_create(void) {
b->begin.prev = &b->end;
b->end.next = &b->begin;
b->end.prev = &b->begin;
b->name = name;
return b;
}
@ -143,12 +145,6 @@ grpc_channel_stack_builder_iterator* grpc_channel_stack_builder_iterator_find(
bool grpc_channel_stack_builder_move_prev(
grpc_channel_stack_builder_iterator* iterator);
void grpc_channel_stack_builder_set_name(grpc_channel_stack_builder* builder,
const char* name) {
GPR_ASSERT(builder->name == nullptr);
builder->name = name;
}
void grpc_channel_stack_builder_set_channel_arguments(
grpc_channel_stack_builder* builder, const grpc_channel_args* args) {
if (builder->args != nullptr) {

@ -32,12 +32,9 @@ typedef struct grpc_channel_stack_builder grpc_channel_stack_builder;
typedef struct grpc_channel_stack_builder_iterator
grpc_channel_stack_builder_iterator;
/// Create a new channel stack builder
grpc_channel_stack_builder* grpc_channel_stack_builder_create(void);
/// Assign a name to the channel stack: \a name must be statically allocated
void grpc_channel_stack_builder_set_name(grpc_channel_stack_builder* builder,
const char* name);
/// Create a new channel stack builder.
/// \a name must be statically allocated.
grpc_channel_stack_builder* grpc_channel_stack_builder_create(const char* name);
/// Set the target uri
void grpc_channel_stack_builder_set_target(grpc_channel_stack_builder* b,

@ -46,6 +46,7 @@
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/call.h"
#include "src/core/lib/surface/channel_stack_type.h"
/** Cache grpc-status: X mdelems for X = 0..NUM_CACHED_STATUS_ELEMS.
* Avoids needing to take a metadata context lock for sending status
@ -243,7 +244,8 @@ grpc_channel* grpc_channel_create(const char* target,
// grpc_shutdown() when the channel is actually destroyed, thus
// ensuring that shutdown is deferred until that point.
grpc_init();
grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create();
grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create(
grpc_channel_stack_type_string(channel_stack_type));
const grpc_core::UniquePtr<char> default_authority =
get_default_authority(input_args);
grpc_channel_args* args =

@ -126,7 +126,8 @@ static int check_stack(const char* file, int line, const char* transport_name,
grpc_channel_args* init_args,
unsigned channel_stack_type, ...) {
// create phony channel stack
grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create();
grpc_channel_stack_builder* builder =
grpc_channel_stack_builder_create("test");
grpc_transport_vtable fake_transport_vtable;
memset(&fake_transport_vtable, 0, sizeof(grpc_transport_vtable));
fake_transport_vtable.name = transport_name;

@ -79,7 +79,8 @@ TEST(XdsChannelStackModifierTest, XdsHttpFiltersInsertion) {
grpc_arg arg = channel_stack_modifier->MakeChannelArg();
// Create a phony grpc_channel_stack_builder object
grpc_channel_args* args = grpc_channel_args_copy_and_add(nullptr, &arg, 1);
grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create();
grpc_channel_stack_builder* builder =
grpc_channel_stack_builder_create("test");
grpc_channel_stack_builder_set_channel_arguments(builder, args);
grpc_channel_args_destroy(args);
grpc_transport_vtable fake_transport_vtable;
@ -123,7 +124,8 @@ TEST(XdsChannelStackModifierTest, XdsHttpFiltersInsertionAfterCensus) {
grpc_arg arg = channel_stack_modifier->MakeChannelArg();
// Create a phony grpc_channel_stack_builder object
grpc_channel_args* args = grpc_channel_args_copy_and_add(nullptr, &arg, 1);
grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create();
grpc_channel_stack_builder* builder =
grpc_channel_stack_builder_create("test");
grpc_channel_stack_builder_set_channel_arguments(builder, args);
grpc_channel_args_destroy(args);
grpc_transport_vtable fake_transport_vtable;

@ -707,8 +707,8 @@ class IsolatedCallFixture : public TrackCounters {
const grpc_channel_args* args = grpc_core::CoreConfiguration::Get()
.channel_args_preconditioning()
.PreconditionChannelArgs(nullptr);
grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create();
grpc_channel_stack_builder_set_name(builder, "phony");
grpc_channel_stack_builder* builder =
grpc_channel_stack_builder_create("phony");
grpc_channel_stack_builder_set_target(builder, "phony_target");
grpc_channel_stack_builder_set_channel_arguments(builder, args);
GPR_ASSERT(grpc_channel_stack_builder_append_filter(

Loading…
Cancel
Save