trace: call Body.Close to end the client HTTP span in OpenCensus
@@ -53,9 +53,12 @@ func main() {
req = req.WithContext(r.Context())
// The outgoing request will be traced with r's trace ID.
- if _, err := client.Do(req); err != nil {
+ resp, err := client.Do(req)
+ if err != nil {
log.Fatal(err)
}
+ // Because we don't read the resp.Body, need to manually call Close().
+ resp.Body.Close()
})
http.Handle("/foo", handler)
log.Fatal(http.ListenAndServe(":6060", &ochttp.Handler{}))
