Skip to content

Commit a97673e

Browse files
committed
TUN-6575: Consume cf-trace-id from incoming http2 TCP requests
1 parent e123bbe commit a97673e

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

connection/connection.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ func (h *HTTPResponseReadWriteAcker) AckConnection(tracePropagation string) erro
174174
Status: switchingProtocolText,
175175
StatusCode: http.StatusSwitchingProtocols,
176176
ContentLength: -1,
177+
Header: http.Header{},
177178
}
178179

179180
if secWebsocketKey := h.req.Header.Get("Sec-WebSocket-Key"); secWebsocketKey != "" {

connection/http2.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,10 @@ func (c *HTTP2Connection) ServeHTTP(w http.ResponseWriter, r *http.Request) {
149149

150150
rws := NewHTTPResponseReadWriterAcker(respWriter, r)
151151
if err := originProxy.ProxyTCP(r.Context(), rws, &TCPRequest{
152-
Dest: host,
153-
CFRay: FindCfRayHeader(r),
154-
LBProbe: IsLBProbeRequest(r),
152+
Dest: host,
153+
CFRay: FindCfRayHeader(r),
154+
LBProbe: IsLBProbeRequest(r),
155+
CfTraceID: r.Header.Get(tracing.TracerContextName),
155156
}); err != nil {
156157
respWriter.WriteErrorResponse()
157158
}

proxy/proxy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ func (p *Proxy) proxyStream(
256256
connectionProxy ingress.StreamBasedOriginProxy,
257257
) error {
258258
ctx := tr.Context
259-
_, connectSpan := tr.Tracer().Start(ctx, "stream_connect")
259+
_, connectSpan := tr.Tracer().Start(ctx, "stream-connect")
260260
originConn, err := connectionProxy.EstablishConnection(ctx, dest)
261261
if err != nil {
262262
tracing.EndWithErrorStatus(connectSpan, err)

proxy/proxy_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ func TestConnections(t *testing.T) {
525525
},
526526
want: want{
527527
message: []byte("echo-test2"),
528+
headers: http.Header{},
528529
},
529530
},
530531
{
@@ -544,6 +545,7 @@ func TestConnections(t *testing.T) {
544545
message: []byte("echo-test3"),
545546
// We expect no headers here because they are sent back via
546547
// the stream.
548+
headers: http.Header{},
547549
},
548550
},
549551
{

0 commit comments

Comments
 (0)