From cbff64220b6d57003172dad3b65086b9d9ce0918 Mon Sep 17 00:00:00 2001 From: Alexander Yastrebov Date: Wed, 29 Sep 2021 21:28:43 +0200 Subject: [PATCH] Fixes stream headers end tracing event (#1867) Signed-off-by: Alexander Yastrebov --- proxy/proxy.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index 651cd24199..e4cb67c68d 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -1193,7 +1193,6 @@ func (p *Proxy) serveResponse(ctx *context) { start := time.Now() p.tracing.logStreamEvent(ctx.proxySpan, StreamHeadersEvent, StartEvent) copyHeader(ctx.responseWriter.Header(), ctx.response.Header) - p.tracing.logStreamEvent(ctx.proxySpan, StreamHeadersEvent, EndEvent) if err := ctx.Request().Context().Err(); err != nil { // deadline exceeded or canceled in stdlib, client closed request @@ -1207,6 +1206,8 @@ func (p *Proxy) serveResponse(ctx *context) { ctx.responseWriter.WriteHeader(ctx.response.StatusCode) ctx.responseWriter.Flush() + p.tracing.logStreamEvent(ctx.proxySpan, StreamHeadersEvent, EndEvent) + n, err := copyStream(ctx.responseWriter, ctx.response.Body) p.tracing.logStreamEvent(ctx.proxySpan, StreamBodyEvent, strconv.FormatInt(n, 10)) if err != nil {