Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
Export StartSpanFromContextWithTracer
Browse files Browse the repository at this point in the history
  • Loading branch information
devoxel committed Jun 26, 2017
1 parent eaaf4e1 commit aecc808
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions gocontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ func SpanFromContext(ctx context.Context) Span {
// ...
// }
func StartSpanFromContext(ctx context.Context, operationName string, opts ...StartSpanOption) (Span, context.Context) {
return startSpanFromContextWithTracer(ctx, GlobalTracer(), operationName, opts...)
return StartSpanFromContextWithTracer(ctx, GlobalTracer(), operationName, opts...)
}

// startSpanFromContextWithTracer is factored out for testing purposes.
func startSpanFromContextWithTracer(ctx context.Context, tracer Tracer, operationName string, opts ...StartSpanOption) (Span, context.Context) {
func StartSpanFromContextWithTracer(ctx context.Context, tracer Tracer, operationName string, opts ...StartSpanOption) (Span, context.Context) {
var span Span
if parentSpan := SpanFromContext(ctx); parentSpan != nil {
opts = append(opts, ChildOf(parentSpan.Context()))
Expand Down
8 changes: 4 additions & 4 deletions gocontext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestStartSpanFromContext(t *testing.T) {
{
parentSpan := &testSpan{}
parentCtx := ContextWithSpan(context.Background(), parentSpan)
childSpan, childCtx := startSpanFromContextWithTracer(parentCtx, testTracer, "child")
childSpan, childCtx := StartSpanFromContextWithTracer(parentCtx, testTracer, "child")
if !childSpan.Context().(testSpanContext).HasParent {
t.Errorf("Failed to find parent: %v", childSpan)
}
Expand All @@ -48,7 +48,7 @@ func TestStartSpanFromContext(t *testing.T) {
// Test the case where there *is not* a Span in the Context.
{
emptyCtx := context.Background()
childSpan, childCtx := startSpanFromContextWithTracer(emptyCtx, testTracer, "child")
childSpan, childCtx := StartSpanFromContextWithTracer(emptyCtx, testTracer, "child")
if childSpan.Context().(testSpanContext).HasParent {
t.Errorf("Should not have found parent: %v", childSpan)
}
Expand All @@ -64,7 +64,7 @@ func TestStartSpanFromContextOptions(t *testing.T) {
// Test options are passed to tracer

startTime := time.Now().Add(-10 * time.Second) // ten seconds ago
span, ctx := startSpanFromContextWithTracer(
span, ctx := StartSpanFromContextWithTracer(
context.Background(), testTracer, "parent", StartTime(startTime), Tag{"component", "test"})

assert.Equal(t, "test", span.(testSpan).Tags["component"])
Expand All @@ -73,7 +73,7 @@ func TestStartSpanFromContextOptions(t *testing.T) {
// Test it also works for a child span

childStartTime := startTime.Add(3 * time.Second)
childSpan, _ := startSpanFromContextWithTracer(
childSpan, _ := StartSpanFromContextWithTracer(
ctx, testTracer, "child", StartTime(childStartTime))

assert.Equal(t, childSpan.(testSpan).Tags["component"], nil)
Expand Down

0 comments on commit aecc808

Please sign in to comment.