You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-11-25 22:41:46 +02:00
Add Keys() method to propagation.TextMapCarrier (#1544)
...and propagation.HeaderCarrier to adapt http.Header to this interface. Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
@@ -112,7 +112,7 @@ func TestExtractValidTraceContextFromHTTPReq(t *testing.T) {
|
||||
req.Header.Set("traceparent", tt.header)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx = prop.Extract(ctx, req.Header)
|
||||
ctx = prop.Extract(ctx, propagation.HeaderCarrier(req.Header))
|
||||
gotSc := trace.RemoteSpanContextFromContext(ctx)
|
||||
if diff := cmp.Diff(gotSc, tt.wantSc, cmp.AllowUnexported(trace.TraceState{})); diff != "" {
|
||||
t.Errorf("Extract Tracecontext: %s: -got +want %s", tt.name, diff)
|
||||
@@ -200,7 +200,7 @@ func TestExtractInvalidTraceContextFromHTTPReq(t *testing.T) {
|
||||
req.Header.Set("traceparent", tt.header)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx = prop.Extract(ctx, req.Header)
|
||||
ctx = prop.Extract(ctx, propagation.HeaderCarrier(req.Header))
|
||||
gotSc := trace.RemoteSpanContextFromContext(ctx)
|
||||
if diff := cmp.Diff(gotSc, wantSc, cmp.AllowUnexported(trace.TraceState{})); diff != "" {
|
||||
t.Errorf("Extract Tracecontext: %s: -got +want %s", tt.name, diff)
|
||||
@@ -257,7 +257,7 @@ func TestInjectTraceContextToHTTPReq(t *testing.T) {
|
||||
ctx = trace.ContextWithRemoteSpanContext(ctx, tt.sc)
|
||||
ctx, _ = mockTracer.Start(ctx, "inject")
|
||||
}
|
||||
prop.Inject(ctx, req.Header)
|
||||
prop.Inject(ctx, propagation.HeaderCarrier(req.Header))
|
||||
|
||||
gotHeader := req.Header.Get("traceparent")
|
||||
if diff := cmp.Diff(gotHeader, tt.wantHeader); diff != "" {
|
||||
@@ -337,7 +337,7 @@ func TestTraceStatePropagation(t *testing.T) {
|
||||
inReq.Header.Add(hk, hv)
|
||||
}
|
||||
|
||||
ctx := prop.Extract(context.Background(), inReq.Header)
|
||||
ctx := prop.Extract(context.Background(), propagation.HeaderCarrier(inReq.Header))
|
||||
if diff := cmp.Diff(
|
||||
trace.RemoteSpanContextFromContext(ctx),
|
||||
tt.wantSc,
|
||||
@@ -351,7 +351,7 @@ func TestTraceStatePropagation(t *testing.T) {
|
||||
mockTracer := oteltest.DefaultTracer()
|
||||
ctx, _ = mockTracer.Start(ctx, "inject")
|
||||
outReq, _ := http.NewRequest(http.MethodGet, "http://www.example.com", nil)
|
||||
prop.Inject(ctx, outReq.Header)
|
||||
prop.Inject(ctx, propagation.HeaderCarrier(outReq.Header))
|
||||
|
||||
if diff := cmp.Diff(outReq.Header.Get(stateHeader), tt.headers[stateHeader]); diff != "" {
|
||||
t.Errorf("Propagated tracestate: -got +want %s", diff)
|
||||
|
||||
Reference in New Issue
Block a user