Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
123023be06 | |||
c2f6dfd267 | |||
acd0034624 | |||
b32b60d136 | |||
66d1c9d811 | |||
a1838a8070 | |||
9084c3134c | |||
2fb5693d97 | |||
57e07c302c |
6
go.mod
6
go.mod
@@ -1,10 +1,10 @@
|
||||
module go.unistack.org/micro-tracer-opentracing/v3
|
||||
module go.unistack.org/micro-tracer-opentracing/v4
|
||||
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
github.com/opentracing/opentracing-go v1.2.0
|
||||
go.unistack.org/micro/v3 v3.10.27
|
||||
go.unistack.org/micro/v4 v4.0.10
|
||||
)
|
||||
|
||||
require github.com/stretchr/testify v1.8.1 // indirect
|
||||
require github.com/stretchr/testify v1.8.3 // indirect
|
||||
|
16
go.sum
16
go.sum
@@ -1,21 +1,13 @@
|
||||
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/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/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/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
go.unistack.org/micro/v3 v3.10.27 h1:jluDdhkG9P/nchaNlhLkBmGxUASkV/L+/fuWG5RX1tY=
|
||||
go.unistack.org/micro/v3 v3.10.27/go.mod h1:ALkeXpqChYDjx8KPi7tz9mmIyOnob6nlNswsg8BnZjQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
|
||||
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
go.unistack.org/micro/v4 v4.0.10 h1:uKqED/n/zrJd4NGxm9OOUw26UMibgYFhf89MOTnM1go=
|
||||
go.unistack.org/micro/v4 v4.0.10/go.mod h1:QT3gOIE4qGgBiQGm2Pad/62Sl5R53QfrgYHD448aX14=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
@@ -7,8 +7,9 @@ import (
|
||||
|
||||
ot "github.com/opentracing/opentracing-go"
|
||||
otlog "github.com/opentracing/opentracing-go/log"
|
||||
"go.unistack.org/micro/v3/metadata"
|
||||
"go.unistack.org/micro/v3/tracer"
|
||||
"go.unistack.org/micro/v4/metadata"
|
||||
"go.unistack.org/micro/v4/options"
|
||||
"go.unistack.org/micro/v4/tracer"
|
||||
)
|
||||
|
||||
var _ tracer.Tracer = &otTracer{}
|
||||
@@ -26,7 +27,7 @@ func (t *otTracer) Flush(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *otTracer) Init(opts ...tracer.Option) error {
|
||||
func (t *otTracer) Init(opts ...options.Option) error {
|
||||
for _, o := range opts {
|
||||
o(&t.opts)
|
||||
}
|
||||
@@ -40,7 +41,7 @@ func (t *otTracer) Init(opts ...tracer.Option) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *otTracer) Start(ctx context.Context, name string, opts ...tracer.SpanOption) (context.Context, tracer.Span) {
|
||||
func (t *otTracer) Start(ctx context.Context, name string, opts ...options.Option) (context.Context, tracer.Span) {
|
||||
options := tracer.NewSpanOptions(opts...)
|
||||
var span ot.Span
|
||||
switch options.Kind {
|
||||
@@ -77,7 +78,7 @@ func (os *otSpan) Tracer() tracer.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)%2 != 0 {
|
||||
os.opts.Labels = os.opts.Labels[:len(os.opts.Labels)-1]
|
||||
}
|
||||
@@ -93,7 +94,7 @@ func (os *otSpan) Finish(opts ...tracer.SpanOption) {
|
||||
os.span.SetTag("x-request-id", os.opts.Labels[idx+1])
|
||||
case "rpc.call", "rpc.call_type", "rpc.flavor", "rpc.service", "rpc.method",
|
||||
"sdk.database", "db.statement", "db.args", "db.query", "db.method",
|
||||
"messaging.destination.name", "messaging.source.name":
|
||||
"messaging.destination.name", "messaging.source.name", "messaging.operation":
|
||||
os.span.SetTag(fmt.Sprintf("%v", os.opts.Labels[idx]), os.opts.Labels[idx+1])
|
||||
default:
|
||||
os.span.LogKV(os.opts.Labels[idx], os.opts.Labels[idx+1])
|
||||
@@ -107,7 +108,7 @@ func (os *otSpan) Finish(opts ...tracer.SpanOption) {
|
||||
os.span.Finish()
|
||||
}
|
||||
|
||||
func (os *otSpan) AddEvent(name string, opts ...tracer.EventOption) {
|
||||
func (os *otSpan) AddEvent(name string, opts ...options.Option) {
|
||||
os.span.LogFields(otlog.Event(name))
|
||||
}
|
||||
|
||||
@@ -131,7 +132,7 @@ func (os *otSpan) AddLabels(labels ...interface{}) {
|
||||
os.opts.Labels = append(os.opts.Labels, labels...)
|
||||
}
|
||||
|
||||
func NewTracer(opts ...tracer.Option) *otTracer {
|
||||
func NewTracer(opts ...options.Option) *otTracer {
|
||||
options := tracer.NewOptions(opts...)
|
||||
return &otTracer{opts: options}
|
||||
}
|
||||
|
@@ -5,8 +5,8 @@ import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/opentracing/opentracing-go"
|
||||
"go.unistack.org/micro/v3/metadata"
|
||||
opentracing "github.com/opentracing/opentracing-go"
|
||||
"go.unistack.org/micro/v4/metadata"
|
||||
)
|
||||
|
||||
func TestStartSpanFromIncomingContext(t *testing.T) {
|
||||
|
@@ -2,11 +2,11 @@ package opentracing
|
||||
|
||||
import (
|
||||
"github.com/opentracing/opentracing-go"
|
||||
"go.unistack.org/micro/v3/tracer"
|
||||
"go.unistack.org/micro/v4/options"
|
||||
)
|
||||
|
||||
type tracerKey struct{}
|
||||
|
||||
func Tracer(ot opentracing.Tracer) tracer.Option {
|
||||
return tracer.SetOption(tracerKey{}, ot)
|
||||
func Tracer(ot opentracing.Tracer) options.Option {
|
||||
return options.ContextOption(tracerKey{}, ot)
|
||||
}
|
||||
|
Reference in New Issue
Block a user