I'm trying to access the method name service/Method
from within the a gRPC handler. I can't seem to find this data on the grpc.ServicerContext
object (and I'm pretty sure it isn't there). My next thought was to use an interceptor since the method name is provided via the grpc.HandlerCallDetails
. The issue is that there isn't any obvious way to forward this to the underlying handler.
Unfortunately, grpc.HandlerCallDetails
doesn't have a constructor, so we can't take the method name and shove it in the metadata for it to be read in the handler. We'd have to create a named tuple that's the same interface as grpc.HandlerCallDetails
and add a new metadata value to it.
It would be great if anyone has run into this and has a solution or if someone on the grpc team has a workaround.
Additionally, this should probably be something that's a bit easier as there is prior art for this kind of feature. grpc-go
has the Method
name to help with this https://pkg.go.dev/google.golang.org/grpc?tab=doc#Method. It seems like in c++ you could potentially pull this out of the census context.