Package list golang-github-go-kit-kit / c718700
tracing/opentracing: fix latest API breakage Closes #338 Peter Bourgon 5 years ago
3 changed file(s) with 12 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
3232 if want, have := "testOp", endpointSpan.OperationName; want != have {
3333 t.Fatalf("Want %q, have %q", want, have)
3434 }
35 contextContext := contextSpan.Context().(*mocktracer.MockSpanContext)
36 endpointContext := endpointSpan.Context().(*mocktracer.MockSpanContext)
35 contextContext := contextSpan.Context().(mocktracer.MockSpanContext)
36 endpointContext := endpointSpan.Context().(mocktracer.MockSpanContext)
3737 // ...and that the ID is unmodified.
3838 if want, have := contextContext.SpanID, endpointContext.SpanID; want != have {
3939 t.Errorf("Want SpanID %q, have %q", want, have)
8585 t.Fatalf("Want %q, have %q", want, have)
8686 }
8787
88 parentContext := parentSpan.Context().(*mocktracer.MockSpanContext)
89 endpointContext := parentSpan.Context().(*mocktracer.MockSpanContext)
88 parentContext := parentSpan.Context().(mocktracer.MockSpanContext)
89 endpointContext := parentSpan.Context().(mocktracer.MockSpanContext)
9090
9191 // ... and that the parent ID is set appropriately.
9292 if want, have := parentContext.SpanID, endpointContext.SpanID; want != have {
1818 // Initialize the ctx with a Span to inject.
1919 beforeSpan := tracer.StartSpan("to_inject").(*mocktracer.MockSpan)
2020 defer beforeSpan.Finish()
21 beforeSpan.Context().SetBaggageItem("baggage", "check")
21 beforeSpan.SetBaggageItem("baggage", "check")
2222 beforeCtx := opentracing.ContextWithSpan(context.Background(), beforeSpan)
2323
2424 toGRPCFunc := kitot.ToGRPCRequest(tracer, logger)
4343 joinCtx := fromGRPCFunc(afterCtx, &md)
4444 joinedSpan := opentracing.SpanFromContext(joinCtx).(*mocktracer.MockSpan)
4545
46 joinedContext := joinedSpan.Context().(*mocktracer.MockSpanContext)
47 beforeContext := beforeSpan.Context().(*mocktracer.MockSpanContext)
46 joinedContext := joinedSpan.Context().(mocktracer.MockSpanContext)
47 beforeContext := beforeSpan.Context().(mocktracer.MockSpanContext)
4848
4949 if joinedContext.SpanID == beforeContext.SpanID {
5050 t.Error("SpanID should have changed", joinedContext.SpanID, beforeContext.SpanID)
5757 if want, have := "joined", joinedSpan.OperationName; want != have {
5858 t.Errorf("Want %q, have %q", want, have)
5959 }
60 if want, have := "check", joinedSpan.Context().BaggageItem("baggage"); want != have {
60 if want, have := "check", joinedSpan.BaggageItem("baggage"); want != have {
6161 t.Errorf("Want %q, have %q", want, have)
6262 }
6363 }
1818 // Initialize the ctx with a Span to inject.
1919 beforeSpan := tracer.StartSpan("to_inject").(*mocktracer.MockSpan)
2020 defer beforeSpan.Finish()
21 beforeSpan.Context().SetBaggageItem("baggage", "check")
21 beforeSpan.SetBaggageItem("baggage", "check")
2222 beforeCtx := opentracing.ContextWithSpan(context.Background(), beforeSpan)
2323
2424 toHTTPFunc := kitot.ToHTTPRequest(tracer, logger)
4343 joinCtx := fromHTTPFunc(afterCtx, req)
4444 joinedSpan := opentracing.SpanFromContext(joinCtx).(*mocktracer.MockSpan)
4545
46 joinedContext := joinedSpan.Context().(*mocktracer.MockSpanContext)
47 beforeContext := beforeSpan.Context().(*mocktracer.MockSpanContext)
46 joinedContext := joinedSpan.Context().(mocktracer.MockSpanContext)
47 beforeContext := beforeSpan.Context().(mocktracer.MockSpanContext)
4848
4949 if joinedContext.SpanID == beforeContext.SpanID {
5050 t.Error("SpanID should have changed", joinedContext.SpanID, beforeContext.SpanID)
5757 if want, have := "joined", joinedSpan.OperationName; want != have {
5858 t.Errorf("Want %q, have %q", want, have)
5959 }
60 if want, have := "check", joinedSpan.Context().BaggageItem("baggage"); want != have {
60 if want, have := "check", joinedSpan.BaggageItem("baggage"); want != have {
6161 t.Errorf("Want %q, have %q", want, have)
6262 }
6363 }