Repository navigation
refactor(tracer): start the root span with OpenTelemetry #858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d11de3d
1e077aa
682023d
13f9bbd
d774ebb
1a899cb
588e1f7
90fee30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -168,15 +168,19 @@ func Test_Start(t *testing.T) { | |
| require.Len(t, spans, 3) | ||
| assert.Equal(t, spans["opentracing-parent"].SpanContext().SpanID(), spans["otel-child"].Parent().SpanID()) | ||
| assert.Equal(t, spans["otel-child"].SpanContext().SpanID(), spans["opentracing-grandchild"].Parent().SpanID()) | ||
| } | ||
|
|
||
| func Test_TraceID(t *testing.T) { | ||
| recorder := tracetest.NewSpanRecorder() | ||
| tracer := newBridgeTracer(sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(recorder))) | ||
| span := tracer.StartSpan("span") | ||
| traceID := TraceID(span) | ||
| span.Finish() | ||
| assert.Len(t, traceID, 32) | ||
| assert.Equal(t, recorder.Ended()[0].SpanContext().TraceID().String(), traceID) | ||
| assert.Empty(t, TraceID(opentracing.NoopTracer{}.StartSpan("noop"))) | ||
| recorder = tracetest.NewSpanRecorder() | ||
| tracer = newBridgeTracer(sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(recorder))) | ||
| opentracing.SetGlobalTracer(tracer) | ||
| ctx, root := Start(context.Background(), "otel-root") | ||
| child2, _ := opentracing.StartSpanFromContext(ctx, "opentracing-child") | ||
| child2.Finish() | ||
| root.End() | ||
| spans = map[string]sdktrace.ReadOnlySpan{} | ||
| for _, span := range recorder.Ended() { | ||
| spans[span.Name()] = span | ||
| } | ||
| require.Len(t, spans, 2) | ||
| assert.False(t, spans["otel-root"].Parent().IsValid()) | ||
| assert.Equal(t, spans["otel-root"].SpanContext().SpanID(), spans["opentracing-child"].Parent().SpanID()) | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧪 suggestion (non-blocking):
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in commit d774ebb, great catch! |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 praise: Checking that an OpenTracing child of a parentless OpenTelemetry root still nests under it covers the riskiest part of this switch.