|
|
@ -30,15 +30,15 @@ func NewTracer(kind trace.SpanKind, opts ...Option) *Tracer { |
|
|
|
for _, o := range opts { |
|
|
|
for _, o := range opts { |
|
|
|
o(&op) |
|
|
|
o(&op) |
|
|
|
} |
|
|
|
} |
|
|
|
if op.tracerProvider != nil { |
|
|
|
if op.tracerProvider == nil { |
|
|
|
otel.SetTracerProvider(op.tracerProvider) |
|
|
|
op.tracerProvider = otel.GetTracerProvider() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch kind { |
|
|
|
switch kind { |
|
|
|
case trace.SpanKindClient: |
|
|
|
case trace.SpanKindClient: |
|
|
|
return &Tracer{tracer: otel.Tracer(op.tracerName), kind: kind, opt: &op} |
|
|
|
return &Tracer{tracer: op.tracerProvider.Tracer(op.tracerName), kind: kind, opt: &op} |
|
|
|
case trace.SpanKindServer: |
|
|
|
case trace.SpanKindServer: |
|
|
|
return &Tracer{tracer: otel.Tracer(op.tracerName), kind: kind, opt: &op} |
|
|
|
return &Tracer{tracer: op.tracerProvider.Tracer(op.tracerName), kind: kind, opt: &op} |
|
|
|
default: |
|
|
|
default: |
|
|
|
panic(fmt.Sprintf("unsupported span kind: %v", kind)) |
|
|
|
panic(fmt.Sprintf("unsupported span kind: %v", kind)) |
|
|
|
} |
|
|
|
} |
|
|
|