SkyAPM / go2sky

Distributed tracing and monitor SDK in Go for Apache SkyWalking APM
https://skywalking.apache.org/
Apache License 2.0
447 stars 122 forks source link

Get Span from ctx #96

Closed matianjun1 closed 2 years ago

matianjun1 commented 3 years ago

Sometime I need spanFromContext

such as go-redis-hook

type Hook interface {
    BeforeProcess(ctx context.Context, cmd Cmder) (context.Context, error)
    AfterProcess(ctx context.Context, cmd Cmder) error
}

only ctx can be propagation, I cant do span.End further

Maybe there is a easy way to solve, set ctxKeyInstance to be public. Then I can use this key to get activeSpan from ctx and do (.Span) to get a Span

wu-sheng commented 3 years ago

Typically, this should be called ctx#activeSpan. We are welcome the contribution.