tracer: finalize tracer implementation

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-03-04 01:12:16 +03:00
parent a862562284
commit 1f0482fbd5
6 changed files with 475 additions and 189 deletions

View File

@@ -2,39 +2,27 @@ package tracer
import "github.com/unistack-org/micro/v3/logger"
var (
// DefaultSize of the buffer
DefaultSize = 64
)
type SpanOptions struct {
}
type SpanOption func(o *SpanOptions)
type EventOptions struct {
}
type EventOption func(o *EventOptions)
// Options struct
type Options struct {
// Name of the tracer
Name string
// Logger is the logger for messages
Logger logger.Logger
// Size is the size of ring buffer
Size int
}
// Option func
type Option func(o *Options)
// ReadOptions struct
type ReadOptions struct {
// Trace id
Trace string
}
// ReadOption func
type ReadOption func(o *ReadOptions)
// ReadTrace read the given trace
func ReadTrace(t string) ReadOption {
return func(o *ReadOptions) {
o.Trace = t
}
}
// Logger sets the logger
func Logger(l logger.Logger) Option {
return func(o *Options) {
@@ -46,7 +34,6 @@ func Logger(l logger.Logger) Option {
func NewOptions(opts ...Option) Options {
options := Options{
Logger: logger.DefaultLogger,
Size: DefaultSize,
}
for _, o := range opts {
o(&options)