avoid duplicate tags
Some checks failed
build / test (push) Failing after 1m17s
codeql / analyze (go) (push) Failing after 2m45s
build / lint (push) Successful in 9m30s

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2024-03-17 23:07:06 +03:00
parent 7948652293
commit 905910e8ce

View File

@ -76,8 +76,6 @@ func (t *otTracer) Start(ctx context.Context, name string, opts ...tracer.SpanOp
} }
} }
sp.AddLabels(options.Labels...)
return tracer.NewSpanContext(ctx, sp), sp return tracer.NewSpanContext(ctx, sp), sp
} }
@ -96,6 +94,7 @@ type otSpan struct {
opts tracer.SpanOptions opts tracer.SpanOptions
status tracer.SpanStatus status tracer.SpanStatus
statusMsg string statusMsg string
labels []interface{}
} }
func (os *otSpan) TraceID() string { func (os *otSpan) TraceID() string {
@ -171,19 +170,7 @@ func (os *otSpan) Kind() tracer.SpanKind {
} }
func (os *otSpan) AddLabels(labels ...interface{}) { func (os *otSpan) AddLabels(labels ...interface{}) {
l := len(labels) os.labels = append(os.labels, labels...)
for idx := 0; idx < l; idx++ {
switch lt := labels[idx].(type) {
case attribute.KeyValue:
os.span.SetTag(string(lt.Key), lt.Value.AsInterface())
case string:
if l > idx+1 {
os.span.SetTag(lt, labels[idx+1])
idx++
}
}
}
} }
func NewTracer(opts ...tracer.Option) *otTracer { func NewTracer(opts ...tracer.Option) *otTracer {