Assuming it is not a client streaming call. Your implementation looks fine, 
except the error/onCancel handling. Also do remember to call 
delegate().onMessage and delegate().onComplete at the end of each method. 
It is thread-safe.

On Tuesday, January 9, 2018 at 7:16:36 PM UTC-8, Joe Qiao wrote:
>
> Hi,
>
> I want to implement a server interceptor to collect how much time used in 
> server side from message received to process complete. 
> so i write a server interceptor which return a 
> SimpleForwardingServerCallListener which have a long field. then i record 
> the start time in the onMessage method, set it to the long field and 
> calculate the total time used in onComplete by using this field value.
> it's basically like this:
>
> return new SimpleForwardingServerCallListener(...){
>       private long start;
>
>      public void onMesage(...){
>        start = System.currentTimeMillis();
>        .....
>     }
>
>
>     public void onComplete(...){
>        log.info("time used:", System.currentTimeMillis() - start);
>        .....
>    }
>
> }
>
> is this implementation correct? is there any thread-safe issue here? 
> Thanks!
>

-- 
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/bdd23fb2-6abc-48a5-a830-bc1a1d91c7fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to