You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-11-23 22:34:47 +02:00
Named Tracer: temporary remove unnecessary tracer methods (#158)
This commit is contained in:
@@ -36,14 +36,6 @@ type Tracer interface {
|
|||||||
operation string,
|
operation string,
|
||||||
body func(ctx context.Context) error,
|
body func(ctx context.Context) error,
|
||||||
) 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 {
|
type EndOptions struct {
|
||||||
|
|||||||
@@ -25,11 +25,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
tracer = trace.GlobalTracer().
|
tracer = trace.GlobalTracer()
|
||||||
WithComponent("example").
|
|
||||||
WithResources(
|
|
||||||
key.New("whatevs").String("yesss"),
|
|
||||||
)
|
|
||||||
|
|
||||||
meter = metric.GlobalMeter() // TODO: should share resources ^^^?
|
meter = metric.GlobalMeter() // TODO: should share resources ^^^?
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ package opentracing
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
otelcore "go.opentelemetry.io/api/core"
|
|
||||||
oteltrace "go.opentelemetry.io/api/trace"
|
oteltrace "go.opentelemetry.io/api/trace"
|
||||||
|
|
||||||
migration "go.opentelemetry.io/experimental/bridge/opentracing/migration"
|
migration "go.opentelemetry.io/experimental/bridge/opentracing/migration"
|
||||||
@@ -53,24 +52,6 @@ func (t *WrapperTracer) otelTracer() oteltrace.Tracer {
|
|||||||
return t.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
|
// WithSpan forwards the call to the wrapped tracer with a modified
|
||||||
// body callback, which sets the active OpenTracing span before
|
// body callback, which sets the active OpenTracing span before
|
||||||
// calling the original callback.
|
// calling the original callback.
|
||||||
|
|||||||
@@ -28,11 +28,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
streaming = sdk.New(spanlog.New()).
|
streaming = sdk.New(spanlog.New())
|
||||||
WithComponent("example").
|
|
||||||
WithResources(
|
|
||||||
key.New("whatevs").String("yesss"),
|
|
||||||
)
|
|
||||||
|
|
||||||
tracer trace.Tracer = streaming
|
tracer trace.Tracer = streaming
|
||||||
meter metric.Meter = metric.NoopMeter{}
|
meter metric.Meter = metric.NoopMeter{}
|
||||||
|
|||||||
@@ -31,12 +31,10 @@ type tracer struct {
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
// TODO These should move somewhere in the api, right?
|
// TODO These should move somewhere in the api, right?
|
||||||
ServiceKey = key.New("service")
|
ErrorKey = key.New("error")
|
||||||
ComponentKey = key.New("component")
|
SpanIDKey = key.New("span_id")
|
||||||
ErrorKey = key.New("error")
|
TraceIDKey = key.New("trace_id")
|
||||||
SpanIDKey = key.New("span_id")
|
MessageKey = key.New("message")
|
||||||
TraceIDKey = key.New("trace_id")
|
|
||||||
MessageKey = key.New("message")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func New(observers ...exporter.Observer) trace.Tracer {
|
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 {
|
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/trace.WithRegion for execution tracer support
|
||||||
// TODO: use runtime/pprof.Do for profile tags support
|
// TODO: use runtime/pprof.Do for profile tags support
|
||||||
|
|||||||
Reference in New Issue
Block a user