Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
1566ccf0d8 | |||
2abea05b41 | |||
a5c1f0a9a7 | |||
|
3d56f83bd2 | ||
9b7a48f410 | |||
|
418124c029 | ||
a0526b1790 | |||
|
ea7f1e66e7 | ||
690f9e1471 | |||
|
c4fcb7319c | ||
2f03982b7b | |||
|
051fcd556f |
2
go.mod
2
go.mod
@@ -4,6 +4,6 @@ go 1.16
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/opentracing/opentracing-go v1.2.0
|
github.com/opentracing/opentracing-go v1.2.0
|
||||||
go.unistack.org/micro/v3 v3.9.13
|
go.unistack.org/micro/v3 v3.10.0
|
||||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
)
|
)
|
||||||
|
4
go.sum
4
go.sum
@@ -73,8 +73,8 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:
|
|||||||
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
|
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
|
||||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||||
go.unistack.org/micro-proto/v3 v3.3.1/go.mod h1:cwRyv8uInM2I7EbU7O8Fx2Ls3N90Uw9UCCcq4olOdfE=
|
go.unistack.org/micro-proto/v3 v3.3.1/go.mod h1:cwRyv8uInM2I7EbU7O8Fx2Ls3N90Uw9UCCcq4olOdfE=
|
||||||
go.unistack.org/micro/v3 v3.9.13 h1:x1/H4rDgvz2JWXx6UvFiWDyRLxg2Kpp6V1kjzpLlyvo=
|
go.unistack.org/micro/v3 v3.10.0 h1:nPtk5Pfwk524HyezGtQ3m3vbK4LdvXqWLI7HgeilYOk=
|
||||||
go.unistack.org/micro/v3 v3.9.13/go.mod h1:gI4RkJKHLPW7KV6h4+ZBOZD997MRvFRXMPQIHpozikI=
|
go.unistack.org/micro/v3 v3.10.0/go.mod h1:gI4RkJKHLPW7KV6h4+ZBOZD997MRvFRXMPQIHpozikI=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
// Package opentracing provides wrappers for OpenTracing
|
|
||||||
package opentracing
|
package opentracing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
opentracing "github.com/opentracing/opentracing-go"
|
"github.com/opentracing/opentracing-go"
|
||||||
|
"github.com/opentracing/opentracing-go/log"
|
||||||
"go.unistack.org/micro/v3/metadata"
|
"go.unistack.org/micro/v3/metadata"
|
||||||
"go.unistack.org/micro/v3/tracer"
|
"go.unistack.org/micro/v3/tracer"
|
||||||
)
|
)
|
||||||
@@ -12,7 +12,8 @@ import (
|
|||||||
var _ tracer.Tracer = &opentracingTracer{}
|
var _ tracer.Tracer = &opentracingTracer{}
|
||||||
|
|
||||||
type opentracingTracer struct {
|
type opentracingTracer struct {
|
||||||
opts tracer.Options
|
opts tracer.Options
|
||||||
|
tracer opentracing.Tracer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ot *opentracingTracer) Name() string {
|
func (ot *opentracingTracer) Name() string {
|
||||||
@@ -20,11 +21,49 @@ func (ot *opentracingTracer) Name() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ot *opentracingTracer) Init(opts ...tracer.Option) error {
|
func (ot *opentracingTracer) Init(opts ...tracer.Option) error {
|
||||||
|
ot.opts = tracer.NewOptions(opts...)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ot *opentracingTracer) Start(ctx context.Context, name string, opts ...tracer.SpanOption) (context.Context, tracer.Span) {
|
func (ot *opentracingTracer) Start(ctx context.Context, name string, opts ...tracer.SpanOption) (context.Context, tracer.Span) {
|
||||||
return nil, nil
|
ctx, span, _ := StartSpanFromIncomingContext(ctx, ot.tracer, name)
|
||||||
|
return ctx, &opentracingSpan{span: span}
|
||||||
|
}
|
||||||
|
|
||||||
|
type opentracingSpan struct {
|
||||||
|
span opentracing.Span
|
||||||
|
labels []interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (os *opentracingSpan) Tracer() tracer.Tracer {
|
||||||
|
return &opentracingTracer{tracer: os.span.Tracer()}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (os *opentracingSpan) Finish(opts ...tracer.SpanOption) {
|
||||||
|
if len(os.labels) > 0 {
|
||||||
|
os.span.LogKV(os.labels...)
|
||||||
|
}
|
||||||
|
os.span.Finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (os *opentracingSpan) AddEvent(name string, opts ...tracer.EventOption) {
|
||||||
|
os.span.LogFields(log.Event(name))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (os *opentracingSpan) Context() context.Context {
|
||||||
|
return tracer.NewSpanContext(context.Background(), os)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (os *opentracingSpan) SetName(name string) {
|
||||||
|
os.span = os.span.SetOperationName(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (os *opentracingSpan) SetLabels(labels ...interface{}) {
|
||||||
|
os.labels = labels
|
||||||
|
}
|
||||||
|
|
||||||
|
func (os *opentracingSpan) AddLabels(labels ...interface{}) {
|
||||||
|
os.labels = append(os.labels, labels...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTracer(opts ...tracer.Option) *opentracingTracer {
|
func NewTracer(opts ...tracer.Option) *opentracingTracer {
|
||||||
|
Reference in New Issue
Block a user