rpc: extract opentelemetry trace context from request headers

This commit is contained in:
jonny rhea 2026-01-13 14:48:49 -06:00 committed by lightclient
parent a9acb3ff93
commit b7c3df55a3
No known key found for this signature in database
GPG key ID: 657913021EF45A6A

View file

@ -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.