Instrumenting streaming calls
So far in the book, we have covered the instrumentation of synchronous calls where the application makes a request and awaits its completion. However, it’s common to use gRPC or other protocols, such as SignalR or WebSocket, to communicate in an asynchronous way when the client and server establish a connection and then send each other messages.
Common use cases for this kind of communication include chat applications, collaboration tools, and other cases when data should flow in real time and frequently in both directions.
The call starts when the client initiates a connection and may last until the client decides to disconnect, the connection becomes idle, or some network issue happens. In practice, it means that such calls may last for days.
While a connection is alive, the client and server can write each other messages to corresponding network streams. It’s much faster and more efficient when the client and server communicate...