Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add channelz support and the admin interface #1915

Merged
merged 8 commits into from
Oct 6, 2021

Conversation

murgatroid99
Copy link
Member

Add channelz functionality to grpc-js (see gRFC A14), along with the admin interface (see gRFC A38).

There are three main parts of this change:

  • The channelz bookkeeping logic, which is spread among the first part of channelz.ts, channel.ts, subchannel.ts, and server.ts, with small parts in call-stream.ts and server-call.ts to count messages.
  • The channelz service handler code, which all lives in the second part of channelz.ts.
  • The admin interface, which is simply a registry of service definitions and corresponding service handlers to be added to a server as a group using the addAdminServicesToServer function. The registration function takes getters instead of plain objects to support retrieving those things lazily, which allows us to load the channelz service lazily so that we do not need to load protobufjs in applications that do not use channelz.

This change adds the following public APIs:

  • getChannelzServiceDefinition(): ServiceDefinition
  • getChannelzHandlers(): ServiceHandler
  • addAdminServicesToServer(server: Server): void
  • Channel#getChannelzRef(): ChannelRef
  • Server#getChannelzRef(): ServerRef

The intended use is for a user to do one of the following to serve the channelz service:

const server = new grpc.Server();
server.addService(grpc.getChannelzServiceDefinition(), grpc.getChannelzHandlers());

OR

const server = new grpc.Server();
grpc.addAdminServicesToServer(server);

In addition, I modified the channel, subchannel, and server trace logs to include the channelz ID to make them easier to cross-reference.

The new channelz_manual_test.js file just starts a server and a client that continuously makes requests to that server, and starts another server serving the channelz service, for a separate channelz client to examine.

@@ -0,0 +1,564 @@
// Copyright 2018 The gRPC Authors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd still be great at some point if we had a common repository for those...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, there is actually https://github.com/grpc/grpc-proto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants