C# grpc context

48 views
Skip to first unread message

Benjamin Krämer

unread,
Feb 27, 2018, 8:32:13 AM2/27/18
to grpc.io
In Java, there is a io.grpc.Context class which let's you store key-value-pairs inside a thread. Is there anything similar in C#? It would be nice to be able to get data into ServerCallContext, like the active OpenTracing span for the current server handle to the client call. For the moment, I am using an AsyncLocal instance but have to give each service implementation a reference to this.

Jan Tattermusch

unread,
Feb 28, 2018, 3:05:51 AM2/28/18
to Benjamin Krämer, grpc.io
Currently we don't have anything like explicitly setup in C#, but as you pointed out, .NET framework already provides some classes for contextual data (such as AsyncLocal). 
One thing you can try: In v1.10.x we are introducing interceptor API, and with that API you should be able to install async context for each of your server-side handlers before they actually run.
You should be aware that there might be some performace penalty associated with using contexts, so please doublecheck the performance (if performance is of interest for you).

On Tue, Feb 27, 2018 at 2:32 PM, Benjamin Krämer <falco...@gmail.com> wrote:
In Java, there is a io.grpc.Context class which let's you store key-value-pairs inside a thread. Is there anything similar in C#? It would be nice to be able to get data into ServerCallContext, like the active OpenTracing span for the current server handle to the client call. For the moment, I am using an AsyncLocal instance but have to give each service implementation a reference to this.

--
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 grpc-io+unsubscribe@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
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/c4e74716-fa71-4b38-8088-60f68c220aef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Jan

Reply all
Reply to author
Forward
0 new messages