From 6543196faffc904d1c5c9413d74e02652f1ec6be Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Fri, 1 Sep 2023 15:39:30 +0300 Subject: [PATCH] tracer improve 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 873b564..68134ea 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/v3 v3.10.25 + go.unistack.org/micro/v3 v3.10.27 ) require github.com/stretchr/testify v1.8.1 // indirect diff --git a/go.sum b/go.sum index 51b5b7a..05f4441 100644 --- a/go.sum +++ b/go.sum @@ -13,8 +13,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ 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.25 h1:A0epdZHOqjnXx103wwFhPKgmvVVbScvfbmn3HmHz1wE= -go.unistack.org/micro/v3 v3.10.25/go.mod h1:ALkeXpqChYDjx8KPi7tz9mmIyOnob6nlNswsg8BnZjQ= +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= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/opentracing.go b/opentracing.go index a528124..0625092 100644 --- a/opentracing.go +++ b/opentracing.go @@ -81,6 +81,7 @@ func (os *otSpan) Finish(opts ...tracer.SpanOption) { 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": @@ -90,8 +91,10 @@ func (os *otSpan) Finish(opts ...tracer.SpanOption) { 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]) } @@ -100,6 +103,7 @@ func (os *otSpan) Finish(opts ...tracer.SpanOption) { 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