Skip to content

Commit

Permalink
Named Tracer: temporary remove unnecessary tracer methods (open-telem…
Browse files Browse the repository at this point in the history
  • Loading branch information
agneum authored and rghetia committed Oct 3, 2019
1 parent 211007e commit cd5ee69
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 61 deletions.
8 changes: 0 additions & 8 deletions api/trace/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ type Tracer interface {
operation string,
body func(ctx context.Context) error,
) error

// TODO: Do we need WithService and WithComponent?
// TODO: Can we make these helpers (based on WithResources)?
WithService(name string) Tracer
WithComponent(name string) Tracer

// WithResources attaches resource attributes to the Tracer.
WithResources(res ...core.KeyValue) Tracer
}

type EndOptions struct {
Expand Down
6 changes: 1 addition & 5 deletions example/basic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ import (
)

var (
tracer = trace.GlobalTracer().
WithComponent("example").
WithResources(
key.New("whatevs").String("yesss"),
)
tracer = trace.GlobalTracer()

meter = metric.GlobalMeter() // TODO: should share resources ^^^?

Expand Down
19 changes: 0 additions & 19 deletions experimental/bridge/opentracing/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package opentracing
import (
"context"

otelcore "go.opentelemetry.io/api/core"
oteltrace "go.opentelemetry.io/api/trace"

migration "go.opentelemetry.io/experimental/bridge/opentracing/migration"
Expand Down Expand Up @@ -53,24 +52,6 @@ func (t *WrapperTracer) otelTracer() oteltrace.Tracer {
return t.tracer
}

// WithResources forwards the call to the wrapped tracer.
func (t *WrapperTracer) WithResources(attributes ...otelcore.KeyValue) oteltrace.Tracer {
t.otelTracer().WithResources(attributes...)
return t
}

// WithComponent forwards the call to the wrapped tracer.
func (t *WrapperTracer) WithComponent(name string) oteltrace.Tracer {
t.otelTracer().WithComponent(name)
return t
}

// WithService forwards the call to the wrapped tracer.
func (t *WrapperTracer) WithService(name string) oteltrace.Tracer {
t.otelTracer().WithService(name)
return t
}

// WithSpan forwards the call to the wrapped tracer with a modified
// body callback, which sets the active OpenTracing span before
// calling the original callback.
Expand Down
6 changes: 1 addition & 5 deletions experimental/streaming/example/basic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ import (
)

var (
streaming = sdk.New(spanlog.New()).
WithComponent("example").
WithResources(
key.New("whatevs").String("yesss"),
)
streaming = sdk.New(spanlog.New())

tracer trace.Tracer = streaming
meter metric.Meter = metric.NoopMeter{}
Expand Down
28 changes: 4 additions & 24 deletions experimental/streaming/sdk/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ type tracer struct {

var (
// TODO These should move somewhere in the api, right?
ServiceKey = key.New("service")
ComponentKey = key.New("component")
ErrorKey = key.New("error")
SpanIDKey = key.New("span_id")
TraceIDKey = key.New("trace_id")
MessageKey = key.New("message")
ErrorKey = key.New("error")
SpanIDKey = key.New("span_id")
TraceIDKey = key.New("trace_id")
MessageKey = key.New("message")
)

func New(observers ...exporter.Observer) trace.Tracer {
Expand All @@ -45,24 +43,6 @@ func New(observers ...exporter.Observer) trace.Tracer {
}
}

func (t *tracer) WithResources(attributes ...core.KeyValue) trace.Tracer {
s := t.exporter.NewScope(exporter.ScopeID{
EventID: t.resources,
}, attributes...)
return &tracer{
exporter: t.exporter,
resources: s.EventID,
}
}

func (t *tracer) WithComponent(name string) trace.Tracer {
return t.WithResources(ComponentKey.String(name))
}

func (t *tracer) WithService(name string) trace.Tracer {
return t.WithResources(ServiceKey.String(name))
}

func (t *tracer) WithSpan(ctx context.Context, name string, body func(context.Context) error) error {
// TODO: use runtime/trace.WithRegion for execution tracer support
// TODO: use runtime/pprof.Do for profile tags support
Expand Down

0 comments on commit cd5ee69

Please sign in to comment.