Skip to content
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

Clear NoopTracer implementation and improve Tracer argument names #314

Merged
merged 5 commits into from
Nov 14, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
12 changes: 6 additions & 6 deletions api/trace/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ type Provider interface {

type Tracer interface {
// Start a span.
Start(context.Context, string, ...SpanOption) (context.Context, Span)
Start(ctx context.Context, spanName string, startOpts ...SpanOption) (context.Context, Span)

// WithSpan wraps the execution of the function body with a span.
// It starts a new span and sets it as an active span in the context.
// It then executes the body. It closes the span before returning the execution result.
// WithSpan wraps the execution of the fn function with a span.
// It starts a new span, sets it as an active span in the context,
// executes the fn function and closes the span before returning the result of fn.
WithSpan(
ctx context.Context,
operation string,
body func(ctx context.Context) error,
spanName string,
fn func(ctx context.Context) error,
) error
}

Expand Down
17 changes: 0 additions & 17 deletions api/trace/noop_trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,12 @@ package trace

import (
"context"

"go.opentelemetry.io/otel/api/core"
)

type NoopTracer struct{}

var _ Tracer = NoopTracer{}

// WithResources does nothing and returns noop implementation of Tracer.
func (t NoopTracer) WithResources(attributes ...core.KeyValue) Tracer {
return t
}

// WithComponent does nothing and returns noop implementation of Tracer.
func (t NoopTracer) WithComponent(name string) Tracer {
return t
}

// WithService does nothing and returns noop implementation of Tracer.
func (t NoopTracer) WithService(name string) Tracer {
return t
}

// WithSpan wraps around execution of func with noop span.
func (t NoopTracer) WithSpan(ctx context.Context, name string, body func(context.Context) error) error {
return body(ctx)
Expand Down