Hi, I am still not sure what your endgoal is. My understanding is that you have some kind of unique id (correlationId, not sure what correlation means here) and you want to attach it your calls, because that information is important for your logs. I can only guess that you might want to pass that Id along with your call graph (a call starts with some id and the server handling that rpc initiates new rpc, assigning them the same id) - i.e. you might want to come up with some very basic version of tracing. Also, I assume the correlation will be different each time a new end-user call is started.
Assuming tracing is the functionality you want, please be aware that gRPC team is working on fully-fledged tracing/stats support for gRPC that will be available in all languages (and will work cross-language) and will be based on a proven design. Tracing support should be available sometime within first half of 2017, so you might be better off just waiting for the real tracing functionality to be available instead of trying to hack it together yourself. Unfortunately, not much info about the tracing support is available publicly yet (for the time being, you can think of Census the same way you can about Zipkin or Opentracing).
If you need a short term solution for tracing purposes, just try adding a metadata entry that carries the "correlationId":
var request = YOUR_PROTOBUF_REQUEST
var requestHeaders = new Metadata
{
{ "tracingId", "UNIQUE_IDENTIFIER_74631984..." }
};
var call = client.FooCall(request, requestHeaders);
on the server side, you will be able to access the "tracingId" metadata entry through serverCallContext.RequestHeaders.
The advantage of using metadata API instead of adding an extra field to your protobuf definitions is that the tracingId doesn't pollute your service schema. Also, this makes more sense semantically as tracing functionality should be orthogonal to the contents of your requests and responses.
To some degree, you could automate instrumentation of new calls on the client side by adding a custom CallInvoker (and that way whenever you start a new call on a channel that uses that callInvoker, the custom callInvoker could add the tracingId to the logs for you).
Another response is inline