chore: avoid nested WithCodeResponseWriter (#3406)

This commit is contained in:
Kevin Wan
2023-07-11 23:59:43 +08:00
committed by GitHub
parent e8c1e6e09b
commit 13cdbdc98b
10 changed files with 81 additions and 39 deletions

View File

@@ -60,7 +60,7 @@ func TraceHandler(serviceName, path string, opts ...TraceOption) func(http.Handl
// convenient for tracking error messages
propagator.Inject(spanCtx, propagation.HeaderCarrier(w.Header()))
trw := &response.WithCodeResponseWriter{Writer: w, Code: http.StatusOK}
trw := response.NewWithCodeResponseWriter(w)
next.ServeHTTP(trw, r.WithContext(spanCtx))
span.SetAttributes(semconv.HTTPAttributesFromHTTPStatusCode(trw.Code)...)