fixup span tags and logs
Some checks failed
build / test (push) Failing after 1m49s
build / lint (push) Successful in 9m49s
codeql / analyze (go) (push) Failing after 12m46s

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2024-03-12 12:38:40 +03:00
parent 3f9704aef8
commit c94af432a0

View File

@ -122,20 +122,28 @@ func (os *otSpan) Finish(opts ...tracer.SpanOption) {
}
os.opts.Labels = tracer.UniqLabels(os.opts.Labels)
for idx := 0; idx < len(os.opts.Labels); idx += 2 {
switch os.opts.Labels[idx] {
k, ok := os.opts.Labels[idx].(string)
if !ok {
continue
}
v, ok := os.opts.Labels[idx+1].(string)
if !ok {
v = fmt.Sprintf("%v", os.opts.Labels[idx+1])
}
switch k {
case "err":
os.status = tracer.SpanStatusError
os.statusMsg = fmt.Sprintf("%v", os.opts.Labels[idx+1])
os.statusMsg = v
case "error":
continue
case "X-Request-Id", "x-request-id":
os.span.SetTag("x-request-id", os.opts.Labels[idx+1])
os.span.SetTag("x-request-id", v)
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", "messaging.operation":
os.span.SetTag(fmt.Sprintf("%v", os.opts.Labels[idx]), os.opts.Labels[idx+1])
os.span.SetTag(k, v)
default:
os.span.LogKV(os.opts.Labels[idx], os.opts.Labels[idx+1])
os.span.LogKV(k, v)
}
}
if os.status == tracer.SpanStatusError {