From b7c3df55a36b15aacb03ce2f3a807d21f49987ac Mon Sep 17 00:00:00 2001 From: jonny rhea Date: Tue, 13 Jan 2026 14:48:49 -0600 Subject: [PATCH] rpc: extract opentelemetry trace context from request headers --- rpc/http.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rpc/http.go b/rpc/http.go index a74f36a1b0..55f0abfa72 100644 --- a/rpc/http.go +++ b/rpc/http.go @@ -30,6 +30,9 @@ import ( "strconv" "sync" "time" + + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/propagation" ) const ( @@ -334,6 +337,9 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { ctx := r.Context() ctx = context.WithValue(ctx, peerInfoContextKey{}, connInfo) + // Extract trace context from incoming headers. + ctx = otel.GetTextMapPropagator().Extract(ctx, propagation.HeaderCarrier(r.Header)) + // All checks passed, create a codec that reads directly from the request body // until EOF, writes the response to w, and orders the server to process a // single request.