TraceContext unpacks the request context looking for an existing trace id.
(next http.Handler)
| 13 | |
| 14 | // TraceContext unpacks the request context looking for an existing trace id. |
| 15 | func TraceContext(next http.Handler) http.Handler { |
| 16 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 17 | ctx := propagator.Extract(r.Context(), propagation.HeaderCarrier(r.Header)) |
| 18 | propagator.Inject(ctx, propagation.HeaderCarrier(r.Header)) |
| 19 | next.ServeHTTP(w, r.WithContext(ctx)) |
| 20 | }) |
| 21 | } |