From aecc8086ee731ff8420dcf59f05c31138709e48a Mon Sep 17 00:00:00 2001 From: Aaron Delaney Date: Mon, 26 Jun 2017 09:54:42 +0100 Subject: [PATCH] Export StartSpanFromContextWithTracer --- gocontext.go | 4 ++-- gocontext_test.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gocontext.go b/gocontext.go index 222a652..0b7b118 100644 --- a/gocontext.go +++ b/gocontext.go @@ -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())) diff --git a/gocontext_test.go b/gocontext_test.go index 65c0130..9fea560 100644 --- a/gocontext_test.go +++ b/gocontext_test.go @@ -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) } @@ -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) } @@ -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"]) @@ -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)