tracer: add context to Options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
9347bb0651
commit
3bd6db79cb
@ -46,3 +46,13 @@ func NewSpanContext(ctx context.Context, span Span) context.Context {
|
|||||||
}
|
}
|
||||||
return context.WithValue(ctx, spanKey{}, span)
|
return context.WithValue(ctx, spanKey{}, span)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetOption returns a function to setup a context with given value
|
||||||
|
func SetOption(k, v interface{}) Option {
|
||||||
|
return func(o *Options) {
|
||||||
|
if o.Context == nil {
|
||||||
|
o.Context = context.Background()
|
||||||
|
}
|
||||||
|
o.Context = context.WithValue(o.Context, k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
package tracer
|
package tracer
|
||||||
|
|
||||||
import "go.unistack.org/micro/v3/logger"
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"go.unistack.org/micro/v3/logger"
|
||||||
|
)
|
||||||
|
|
||||||
// SpanOptions contains span option
|
// SpanOptions contains span option
|
||||||
type SpanOptions struct {
|
type SpanOptions struct {
|
||||||
@ -28,6 +32,8 @@ type Options struct {
|
|||||||
Logger logger.Logger
|
Logger logger.Logger
|
||||||
// Name of the tracer
|
// Name of the tracer
|
||||||
Name string
|
Name string
|
||||||
|
// Context used to store custome tracer options
|
||||||
|
Context context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
// Option func signature
|
// Option func signature
|
||||||
|
Loading…
Reference in New Issue
Block a user