getting the simple method name from `MethodDescriptor`

59 views
Skip to first unread message

Noel Yap

unread,
Jan 17, 2017, 7:07:52 PM1/17/17
to grp...@googlegroups.com
We have a need to get the simple method name from MethodDescriptor. For example, the simple service name of service/method is method. This can be implemented using extractFullServiceName but sometimes we want both the full service name as well as the simple method name and implementing extractSimpleMethodName in terms of extractFullServiceName would mean searching for / at least twice through the full method name. This can be avoided if MethodDescriptor stored the full service name and the simple method name separately. Before I start working on a PR, I'd like to know if this is a change the team would be open to and, if so, any other information that might be helpful.

Thanks,
Noel

Noel Yap

unread,
Jan 17, 2017, 7:33:52 PM1/17/17
to grp...@googlegroups.com
An alternative implementation would be to have a method extractFullServiceNameAndSimpleMethodName that returns a pair of Strings (or a class with two String members) representing the full service name and simple method name.

Carl Mastrangelo

unread,
Jan 18, 2017, 1:16:31 PM1/18/17
to grpc.io, noel...@gmail.com
We keep them together because that is what is going to be sent to the server.  We don't have such a strong split between methods and services; services are a lightweight way of grouping methods together.

Can you describe what you would like to use the simple method name for?

Noel Yap

unread,
Jan 18, 2017, 2:41:55 PM1/18/17
to Carl Mastrangelo, grpc.io
We use it for naming properties (eg grpc.client.applicationName.ServiceName.interceptor.retry.methodName.maxRetries), being able to slice and dice metrics based on services and methods separately, and being able to use ServiceDescriptor.findMethodByName (if there were a way to go directly from io.grpc.MethodDescriptor to com.google.protobuf.Descriptors.MethodDescriptor, this use case would go away).

Thanks,
Noel
Reply all
Reply to author
Forward
0 new messages