2020-09-10 00:06:29 +03:00
|
|
|
package tracer
|
2020-01-18 10:20:46 +00:00
|
|
|
|
2020-12-09 12:10:25 +03:00
|
|
|
import "github.com/unistack-org/micro/v3/logger"
|
|
|
|
|
2021-04-27 08:32:47 +03:00
|
|
|
type SpanOptions struct{}
|
2021-03-04 01:12:16 +03:00
|
|
|
|
|
|
|
type SpanOption func(o *SpanOptions)
|
|
|
|
|
2021-04-27 08:32:47 +03:00
|
|
|
type EventOptions struct{}
|
2021-03-04 01:12:16 +03:00
|
|
|
|
|
|
|
type EventOption func(o *EventOptions)
|
2020-11-03 02:02:32 +03:00
|
|
|
|
2020-11-03 01:08:23 +03:00
|
|
|
// Options struct
|
2020-01-29 15:45:11 +00:00
|
|
|
type Options struct {
|
2021-03-06 19:45:13 +03:00
|
|
|
// Logger used for logging
|
|
|
|
Logger logger.Logger
|
2021-03-04 01:12:16 +03:00
|
|
|
// Name of the tracer
|
2021-01-29 13:17:32 +03:00
|
|
|
Name string
|
2020-01-29 15:45:11 +00:00
|
|
|
}
|
2020-01-18 10:20:46 +00:00
|
|
|
|
2020-11-03 01:08:23 +03:00
|
|
|
// Option func
|
2020-01-18 10:20:46 +00:00
|
|
|
type Option func(o *Options)
|
|
|
|
|
2020-12-09 12:10:25 +03:00
|
|
|
// Logger sets the logger
|
|
|
|
func Logger(l logger.Logger) Option {
|
|
|
|
return func(o *Options) {
|
|
|
|
o.Logger = l
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 02:02:32 +03:00
|
|
|
// NewOptions returns default options
|
|
|
|
func NewOptions(opts ...Option) Options {
|
|
|
|
options := Options{
|
2020-12-09 12:10:25 +03:00
|
|
|
Logger: logger.DefaultLogger,
|
2020-01-29 15:45:11 +00:00
|
|
|
}
|
2020-11-03 02:02:32 +03:00
|
|
|
for _, o := range opts {
|
|
|
|
o(&options)
|
|
|
|
}
|
|
|
|
return options
|
2020-01-29 15:45:11 +00:00
|
|
|
}
|
2021-01-29 14:07:35 +03:00
|
|
|
|
|
|
|
// Name sets the name
|
|
|
|
func Name(n string) Option {
|
|
|
|
return func(o *Options) {
|
|
|
|
o.Name = n
|
|
|
|
}
|
|
|
|
}
|