micro/tracer/options.go

52 lines
915 B
Go
Raw Normal View History

package tracer
2020-01-18 13:20:46 +03:00
import "go.unistack.org/micro/v3/logger"
// SpanOptions contains span option
type SpanOptions struct{}
// SpanOption func signature
type SpanOption func(o *SpanOptions)
// EventOptions contains event options
type EventOptions struct{}
// EventOption func signature
type EventOption func(o *EventOptions)
// Options struct
2020-01-29 18:45:11 +03:00
type Options struct {
// Logger used for logging
Logger logger.Logger
// Name of the tracer
Name string
2020-01-29 18:45:11 +03:00
}
2020-01-18 13:20:46 +03:00
// Option func signature
2020-01-18 13:20:46 +03:00
type Option func(o *Options)
// Logger sets the logger
func Logger(l logger.Logger) Option {
return func(o *Options) {
o.Logger = l
}
}
// NewOptions returns default options
func NewOptions(opts ...Option) Options {
options := Options{
Logger: logger.DefaultLogger,
2020-01-29 18:45:11 +03:00
}
for _, o := range opts {
o(&options)
}
return options
2020-01-29 18:45:11 +03:00
}
// Name sets the name
func Name(n string) Option {
return func(o *Options) {
o.Name = n
}
}