(t *testing.T)
| 79 | } |
| 80 | |
| 81 | func TestExplicitReferences(t *testing.T) { |
| 82 | tracer := NewTracer("blobstore") |
| 83 | defer tracer.Close() |
| 84 | |
| 85 | parentSpan := tracer.StartSpan("parent").(*spanImpl) |
| 86 | defer parentSpan.Finish() |
| 87 | |
| 88 | span1 := tracer.StartSpan("child", ChildOf(parentSpan.Context())).(*spanImpl) |
| 89 | defer span1.Finish() |
| 90 | |
| 91 | require.Equal(t, 1, len(span1.references)) |
| 92 | require.Equal(t, parentSpan.context.traceID, span1.context.traceID) |
| 93 | require.Equal(t, parentSpan.context.spanID, span1.context.parentID) |
| 94 | |
| 95 | ctx := ContextWithSpan(context.Background(), span1) |
| 96 | span2 := SpanFromContext(ctx).(*spanImpl) |
| 97 | |
| 98 | span3, _ := StartSpanFromContext(ctx, "child of span") |
| 99 | cs := span3.(*spanImpl) |
| 100 | |
| 101 | require.Equal(t, span1, span2) |
| 102 | require.Equal(t, 1, len(cs.references)) |
| 103 | require.Equal(t, span1.context.traceID, cs.context.traceID) |
| 104 | require.Equal(t, span1.context.spanID, cs.context.parentID) |
| 105 | |
| 106 | newParentSpan := tracer.StartSpan("newParentSpan") |
| 107 | span4 := tracer.StartSpan("nChild", FollowsFrom(span3.Context()), |
| 108 | FollowsFrom(newParentSpan.Context())).(*spanImpl) |
| 109 | |
| 110 | require.Equal(t, 2, len(span4.references)) |
| 111 | |
| 112 | span5 := tracer.StartSpan("empty span context", ChildOf(&SpanContext{})).(*spanImpl) |
| 113 | require.Equal(t, 0, len(span5.references)) |
| 114 | } |
| 115 | |
| 116 | func TestStartSpanFromContext(t *testing.T) { |
| 117 | span, ctx := StartSpanFromContext(context.Background(), "span1") |
nothing calls this directly
no test coverage detected