fix: set request ID in tracing context key (#17602)

Since `addCustomerHeaders` middleware was after the `httpTracer`
middleware, the request ID was not set in the http tracing context. By
reordering these middleware functions, the request ID header becomes
available. We also avoid setting the tracing context key again in
`newContext`.

Bonus: All middleware functions are renamed with a "Middleware" suffix
to avoid confusion with http Handler functions.
This commit is contained in:
Aditya Manthramurthy
2023-07-08 07:31:42 -07:00
committed by GitHub
parent 45a717a142
commit 7af78af1f0
9 changed files with 43 additions and 49 deletions

View File

@@ -65,7 +65,7 @@ func getOpName(name string) (op string) {
// If trace is enabled, execute the request if it is traced by other handlers
// otherwise, generate a trace event with request information but no response.
func httpTracer(h http.Handler) http.Handler {
func httpTracerMiddleware(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Setup a http request response recorder - this is needed for
// http stats requests and audit if enabled.