TUN-6575: Consume cf-trace-id from incoming http2 TCP requests

This commit is contained in:
Devin Carr 2022-08-11 14:54:12 -07:00
parent e123bbe1c5
commit a97673e8b9
4 changed files with 8 additions and 4 deletions

View File

@ -174,6 +174,7 @@ func (h *HTTPResponseReadWriteAcker) AckConnection(tracePropagation string) erro
Status: switchingProtocolText, Status: switchingProtocolText,
StatusCode: http.StatusSwitchingProtocols, StatusCode: http.StatusSwitchingProtocols,
ContentLength: -1, ContentLength: -1,
Header: http.Header{},
} }
if secWebsocketKey := h.req.Header.Get("Sec-WebSocket-Key"); secWebsocketKey != "" { if secWebsocketKey := h.req.Header.Get("Sec-WebSocket-Key"); secWebsocketKey != "" {

View File

@ -149,9 +149,10 @@ func (c *HTTP2Connection) ServeHTTP(w http.ResponseWriter, r *http.Request) {
rws := NewHTTPResponseReadWriterAcker(respWriter, r) rws := NewHTTPResponseReadWriterAcker(respWriter, r)
if err := originProxy.ProxyTCP(r.Context(), rws, &TCPRequest{ if err := originProxy.ProxyTCP(r.Context(), rws, &TCPRequest{
Dest: host, Dest: host,
CFRay: FindCfRayHeader(r), CFRay: FindCfRayHeader(r),
LBProbe: IsLBProbeRequest(r), LBProbe: IsLBProbeRequest(r),
CfTraceID: r.Header.Get(tracing.TracerContextName),
}); err != nil { }); err != nil {
respWriter.WriteErrorResponse() respWriter.WriteErrorResponse()
} }

View File

@ -256,7 +256,7 @@ func (p *Proxy) proxyStream(
connectionProxy ingress.StreamBasedOriginProxy, connectionProxy ingress.StreamBasedOriginProxy,
) error { ) error {
ctx := tr.Context ctx := tr.Context
_, connectSpan := tr.Tracer().Start(ctx, "stream_connect") _, connectSpan := tr.Tracer().Start(ctx, "stream-connect")
originConn, err := connectionProxy.EstablishConnection(ctx, dest) originConn, err := connectionProxy.EstablishConnection(ctx, dest)
if err != nil { if err != nil {
tracing.EndWithErrorStatus(connectSpan, err) tracing.EndWithErrorStatus(connectSpan, err)

View File

@ -525,6 +525,7 @@ func TestConnections(t *testing.T) {
}, },
want: want{ want: want{
message: []byte("echo-test2"), message: []byte("echo-test2"),
headers: http.Header{},
}, },
}, },
{ {
@ -544,6 +545,7 @@ func TestConnections(t *testing.T) {
message: []byte("echo-test3"), message: []byte("echo-test3"),
// We expect no headers here because they are sent back via // We expect no headers here because they are sent back via
// the stream. // the stream.
headers: http.Header{},
}, },
}, },
{ {