mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 20:56:42 +00:00
rpc: extract opentelemetry trace context from request headers
This commit is contained in:
parent
a9acb3ff93
commit
b7c3df55a3
1 changed files with 6 additions and 0 deletions
|
|
@ -30,6 +30,9 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"go.opentelemetry.io/otel"
|
||||||
|
"go.opentelemetry.io/otel/propagation"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -334,6 +337,9 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
ctx = context.WithValue(ctx, peerInfoContextKey{}, connInfo)
|
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
|
// 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
|
// until EOF, writes the response to w, and orders the server to process a
|
||||||
// single request.
|
// single request.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue