update for latest micro #41

Merged
vtolstov merged 1 commits from micro into master 2023-08-02 09:41:51 +03:00
4 changed files with 20 additions and 21 deletions

8
go.mod
View File

@ -4,11 +4,7 @@ go 1.20
require ( require (
github.com/opentracing/opentracing-go v1.2.0 github.com/opentracing/opentracing-go v1.2.0
go.unistack.org/micro/v4 v4.0.1 go.unistack.org/micro/v4 v4.0.5
) )
require ( require github.com/stretchr/testify v1.8.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/stretchr/testify v1.5.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

12
go.sum
View File

@ -1,17 +1,15 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
go.unistack.org/micro/v4 v4.0.1 h1:xo1IxbVfgh8i0eY0VeYa3cbb13u5n/Mxnp3FOgWD4Jo= go.unistack.org/micro/v4 v4.0.1 h1:xo1IxbVfgh8i0eY0VeYa3cbb13u5n/Mxnp3FOgWD4Jo=
go.unistack.org/micro/v4 v4.0.1/go.mod h1:p/J5UcSJjfHsWGT31uKoghQ5rUQZzQJBAFy+Z4+ZVMs= go.unistack.org/micro/v4 v4.0.1/go.mod h1:p/J5UcSJjfHsWGT31uKoghQ5rUQZzQJBAFy+Z4+ZVMs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= go.unistack.org/micro/v4 v4.0.5 h1:uacmV8yHjCOtVfECc4w1tgp6bd3bBWrZa8X4iQLk48g=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= go.unistack.org/micro/v4 v4.0.5/go.mod h1:bVEYTlPi0EsdgZZt311bIroDg9ict7ky3C87dSCCAGk=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=

View File

@ -7,6 +7,7 @@ import (
"github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go"
"github.com/opentracing/opentracing-go/log" "github.com/opentracing/opentracing-go/log"
"go.unistack.org/micro/v4/metadata" "go.unistack.org/micro/v4/metadata"
"go.unistack.org/micro/v4/options"
"go.unistack.org/micro/v4/tracer" "go.unistack.org/micro/v4/tracer"
) )
@ -21,7 +22,11 @@ func (ot *otTracer) Name() string {
return ot.opts.Name return ot.opts.Name
} }
func (ot *otTracer) Init(opts ...tracer.Option) error { func (ot *otTracer) Flush(ctx context.Context) error {
return nil
}
func (ot *otTracer) Init(opts ...options.Option) error {
for _, o := range opts { for _, o := range opts {
o(&ot.opts) o(&ot.opts)
} }
@ -35,7 +40,7 @@ func (ot *otTracer) Init(opts ...tracer.Option) error {
return nil return nil
} }
func (ot *otTracer) Start(ctx context.Context, name string, opts ...tracer.SpanOption) (context.Context, tracer.Span) { func (ot *otTracer) Start(ctx context.Context, name string, opts ...options.Option) (context.Context, tracer.Span) {
options := tracer.NewSpanOptions(opts...) options := tracer.NewSpanOptions(opts...)
var span opentracing.Span var span opentracing.Span
switch options.Kind { switch options.Kind {
@ -73,14 +78,14 @@ func (os *otSpan) Tracer() tracer.Tracer {
return &otTracer{tracer: os.span.Tracer()} return &otTracer{tracer: os.span.Tracer()}
} }
func (os *otSpan) Finish(opts ...tracer.SpanOption) { func (os *otSpan) Finish(opts ...options.Option) {
if len(os.opts.Labels) > 0 { if len(os.opts.Labels) > 0 {
os.span.LogKV(os.opts.Labels...) os.span.LogKV(os.opts.Labels...)
} }
os.span.Finish() os.span.Finish()
} }
func (os *otSpan) AddEvent(name string, opts ...tracer.EventOption) { func (os *otSpan) AddEvent(name string, opts ...options.Option) {
os.span.LogFields(log.Event(name)) os.span.LogFields(log.Event(name))
} }
@ -104,7 +109,7 @@ func (os *otSpan) AddLabels(labels ...interface{}) {
os.opts.Labels = append(os.opts.Labels, labels...) os.opts.Labels = append(os.opts.Labels, labels...)
} }
func NewTracer(opts ...tracer.Option) *otTracer { func NewTracer(opts ...options.Option) *otTracer {
options := tracer.NewOptions(opts...) options := tracer.NewOptions(opts...)
return &otTracer{opts: options} return &otTracer{opts: options}
} }

View File

@ -2,11 +2,11 @@ package opentracing
import ( import (
"github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go"
"go.unistack.org/micro/v4/tracer" "go.unistack.org/micro/v4/options"
) )
type tracerKey struct{} type tracerKey struct{}
func Tracer(ot opentracing.Tracer) tracer.Option { func Tracer(ot opentracing.Tracer) options.Option {
return tracer.SetOption(tracerKey{}, ot) return options.ContextOption(tracerKey{}, ot)
} }