census-instrumentation / opencensus-specs

Apache License 2.0
188 stars 50 forks source link

Define standard annotations for HTTP #116

Open Sebruck opened 6 years ago

Sebruck commented 6 years ago

When a server answers with an HttpResponse there are two relevant events.

  1. The server generated the response and sent it to the client
  2. The body is fully transferred to the client

While 2. is indicated by the span end, 1. should be an annotation.

I think we should have a standard name for this annotation, something like response sent (server side) and response received (client side) comes into my mind.

WDYT? Any opinions?

semistrict commented 6 years ago

Interesting idea. I assume you mean annotations on the client-side span (since the server-side span would not known when the response had been received).

Why is the server-side span not sufficient for this? It should give you this information and be contained within the client-side span.

The only reason I could think for not having the server-side span is if the server is controlled by someone else. In this case, how would you know when the server had sent a response (seems to require cooperation from the server)?

Sebruck commented 6 years ago

I think this also applies for the server side span.

In the end a timeline of a http request looks like this:

|--------------------------------------------------------------------------------------------------------------------------------------------------->|
conn        request header      request entity                  response header                response body                    connection closed       
open        received            fully received                  sent                           fully sent
                                                                                           (could be chunked / SSE)

For the client side it looks similar, just the received and sent key words flip.

In frameworks like akka-http or http4s it is easy to determine when these events happen since the Http Message (request or response) and their entity are separate asynchronous operations (Futures/Streams)

I think it would be nice to have for those events standardised annotations.