Compare commits

...

12 Commits

Author SHA1 Message Date
1566ccf0d8 Merge pull request #27 from unistack-org/fixes
implement tracer.Tracer interface
2023-01-16 23:43:40 +03:00
2abea05b41 update
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-01-16 23:41:56 +03:00
a5c1f0a9a7 Merge pull request #26 from unistack-org/dependabot/go_modules/go.unistack.org/micro/v3-3.10.0
Bump go.unistack.org/micro/v3 from 3.9.18 to 3.10.0
2023-01-09 05:15:34 +03:00
dependabot[bot]
3d56f83bd2 Bump go.unistack.org/micro/v3 from 3.9.18 to 3.10.0
Bumps [go.unistack.org/micro/v3](https://github.com/unistack-org/micro) from 3.9.18 to 3.10.0.
- [Release notes](https://github.com/unistack-org/micro/releases)
- [Commits](https://github.com/unistack-org/micro/compare/v3.9.18...v3.10.0)

---
updated-dependencies:
- dependency-name: go.unistack.org/micro/v3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-09 02:14:12 +00:00
9b7a48f410 Merge pull request #25 from unistack-org/dependabot/go_modules/go.unistack.org/micro/v3-3.9.18
Bump go.unistack.org/micro/v3 from 3.9.17 to 3.9.18
2022-12-28 05:06:53 +03:00
dependabot[bot]
418124c029 Bump go.unistack.org/micro/v3 from 3.9.17 to 3.9.18
Bumps [go.unistack.org/micro/v3](https://github.com/unistack-org/micro) from 3.9.17 to 3.9.18.
- [Release notes](https://github.com/unistack-org/micro/releases)
- [Commits](https://github.com/unistack-org/micro/compare/v3.9.17...v3.9.18)

---
updated-dependencies:
- dependency-name: go.unistack.org/micro/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-28 02:05:24 +00:00
a0526b1790 Merge pull request #24 from unistack-org/dependabot/go_modules/go.unistack.org/micro/v3-3.9.17
Bump go.unistack.org/micro/v3 from 3.9.15 to 3.9.17
2022-12-26 05:14:42 +03:00
dependabot[bot]
ea7f1e66e7 Bump go.unistack.org/micro/v3 from 3.9.15 to 3.9.17
Bumps [go.unistack.org/micro/v3](https://github.com/unistack-org/micro) from 3.9.15 to 3.9.17.
- [Release notes](https://github.com/unistack-org/micro/releases)
- [Commits](https://github.com/unistack-org/micro/compare/v3.9.15...v3.9.17)

---
updated-dependencies:
- dependency-name: go.unistack.org/micro/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-26 02:13:26 +00:00
690f9e1471 Merge pull request #23 from unistack-org/dependabot/go_modules/go.unistack.org/micro/v3-3.9.15
Bump go.unistack.org/micro/v3 from 3.9.14 to 3.9.15
2022-11-29 05:09:06 +03:00
dependabot[bot]
c4fcb7319c Bump go.unistack.org/micro/v3 from 3.9.14 to 3.9.15
Bumps [go.unistack.org/micro/v3](https://github.com/unistack-org/micro) from 3.9.14 to 3.9.15.
- [Release notes](https://github.com/unistack-org/micro/releases)
- [Commits](https://github.com/unistack-org/micro/compare/v3.9.14...v3.9.15)

---
updated-dependencies:
- dependency-name: go.unistack.org/micro/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-29 02:07:50 +00:00
2f03982b7b Merge pull request #22 from unistack-org/dependabot/go_modules/go.unistack.org/micro/v3-3.9.14
Bump go.unistack.org/micro/v3 from 3.9.13 to 3.9.14
2022-11-28 05:13:17 +03:00
dependabot[bot]
051fcd556f Bump go.unistack.org/micro/v3 from 3.9.13 to 3.9.14
Bumps [go.unistack.org/micro/v3](https://github.com/unistack-org/micro) from 3.9.13 to 3.9.14.
- [Release notes](https://github.com/unistack-org/micro/releases)
- [Commits](https://github.com/unistack-org/micro/compare/v3.9.13...v3.9.14)

---
updated-dependencies:
- dependency-name: go.unistack.org/micro/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-28 02:11:50 +00:00
3 changed files with 46 additions and 7 deletions

2
go.mod
View File

@@ -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
View File

@@ -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=

View File

@@ -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 {