From acd0034624b0f01b618bf2b27342308b74aca917 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Fri, 1 Sep 2023 15:52:29 +0300 Subject: [PATCH] uniq labels Signed-off-by: Vasiliy Tolstov --- go.mod | 2 +- go.sum | 4 ++-- opentracing.go | 8 ++++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index a45a6e8..f6af100 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/opentracing/opentracing-go v1.2.0 - go.unistack.org/micro/v4 v4.0.7 + go.unistack.org/micro/v4 v4.0.10 ) require github.com/stretchr/testify v1.8.3 // indirect diff --git a/go.sum b/go.sum index b00da63..d6ed6dc 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 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.7 h1:2lwtZlHcSwgkahhFbkI4x1lOS79lw8uLHtcEhlFF+AM= -go.unistack.org/micro/v4 v4.0.7/go.mod h1:bVEYTlPi0EsdgZZt311bIroDg9ict7ky3C87dSCCAGk= +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= diff --git a/opentracing.go b/opentracing.go index 37cfe96..93295a0 100644 --- a/opentracing.go +++ b/opentracing.go @@ -82,6 +82,7 @@ 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] } + os.opts.Labels = tracer.UniqLabels(os.opts.Labels) for idx := 0; idx < len(os.opts.Labels); idx += 2 { switch os.opts.Labels[idx] { case "err": @@ -91,8 +92,10 @@ func (os *otSpan) Finish(opts ...options.Option) { continue case "X-Request-Id", "x-request-id": os.span.SetTag("x-request-id", os.opts.Labels[idx+1]) - case "rpc.call", "rpc.call_type", "rpc.flavor", "span.kind", "sdk.database", "db.statement", "db.args", "args", "db.query", "query", "method": - os.span.SetTag(fmt.Sprintf("%v", os.opts.Labels[idx]), fmt.Sprintf("%v", 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": + 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]) } @@ -101,6 +104,7 @@ func (os *otSpan) Finish(opts ...options.Option) { os.span.SetTag("error", true) os.span.LogKV("error", os.statusMsg) } + os.span.SetTag("span.kind", os.opts.Kind) os.span.Finish() } -- 2.45.2