mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2024-12-02 08:52:21 +02:00
Named Tracer: temporary remove unnecessary tracer methods (#158)
This commit is contained in:
parent
211007efb2
commit
cd5ee69468
@ -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 {
|
||||
|
@ -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 ^^^?
|
||||
|
||||
|
@ -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"
|
||||
@ -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.
|
||||
|
@ -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{}
|
||||
|
@ -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 {
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user