Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions internal/slackcontext/slackcontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,6 @@ func SetOpenTracingTraceID(ctx context.Context, traceID string) context.Context
return ctx
}

// OpenTracingTracer returns the `opentracing.Tracer` associated with `ctx`, or
// `nil` and `slackerror.ErrContextValueNotFound` if no `Tracer` could be found.
func OpenTracingTracer(ctx context.Context) (opentracing.Tracer, error) {
Comment on lines -75 to -77

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🪓 praise: Tracing tracers traced tracers tracing!

var tracer, ok = ctx.Value(contextKeyOpenTracingTracer).(opentracing.Tracer)
if !ok || tracer == nil {
return nil, slackerror.New(slackerror.ErrContextValueNotFound).
WithMessage("The value for OpenTracing Tracer could not be found")
}
return tracer, nil
}

// SetOpenTracingSpan returns a new `context.Context` that holds a reference to
// the `opentracing.Tracer`. If tracer is nil, a new context without a tracer returned.
func SetOpenTracingTracer(ctx context.Context, tracer opentracing.Tracer) context.Context {
Expand Down
27 changes: 0 additions & 27 deletions internal/slackcontext/slackcontext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,33 +87,6 @@ func Test_SlackContext_SetOpenTracingTraceID(t *testing.T) {
}
}

func Test_SlackContext_OpenTracingTracer(t *testing.T) {
_, _tracer := tracer.SetupTracer(true)

tests := map[string]struct {
expectedTracer opentracing.Tracer
expectedError error
}{
"returns Tracer when it exists": {
expectedTracer: _tracer,
expectedError: nil,
},
"returns error when Tracer not found": {
expectedTracer: nil,
expectedError: slackerror.New(slackerror.ErrContextValueNotFound).WithMessage("The value for OpenTracing Tracer could not be found"),
},
}
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
ctx := t.Context()
ctx = context.WithValue(ctx, contextKeyOpenTracingTracer, tc.expectedTracer)
actualTracer, actualError := OpenTracingTracer(ctx)
require.Equal(t, tc.expectedTracer, actualTracer)
require.Equal(t, tc.expectedError, actualError)
})
}
}

func Test_SlackContext_SetOpenTracingTracer(t *testing.T) {
_, _tracer := tracer.SetupTracer(true)

Expand Down
Loading