From a4a6db00802e20d297719b633b4c9b804c5228a4 Mon Sep 17 00:00:00 2001 From: kpango Date: Thu, 18 Aug 2022 13:27:38 +0900 Subject: [PATCH] fix Signed-off-by: kpango --- pkg/agent/core/ngt/handler/grpc/object.go | 24 +- pkg/gateway/lb/handler/grpc/handler.go | 337 ++++++++++++++-------- 2 files changed, 235 insertions(+), 126 deletions(-) diff --git a/pkg/agent/core/ngt/handler/grpc/object.go b/pkg/agent/core/ngt/handler/grpc/object.go index 771448c4f43..9cb79449db9 100644 --- a/pkg/agent/core/ngt/handler/grpc/object.go +++ b/pkg/agent/core/ngt/handler/grpc/object.go @@ -60,7 +60,9 @@ func (s *server) Exists(ctx context.Context, uid *payload.Object_ID) (res *paylo }) if span != nil { - span.SetStatus(trace.StatusCodeInvalidArgument(err.Error())) + span.RecordError(err) + span.SetAttributes(trace.StatusCodeInvalidArgument(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } log.Warn(err) return nil, err @@ -78,7 +80,9 @@ func (s *server) Exists(ctx context.Context, uid *payload.Object_ID) (res *paylo }, uid.GetId()) if span != nil { - span.SetStatus(trace.StatusCodeNotFound(err.Error())) + span.RecordError(err) + span.SetAttributes(trace.StatusCodeNotFound(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -114,7 +118,9 @@ func (s *server) GetObject(ctx context.Context, id *payload.Object_VectorRequest }) log.Warn(err) if span != nil { - span.SetStatus(trace.StatusCodeInvalidArgument(err.Error())) + span.RecordError(err) + span.SetAttributes(trace.StatusCodeInvalidArgument(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -131,7 +137,9 @@ func (s *server) GetObject(ctx context.Context, id *payload.Object_VectorRequest ResourceName: fmt.Sprintf("%s: %s(%s)", apiName, s.name, s.ip), }, info.Get()) if span != nil { - span.SetStatus(trace.StatusCodeNotFound(err.Error())) + span.RecordError(err) + span.SetAttributes(trace.StatusCodeNotFound(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -163,7 +171,9 @@ func (s *server) StreamGetObject(stream vald.Object_StreamGetObjectServer) (err if err != nil { st, msg, err := status.ParseError(err, codes.Internal, "failed to parse GetObject gRPC error response") if sspan != nil { - sspan.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) + sspan.RecordError(err) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Object_StreamVector{ Payload: &payload.Object_StreamVector_Status{ @@ -181,7 +191,9 @@ func (s *server) StreamGetObject(stream vald.Object_StreamGetObjectServer) (err if err != nil { st, msg, err := status.ParseError(err, codes.Internal, "failed to parse StreamGetObject gRPC error response") if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) + span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } log.Error(err) diff --git a/pkg/gateway/lb/handler/grpc/handler.go b/pkg/gateway/lb/handler/grpc/handler.go index cadf9f846e7..a71c663f278 100644 --- a/pkg/gateway/lb/handler/grpc/handler.go +++ b/pkg/gateway/lb/handler/grpc/handler.go @@ -97,8 +97,9 @@ func (s *server) Exists(ctx context.Context, meta *payload.Object_ID) (id *paylo }) log.Warn(err) if span != nil { - span.SetStatus(trace.StatusCodeInvalidArgument(err.Error())) span.RecordError(err) + span.SetAttributes(trace.StatusCodeInvalidArgument(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -125,21 +126,23 @@ func (s *server) Exists(ctx context.Context, meta *payload.Object_ID) (id *paylo case errors.Is(err, context.Canceled), errors.Is(err, errors.ErrRPCCallFailed(target, context.Canceled)): if sspan != nil { - sspan.SetStatus(trace.StatusCodeCancelled( + sspan.RecordError(err) + sspan.SetAttributes(trace.StatusCodeCancelled( errdetails.ValdGRPCResourceTypePrefix + "/vald.v1.Exists.BroadCast/" + - target + " canceled: " + err.Error())) - sspan.RecordError(err) + target + " canceled: " + err.Error())...) + sspan.SetStatus(trace.StatusError, err.Error()) } return nil case errors.Is(err, context.DeadlineExceeded), errors.Is(err, errors.ErrRPCCallFailed(target, context.DeadlineExceeded)): if sspan != nil { - sspan.SetStatus(trace.StatusCodeDeadlineExceeded( + sspan.RecordError(err) + sspan.SetAttributes(trace.StatusCodeDeadlineExceeded( errdetails.ValdGRPCResourceTypePrefix + "/vald.v1.Exists.BroadCast/" + - target + " deadline_exceeded: " + err.Error())) - sspan.RecordError(err) + target + " deadline_exceeded: " + err.Error())...) + sspan.SetStatus(trace.StatusError, err.Error()) } return nil } @@ -157,8 +160,9 @@ func (s *server) Exists(ctx context.Context, meta *payload.Object_ID) (id *paylo ResourceName: fmt.Sprintf("%s: %s(%s) to %s", apiName, s.name, s.ip, target), }) if sspan != nil { - sspan.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) sspan.RecordError(err) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetStatus(trace.StatusError, err.Error()) } if err != nil && st.Code() != codes.NotFound { return err @@ -195,8 +199,9 @@ func (s *server) Exists(ctx context.Context, meta *payload.Object_ID) (id *paylo ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err @@ -228,8 +233,9 @@ func (s *server) Search(ctx context.Context, req *payload.Search_Request) (res * }, }) if span != nil { - span.SetStatus(trace.StatusCodeInvalidArgument(err.Error())) span.RecordError(err) + span.SetAttributes(trace.StatusCodeInvalidArgument(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -261,8 +267,9 @@ func (s *server) Search(ctx context.Context, req *payload.Search_Request) (res * ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }, info.Get()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -299,8 +306,9 @@ func (s *server) SearchByID(ctx context.Context, req *payload.Search_IDRequest) ResourceName: fmt.Sprintf("%s: %s(%s)", apiName, s.name, s.ip), }) if span != nil { - span.SetStatus(trace.StatusCodeInvalidArgument(err.Error())) span.RecordError(err) + span.SetAttributes(trace.StatusCodeInvalidArgument(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -353,8 +361,9 @@ func (s *server) SearchByID(ctx context.Context, req *payload.Search_IDRequest) ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, errors.Wrap(err, serr.Error()) } @@ -388,8 +397,9 @@ func (s *server) SearchByID(ctx context.Context, req *payload.Search_IDRequest) }) err = errors.Wrap(err, serr.Error()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -444,20 +454,22 @@ func (s *server) search(ctx context.Context, cfg *payload.Search_Config, case errors.Is(err, context.Canceled), errors.Is(err, errors.ErrRPCCallFailed(target, context.Canceled)): if sspan != nil { - sspan.SetStatus(trace.StatusCodeCancelled( + sspan.RecordError(err) + sspan.SetAttributes(trace.StatusCodeCancelled( errdetails.ValdGRPCResourceTypePrefix + "/vald.v1.search.BroadCast/" + - target + " canceled: " + err.Error())) - sspan.RecordError(err) + target + " canceled: " + err.Error())...) + sspan.SetStatus(trace.StatusError, err.Error()) } case errors.Is(err, context.DeadlineExceeded), errors.Is(err, errors.ErrRPCCallFailed(target, context.DeadlineExceeded)): if sspan != nil { - sspan.SetStatus(trace.StatusCodeDeadlineExceeded( + sspan.RecordError(err) + sspan.SetAttributes(trace.StatusCodeDeadlineExceeded( errdetails.ValdGRPCResourceTypePrefix + "/vald.v1.search.BroadCast/" + - target + " deadline_exceeded: " + err.Error())) - sspan.RecordError(err) + target + " deadline_exceeded: " + err.Error())...) + sspan.SetStatus(trace.StatusError, err.Error()) } case err != nil: st, msg, err := status.ParseError(err, codes.Internal, "failed to parse search gRPC error response", @@ -466,8 +478,9 @@ func (s *server) search(ctx context.Context, cfg *payload.Search_Config, ResourceName: fmt.Sprintf("%s: %s(%s) to %s", apiName, s.name, s.ip, target), }) if sspan != nil { - sspan.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) sspan.RecordError(err) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetStatus(trace.StatusError, err.Error()) } switch st.Code() { case codes.Internal, @@ -482,8 +495,9 @@ func (s *server) search(ctx context.Context, cfg *payload.Search_Config, ResourceName: fmt.Sprintf("%s: %s(%s) to %s", apiName, s.name, s.ip, target), }) if sspan != nil { - sspan.SetStatus(trace.StatusCodeNotFound(err.Error())) sspan.RecordError(err) + sspan.SetAttributes(trace.StatusCodeNotFound(err.Error())...) + sspan.SetStatus(trace.StatusError, err.Error()) } } for _, dist := range r.GetResults() { @@ -581,8 +595,9 @@ func (s *server) search(ctx context.Context, cfg *payload.Search_Config, }, info.Get(), ) if span != nil { - span.SetStatus(trace.StatusCodeDeadlineExceeded(err.Error())) span.RecordError(err) + span.SetAttributes(trace.StatusCodeDeadlineExceeded(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -600,8 +615,9 @@ func (s *server) search(ctx context.Context, cfg *payload.Search_Config, }, info.Get(), ) if span != nil { - span.SetStatus(trace.StatusCodeDeadlineExceeded(err.Error())) span.RecordError(err) + span.SetAttributes(trace.StatusCodeDeadlineExceeded(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -619,8 +635,9 @@ func (s *server) search(ctx context.Context, cfg *payload.Search_Config, ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }, info.Get()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } log.Warn(err) if len(res.GetResults()) == 0 { @@ -641,8 +658,9 @@ func (s *server) search(ctx context.Context, cfg *payload.Search_Config, ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }, info.Get()) if span != nil { - span.SetStatus(trace.StatusCodeNotFound(err.Error())) span.RecordError(err) + span.SetAttributes(trace.StatusCodeNotFound(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -652,8 +670,9 @@ func (s *server) search(ctx context.Context, cfg *payload.Search_Config, err = errors.ErrInsuffcientSearchResult } if span != nil { - span.SetStatus(trace.StatusCodeNotFound(err.Error())) span.RecordError(err) + span.SetAttributes(trace.StatusCodeNotFound(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } err = status.WrapWithNotFound( fmt.Sprintf("error search result length is not enough required: %d, found: %d", min, len(res.GetResults())), @@ -668,8 +687,9 @@ func (s *server) search(ctx context.Context, cfg *payload.Search_Config, }, info.Get(), ) if span != nil { - span.SetStatus(trace.StatusCodeNotFound(err.Error())) span.RecordError(err) + span.SetAttributes(trace.StatusCodeNotFound(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -702,8 +722,9 @@ func (s *server) StreamSearch(stream vald.Search_StreamSearchServer) (err error) if err != nil { st, msg, err := status.ParseError(err, codes.Internal, "failed to parse Search gRPC error response") if sspan != nil { - sspan.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) sspan.RecordError(err) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Search_StreamResponse{ Payload: &payload.Search_StreamResponse_Status{ @@ -722,8 +743,9 @@ func (s *server) StreamSearch(stream vald.Search_StreamSearchServer) (err error) st, msg, err := status.ParseError(err, codes.Internal, "failed to parse StreamSearch gRPC error response") if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return err } @@ -751,8 +773,9 @@ func (s *server) StreamSearchByID(stream vald.Search_StreamSearchByIDServer) (er if err != nil { st, msg, err := status.ParseError(err, codes.Internal, "failed to parse SearchByID gRPC error response") if sspan != nil { - sspan.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) sspan.RecordError(err) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Search_StreamResponse{ Payload: &payload.Search_StreamResponse_Status{ @@ -771,8 +794,9 @@ func (s *server) StreamSearchByID(stream vald.Search_StreamSearchByIDServer) (er st, msg, err := status.ParseError(err, codes.Internal, "failed to parse StreamSearchByID gRPC error response") if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return err } @@ -813,8 +837,9 @@ func (s *server) MultiSearch(ctx context.Context, reqs *payload.Search_MultiRequ }, }, info.Get()) if span != nil { - span.SetStatus(trace.StatusCodeInvalidArgument(err.Error())) span.RecordError(err) + span.SetAttributes(trace.StatusCodeInvalidArgument(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -835,8 +860,9 @@ func (s *server) MultiSearch(ctx context.Context, reqs *payload.Search_MultiRequ ServingData: errdetails.Serialize(query), }) if sspan != nil { - sspan.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) sspan.RecordError(err) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetStatus(trace.StatusError, err.Error()) } mu.Lock() if errs == nil { @@ -863,8 +889,9 @@ func (s *server) MultiSearch(ctx context.Context, reqs *payload.Search_MultiRequ ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -906,8 +933,9 @@ func (s *server) MultiSearchByID(ctx context.Context, reqs *payload.Search_Multi ServingData: errdetails.Serialize(query), }) if sspan != nil { - sspan.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) sspan.RecordError(err) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetStatus(trace.StatusError, err.Error()) } mu.Lock() if errs == nil { @@ -935,8 +963,9 @@ func (s *server) MultiSearchByID(ctx context.Context, reqs *payload.Search_Multi ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -967,8 +996,9 @@ func (s *server) LinearSearch(ctx context.Context, req *payload.Search_Request) }, }) if span != nil { - span.SetStatus(trace.StatusCodeInvalidArgument(err.Error())) span.RecordError(err) + span.SetAttributes(trace.StatusCodeInvalidArgument(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -998,8 +1028,9 @@ func (s *server) LinearSearch(ctx context.Context, req *payload.Search_Request) ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }, info.Get()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -1031,8 +1062,9 @@ func (s *server) LinearSearchByID(ctx context.Context, req *payload.Search_IDReq }, }) if span != nil { - span.SetStatus(trace.StatusCodeInvalidArgument(err.Error())) span.RecordError(err) + span.SetAttributes(trace.StatusCodeInvalidArgument(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -1083,8 +1115,9 @@ func (s *server) LinearSearchByID(ctx context.Context, req *payload.Search_IDReq ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, errors.Wrap(err, serr.Error()) } @@ -1119,8 +1152,9 @@ func (s *server) LinearSearchByID(ctx context.Context, req *payload.Search_IDReq }) err = errors.Wrap(err, serr.Error()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -1148,8 +1182,9 @@ func (s *server) StreamLinearSearch(stream vald.Search_StreamLinearSearchServer) if err != nil { st, msg, err := status.ParseError(err, codes.Internal, "failed to parse LinearSearch gRPC error response") if sspan != nil { - sspan.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) sspan.RecordError(err) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Search_StreamResponse{ Payload: &payload.Search_StreamResponse_Status{ @@ -1168,8 +1203,9 @@ func (s *server) StreamLinearSearch(stream vald.Search_StreamLinearSearchServer) st, msg, err := status.ParseError(err, codes.Internal, "failed to parse StreamLinearSearch gRPC error response") if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return err } @@ -1197,8 +1233,9 @@ func (s *server) StreamLinearSearchByID(stream vald.Search_StreamLinearSearchByI if err != nil { st, msg, err := status.ParseError(err, codes.Internal, "failed to parse LinearSearchByID gRPC error response") if sspan != nil { - sspan.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) sspan.RecordError(err) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Search_StreamResponse{ Payload: &payload.Search_StreamResponse_Status{ @@ -1217,8 +1254,9 @@ func (s *server) StreamLinearSearchByID(stream vald.Search_StreamLinearSearchByI st, msg, err := status.ParseError(err, codes.Internal, "failed to parse StreamLinearSearchByID gRPC error response") if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return err } @@ -1259,8 +1297,9 @@ func (s *server) MultiLinearSearch(ctx context.Context, reqs *payload.Search_Mul }, }, info.Get()) if span != nil { - span.SetStatus(trace.StatusCodeInvalidArgument(err.Error())) span.RecordError(err) + span.SetAttributes(trace.StatusCodeInvalidArgument(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -1281,8 +1320,9 @@ func (s *server) MultiLinearSearch(ctx context.Context, reqs *payload.Search_Mul ServingData: errdetails.Serialize(query), }) if sspan != nil { - sspan.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) sspan.RecordError(err) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetStatus(trace.StatusError, err.Error()) } mu.Lock() if errs == nil { @@ -1309,8 +1349,9 @@ func (s *server) MultiLinearSearch(ctx context.Context, reqs *payload.Search_Mul ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -1352,8 +1393,9 @@ func (s *server) MultiLinearSearchByID(ctx context.Context, reqs *payload.Search ServingData: errdetails.Serialize(query), }) if sspan != nil { - sspan.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) sspan.RecordError(err) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetStatus(trace.StatusError, err.Error()) } mu.Lock() if errs == nil { @@ -1381,8 +1423,9 @@ func (s *server) MultiLinearSearchByID(ctx context.Context, reqs *payload.Search ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -1416,8 +1459,9 @@ func (s *server) Insert(ctx context.Context, req *payload.Insert_Request) (ce *p ResourceName: fmt.Sprintf("%s: %s(%s)", apiName, s.name, s.ip), }) if span != nil { - span.SetStatus(trace.StatusCodeInvalidArgument(err.Error())) span.RecordError(err) + span.SetAttributes(trace.StatusCodeInvalidArgument(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -1439,8 +1483,9 @@ func (s *server) Insert(ctx context.Context, req *payload.Insert_Request) (ce *p }, }, info.Get()) if span != nil { - span.SetStatus(trace.StatusCodeInvalidArgument(err.Error())) span.RecordError(err) + span.SetAttributes(trace.StatusCodeInvalidArgument(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -1463,8 +1508,9 @@ func (s *server) Insert(ctx context.Context, req *payload.Insert_Request) (ce *p ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }, info.Get()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -1505,21 +1551,23 @@ func (s *server) Insert(ctx context.Context, req *payload.Insert_Request) (ce *p case errors.Is(err, context.Canceled), errors.Is(err, errors.ErrRPCCallFailed(target, context.Canceled)): if span != nil { - span.SetStatus(trace.StatusCodeCancelled( + span.RecordError(err) + span.SetAttributes(trace.StatusCodeCancelled( errdetails.ValdGRPCResourceTypePrefix + "/vald.v1.Insert.DoMulti/" + - target + " canceled: " + err.Error())) - span.RecordError(err) + target + " canceled: " + err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil case errors.Is(err, context.DeadlineExceeded), errors.Is(err, errors.ErrRPCCallFailed(target, context.DeadlineExceeded)): if span != nil { - span.SetStatus(trace.StatusCodeDeadlineExceeded( + span.RecordError(err) + span.SetAttributes(trace.StatusCodeDeadlineExceeded( errdetails.ValdGRPCResourceTypePrefix + "/vald.v1.Insert.DoMulti/" + - target + " deadline_exceeded: " + err.Error())) - span.RecordError(err) + target + " deadline_exceeded: " + err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil } @@ -1534,8 +1582,9 @@ func (s *server) Insert(ctx context.Context, req *payload.Insert_Request) (ce *p ResourceName: fmt.Sprintf("%s: %s(%s) to %s", apiName, s.name, s.ip, target), }) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } if err != nil && st.Code() != codes.AlreadyExists { emu.Lock() @@ -1574,8 +1623,9 @@ func (s *server) Insert(ctx context.Context, req *payload.Insert_Request) (ce *p ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }, info.Get()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -1604,8 +1654,9 @@ func (s *server) StreamInsert(stream vald.Insert_StreamInsertServer) (err error) if err != nil { st, msg, err := status.ParseError(err, codes.Internal, "failed to parse Insert gRPC error response") if sspan != nil { - sspan.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) sspan.RecordError(err) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Object_StreamLocation{ Payload: &payload.Object_StreamLocation_Status{ @@ -1623,8 +1674,9 @@ func (s *server) StreamInsert(stream vald.Insert_StreamInsertServer) (err error) if err != nil { st, msg, err := status.ParseError(err, codes.Internal, "failed to parse StreamInsert gRPC error response") if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return err } @@ -1661,8 +1713,9 @@ func (s *server) MultiInsert(ctx context.Context, reqs *payload.Insert_MultiRequ }, }, info.Get()) if span != nil { - span.SetStatus(trace.StatusCodeInvalidArgument(err.Error())) span.RecordError(err) + span.SetAttributes(trace.StatusCodeInvalidArgument(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -1685,8 +1738,9 @@ func (s *server) MultiInsert(ctx context.Context, reqs *payload.Insert_MultiRequ ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }, info.Get()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -1728,21 +1782,23 @@ func (s *server) MultiInsert(ctx context.Context, reqs *payload.Insert_MultiRequ case errors.Is(err, context.Canceled), errors.Is(err, errors.ErrRPCCallFailed(target, context.Canceled)): if span != nil { - span.SetStatus(trace.StatusCodeCancelled( + span.RecordError(err) + span.SetAttributes(trace.StatusCodeCancelled( errdetails.ValdGRPCResourceTypePrefix + "/vald.v1.MultiInsert.DoMulti/" + - target + " canceled: " + err.Error())) - span.RecordError(err) + target + " canceled: " + err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil case errors.Is(err, context.DeadlineExceeded), errors.Is(err, errors.ErrRPCCallFailed(target, context.DeadlineExceeded)): if span != nil { - span.SetStatus(trace.StatusCodeDeadlineExceeded( + span.RecordError(err) + span.SetAttributes(trace.StatusCodeDeadlineExceeded( errdetails.ValdGRPCResourceTypePrefix + "/vald.v1.MultiInsert.DoMulti/" + - target + " deadline_exceeded: " + err.Error())) - span.RecordError(err) + target + " deadline_exceeded: " + err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil } @@ -1757,8 +1813,9 @@ func (s *server) MultiInsert(ctx context.Context, reqs *payload.Insert_MultiRequ ResourceName: fmt.Sprintf("%s: %s(%s) to %s", apiName, s.name, s.ip, target), }) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } if err != nil { @@ -1797,8 +1854,9 @@ func (s *server) MultiInsert(ctx context.Context, reqs *payload.Insert_MultiRequ ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }, info.Get()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -1832,8 +1890,9 @@ func (s *server) Update(ctx context.Context, req *payload.Update_Request) (res * ResourceName: fmt.Sprintf("%s: %s(%s)", apiName, s.name, s.ip), }) if span != nil { - span.SetStatus(trace.StatusCodeInvalidArgument(err.Error())) span.RecordError(err) + span.SetAttributes(trace.StatusCodeInvalidArgument(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -1855,8 +1914,9 @@ func (s *server) Update(ctx context.Context, req *payload.Update_Request) (res * }, }, info.Get()) if span != nil { - span.SetStatus(trace.StatusCodeInvalidArgument(err.Error())) span.RecordError(err) + span.SetAttributes(trace.StatusCodeInvalidArgument(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -1882,8 +1942,9 @@ func (s *server) Update(ctx context.Context, req *payload.Update_Request) (res * ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }, info.Get()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -1902,8 +1963,9 @@ func (s *server) Update(ctx context.Context, req *payload.Update_Request) (res * ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }, info.Get()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -1942,8 +2004,9 @@ func (s *server) Update(ctx context.Context, req *payload.Update_Request) (res * ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }, info.Get()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -1969,8 +2032,9 @@ func (s *server) Update(ctx context.Context, req *payload.Update_Request) (res * ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }, info.Get()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err @@ -1999,8 +2063,9 @@ func (s *server) StreamUpdate(stream vald.Update_StreamUpdateServer) (err error) if err != nil { st, msg, err := status.ParseError(err, codes.Internal, "failed to parse Update gRPC error response") if sspan != nil { - sspan.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) sspan.RecordError(err) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Object_StreamLocation{ Payload: &payload.Object_StreamLocation_Status{ @@ -2018,8 +2083,9 @@ func (s *server) StreamUpdate(stream vald.Update_StreamUpdateServer) (err error) if err != nil { st, msg, err := status.ParseError(err, codes.Internal, "failed to parse StreamUpdate gRPC error response") if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return err } @@ -2056,8 +2122,9 @@ func (s *server) MultiUpdate(ctx context.Context, reqs *payload.Update_MultiRequ }, }, info.Get()) if span != nil { - span.SetStatus(trace.StatusCodeInvalidArgument(err.Error())) span.RecordError(err) + span.SetAttributes(trace.StatusCodeInvalidArgument(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -2083,8 +2150,9 @@ func (s *server) MultiUpdate(ctx context.Context, reqs *payload.Update_MultiRequ ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }, info.Get()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -2139,8 +2207,9 @@ func (s *server) MultiUpdate(ctx context.Context, reqs *payload.Update_MultiRequ ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }, info.Get()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -2160,8 +2229,9 @@ func (s *server) MultiUpdate(ctx context.Context, reqs *payload.Update_MultiRequ ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }, info.Get()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -2197,8 +2267,9 @@ func (s *server) Upsert(ctx context.Context, req *payload.Upsert_Request) (loc * ResourceName: fmt.Sprintf("%s: %s(%s)", apiName, s.name, s.ip), }) if span != nil { - span.SetStatus(trace.StatusCodeInvalidArgument(err.Error())) span.RecordError(err) + span.SetAttributes(trace.StatusCodeInvalidArgument(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -2220,8 +2291,9 @@ func (s *server) Upsert(ctx context.Context, req *payload.Upsert_Request) (loc * }, }, info.Get()) if span != nil { - span.SetStatus(trace.StatusCodeInvalidArgument(err.Error())) span.RecordError(err) + span.SetAttributes(trace.StatusCodeInvalidArgument(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -2249,8 +2321,9 @@ func (s *server) Upsert(ctx context.Context, req *payload.Upsert_Request) (loc * ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }, info.Get()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -2296,8 +2369,9 @@ func (s *server) Upsert(ctx context.Context, req *payload.Upsert_Request) (loc * ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }, info.Get()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -2325,8 +2399,9 @@ func (s *server) StreamUpsert(stream vald.Upsert_StreamUpsertServer) (err error) if err != nil { st, msg, err := status.ParseError(err, codes.Internal, "failed to parse Upsert gRPC error response") if sspan != nil { - sspan.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) sspan.RecordError(err) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Object_StreamLocation{ Payload: &payload.Object_StreamLocation_Status{ @@ -2344,8 +2419,9 @@ func (s *server) StreamUpsert(stream vald.Upsert_StreamUpsertServer) (err error) if err != nil { st, msg, err := status.ParseError(err, codes.Internal, "failed to parse StreamUpdate gRPC error response") if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return err } @@ -2384,8 +2460,9 @@ func (s *server) MultiUpsert(ctx context.Context, reqs *payload.Upsert_MultiRequ }, }, info.Get()) if span != nil { - span.SetStatus(trace.StatusCodeInvalidArgument(err.Error())) span.RecordError(err) + span.SetAttributes(trace.StatusCodeInvalidArgument(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -2513,8 +2590,9 @@ func (s *server) MultiUpsert(ctx context.Context, reqs *payload.Upsert_MultiRequ ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }, info.Get()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -2547,8 +2625,9 @@ func (s *server) Remove(ctx context.Context, req *payload.Remove_Request) (locs ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }, info.Get()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -2593,8 +2672,9 @@ func (s *server) Remove(ctx context.Context, req *payload.Remove_Request) (locs ResourceName: fmt.Sprintf("%s: %s(%s) to %s", apiName, s.name, s.ip, target), }) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } if err != nil && st.Code() != codes.NotFound { log.Error(err) @@ -2620,8 +2700,9 @@ func (s *server) Remove(ctx context.Context, req *payload.Remove_Request) (locs ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }, info.Get()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -2637,8 +2718,9 @@ func (s *server) Remove(ctx context.Context, req *payload.Remove_Request) (locs ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }) if span != nil { - span.SetStatus(trace.StatusCodeNotFound(err.Error())) span.RecordError(err) + span.SetAttributes(trace.StatusCodeNotFound(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -2666,8 +2748,9 @@ func (s *server) StreamRemove(stream vald.Remove_StreamRemoveServer) (err error) if err != nil { st, msg, err := status.ParseError(err, codes.Internal, "failed to parse Remove gRPC error response") if sspan != nil { - sspan.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) sspan.RecordError(err) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Object_StreamLocation{ Payload: &payload.Object_StreamLocation_Status{ @@ -2685,8 +2768,9 @@ func (s *server) StreamRemove(stream vald.Remove_StreamRemoveServer) (err error) if err != nil { st, msg, err := status.ParseError(err, codes.Internal, "failed to parse StreamRemove gRPC error response") if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return err } @@ -2723,8 +2807,9 @@ func (s *server) MultiRemove(ctx context.Context, reqs *payload.Remove_MultiRequ ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }, info.Get()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -2762,21 +2847,23 @@ func (s *server) MultiRemove(ctx context.Context, reqs *payload.Remove_MultiRequ case errors.Is(err, context.Canceled), errors.Is(err, errors.ErrRPCCallFailed(target, context.Canceled)): if span != nil { - span.SetStatus(trace.StatusCodeCancelled( + span.RecordError(err) + span.SetAttributes(trace.StatusCodeCancelled( errdetails.ValdGRPCResourceTypePrefix + "/vald.v1.MultiRemove.BroadCast/" + - target + " canceled: " + err.Error())) - span.RecordError(err) + target + " canceled: " + err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil case errors.Is(err, context.DeadlineExceeded), errors.Is(err, errors.ErrRPCCallFailed(target, context.DeadlineExceeded)): if span != nil { - span.SetStatus(trace.StatusCodeDeadlineExceeded( + span.RecordError(err) + span.SetAttributes(trace.StatusCodeDeadlineExceeded( errdetails.ValdGRPCResourceTypePrefix + "/vald.v1.MultiRemove.BroadCast/" + - target + " deadline_exceeded: " + err.Error())) - span.RecordError(err) + target + " deadline_exceeded: " + err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil } @@ -2791,8 +2878,9 @@ func (s *server) MultiRemove(ctx context.Context, reqs *payload.Remove_MultiRequ ResourceName: fmt.Sprintf("%s: %s(%s) to %s", apiName, s.name, s.ip, target), }) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } if err != nil && st.Code() != codes.NotFound { @@ -2818,8 +2906,9 @@ func (s *server) MultiRemove(ctx context.Context, reqs *payload.Remove_MultiRequ ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }, info.Get()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -2835,8 +2924,9 @@ func (s *server) MultiRemove(ctx context.Context, reqs *payload.Remove_MultiRequ ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }) if span != nil { - span.SetStatus(trace.StatusCodeNotFound(err.Error())) span.RecordError(err) + span.SetAttributes(trace.StatusCodeNotFound(err.Error())...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -2871,21 +2961,23 @@ func (s *server) GetObject(ctx context.Context, req *payload.Object_VectorReques case errors.Is(err, context.Canceled), errors.Is(err, errors.ErrRPCCallFailed(target, context.Canceled)): if sspan != nil { - sspan.SetStatus(trace.StatusCodeCancelled( + sspan.RecordError(err) + sspan.SetAttributes(trace.StatusCodeCancelled( errdetails.ValdGRPCResourceTypePrefix + "/vald.v1.GetObject.BroadCast/" + - target + " canceled: " + err.Error())) - sspan.RecordError(err) + target + " canceled: " + err.Error())...) + sspan.SetStatus(trace.StatusError, err.Error()) } return nil case errors.Is(err, context.DeadlineExceeded), errors.Is(err, errors.ErrRPCCallFailed(target, context.DeadlineExceeded)): if sspan != nil { - sspan.SetStatus(trace.StatusCodeDeadlineExceeded( + sspan.RecordError(err) + sspan.SetAttributes(trace.StatusCodeDeadlineExceeded( errdetails.ValdGRPCResourceTypePrefix + "/vald.v1.GetObject.BroadCast/" + - target + " deadline_exceeded: " + err.Error())) - sspan.RecordError(err) + target + " deadline_exceeded: " + err.Error())...) + sspan.SetStatus(trace.StatusError, err.Error()) } return nil } @@ -2901,8 +2993,9 @@ func (s *server) GetObject(ctx context.Context, req *payload.Object_VectorReques ResourceName: fmt.Sprintf("%s: %s(%s) to %s", apiName, s.name, s.ip, target), }, info.Get()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } if err != nil && st.Code() != codes.NotFound { return err @@ -2938,8 +3031,9 @@ func (s *server) GetObject(ctx context.Context, req *payload.Object_VectorReques ResourceName: fmt.Sprintf("%s: %s(%s) to %v", apiName, s.name, s.ip, s.gateway.Addrs(ctx)), }, info.Get()) if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) } return nil, err } @@ -2967,8 +3061,9 @@ func (s *server) StreamGetObject(stream vald.Object_StreamGetObjectServer) (err if err != nil { st, msg, err := status.ParseError(err, codes.Internal, "failed to parse GetObject gRPC error response") if sspan != nil { - sspan.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) sspan.RecordError(err) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Object_StreamVector{ Payload: &payload.Object_StreamVector_Status{ @@ -2986,8 +3081,10 @@ func (s *server) StreamGetObject(stream vald.Object_StreamGetObjectServer) (err if err != nil { st, msg, err := status.ParseError(err, codes.Internal, "failed to parse StreamGetObject gRPC error response") if span != nil { - span.SetStatus(trace.FromGRPCStatus(st.Code(), msg)) span.RecordError(err) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetStatus(trace.StatusError, err.Error()) + } return err }