1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-02-11 13:38:46 +02:00

tracing: set tracing status after request. (#911)

This commit is contained in:
dowenliu-xyz 2021-05-15 16:18:52 +08:00 committed by GitHub
parent e7926b989d
commit 24b1ca6bc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,6 +8,7 @@ import (
"github.com/go-kratos/kratos/v2/transport/http"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/trace"
"google.golang.org/grpc/metadata"
@ -103,6 +104,9 @@ func Server(opts ...Option) middleware.Middleware {
attribute.String("event", "error"),
attribute.String("message", err.Error()),
)
span.SetStatus(codes.Error, err.Error())
} else {
span.SetStatus(codes.Ok, "OK")
}
return
}
@ -158,6 +162,9 @@ func Client(opts ...Option) middleware.Middleware {
attribute.String("event", "error"),
attribute.String("message", err.Error()),
)
span.SetStatus(codes.Error, err.Error())
} else {
span.SetStatus(codes.Ok, "OK")
}
return
}