1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-05-19 21:23:04 +02:00

21 lines
466 B
Go
Raw Normal View History

2021-08-30 16:48:57 +02:00
package trace
import (
"context"
"runtime"
"github.com/opentracing/opentracing-go"
)
// NewSpan accepts a context and returns an OpenTracing span. Can be used to
// nest spans.
func NewSpan(ctx context.Context) opentracing.Span {
pc := make([]uintptr, 10) // at least 1 entry needed
runtime.Callers(2, pc)
span := opentracing.StartSpan(
runtime.FuncForPC(pc[0]).Name(),
opentracing.ChildOf(opentracing.SpanFromContext(ctx).Context()),
)
return span
}