micro: rewrite options to support multiple building blocks
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
@@ -6,6 +6,10 @@ type noopTracer struct {
|
||||
opts Options
|
||||
}
|
||||
|
||||
func (n *noopTracer) Name() string {
|
||||
return n.opts.Name
|
||||
}
|
||||
|
||||
// Init initilize tracer
|
||||
func (n *noopTracer) Init(opts ...Option) error {
|
||||
for _, o := range opts {
|
||||
@@ -19,6 +23,11 @@ func (n *noopTracer) Start(ctx context.Context, name string) (context.Context, *
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Lookup get span from context
|
||||
func (n *noopTracer) Lookup(ctx context.Context) (*Span, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Finish finishes span
|
||||
func (n *noopTracer) Finish(*Span) error {
|
||||
return nil
|
||||
|
||||
@@ -9,6 +9,7 @@ var (
|
||||
|
||||
// Options struct
|
||||
type Options struct {
|
||||
Name string
|
||||
// Logger is the logger for messages
|
||||
Logger logger.Logger
|
||||
// Size is the size of ring buffer
|
||||
|
||||
@@ -15,10 +15,14 @@ var (
|
||||
|
||||
// Tracer is an interface for distributed tracing
|
||||
type Tracer interface {
|
||||
Name() string
|
||||
Init(...Option) error
|
||||
// Start a trace
|
||||
Start(ctx context.Context, name string) (context.Context, *Span)
|
||||
// Finish the trace
|
||||
Finish(*Span) error
|
||||
// Lookup get span from context
|
||||
Lookup(ctx context.Context) (*Span, error)
|
||||
// Read the traces
|
||||
Read(...ReadOption) ([]*Span, error)
|
||||
}
|
||||
Reference in New Issue
Block a user