I've done this using grpc-java. The theory should be similar for C#. You need to use a custom header to propagate your correlation id over the wire. You will also need a place to store the correlation id between processing a service call and calling the next service in the chain, such as a thread local variable.
On the client side use an InterceptingCallInvoker to marshal the thread local correlation id into a header. On the server side, use a InterceptingCallInvoker to marshal the header into the thread local variable. Using this pattern you can chain multiple service calls while transparently preserving a single correlation id across the entire chain. This is called the Ambient Context pattern. A three service chain would look something like this: Thread local -> Header -> Thread local -> Header -> Thread Local If you are using asynchronous APIs you will have to do extra work to make sure your thread local context survives the thread hopping that happens with async/await. On Tuesday, February 21, 2017 at 2:22:38 AM UTC-8, [email protected] wrote: > > > I have many microservices en .net communicating with each other via gRPC > (I use "protoc.exe" and "grpc_csharp_plugin.exe" to generate the client and > server parts). > Now I need that the gRPC request keeps the same correlationId passing > through different microservices. > > Please advise if I can add my own gRPC plugin that handle this > automatically? > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/grpc-io. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/82238ec1-2404-49c0-b78a-dc1faeba973e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
