From b9cb6a24c5755015d8fa144e05d48d5bc538826a Mon Sep 17 00:00:00 2001 From: datelier <57349093+datelier@users.noreply.github.com> Date: Wed, 2 Oct 2024 15:55:10 +0900 Subject: [PATCH 1/6] modify ParseError to FromError --- pkg/agent/core/ngt/handler/grpc/insert.go | 12 +-- .../core/ngt/handler/grpc/linear_search.go | 77 ++++++------------- pkg/agent/core/ngt/handler/grpc/object.go | 12 +-- pkg/agent/core/ngt/handler/grpc/remove.go | 27 +++---- pkg/agent/core/ngt/handler/grpc/search.go | 77 ++++++------------- pkg/agent/core/ngt/handler/grpc/update.go | 12 +-- pkg/agent/core/ngt/handler/grpc/upsert.go | 27 +++---- 7 files changed, 84 insertions(+), 160 deletions(-) diff --git a/pkg/agent/core/ngt/handler/grpc/insert.go b/pkg/agent/core/ngt/handler/grpc/insert.go index 3e982dbaf1..6709f755eb 100644 --- a/pkg/agent/core/ngt/handler/grpc/insert.go +++ b/pkg/agent/core/ngt/handler/grpc/insert.go @@ -162,10 +162,10 @@ func (s *server) StreamInsert(stream vald.Insert_StreamInsertServer) (err error) }() res, err := s.Insert(ctx, req) if err != nil { - st, msg, err := status.ParseError(err, codes.Internal, "failed to parse Insert gRPC error response") - if sspan != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Object_StreamLocation{ @@ -181,10 +181,10 @@ func (s *server) StreamInsert(stream vald.Insert_StreamInsertServer) (err error) }, nil }) if err != nil { - st, msg, err := status.ParseError(err, codes.Internal, "failed to parse StreamInsert gRPC error response") - if span != nil { + st, _ = status.FromError(err) + if st != nil && span != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) span.SetStatus(trace.StatusError, err.Error()) } return err diff --git a/pkg/agent/core/ngt/handler/grpc/linear_search.go b/pkg/agent/core/ngt/handler/grpc/linear_search.go index 1c13861428..daaef46ad7 100644 --- a/pkg/agent/core/ngt/handler/grpc/linear_search.go +++ b/pkg/agent/core/ngt/handler/grpc/linear_search.go @@ -344,10 +344,10 @@ func (s *server) StreamLinearSearch(stream vald.Search_StreamLinearSearchServer) }() res, err := s.LinearSearch(ctx, req) if err != nil { - st, msg, err := status.ParseError(err, codes.Internal, "failed to parse LinearSearch gRPC error response") - if sspan != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Search_StreamResponse{ @@ -363,11 +363,10 @@ func (s *server) StreamLinearSearch(stream vald.Search_StreamLinearSearchServer) }, nil }) if err != nil { - st, msg, err := status.ParseError(err, codes.Internal, - "failed to parse StreamLinearSearch gRPC error response") - if span != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) span.SetStatus(trace.StatusError, err.Error()) } return err @@ -394,10 +393,10 @@ func (s *server) StreamLinearSearchByID( }() res, err := s.LinearSearchByID(ctx, req) if err != nil { - st, msg, err := status.ParseError(err, codes.Internal, "failed to parse LinearSearchByID gRPC error response") - if sspan != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Search_StreamResponse{ @@ -413,10 +412,10 @@ func (s *server) StreamLinearSearchByID( }, nil }) if err != nil { - st, msg, err := status.ParseError(err, codes.Internal, "failed to parse StreamLinearSearchByID gRPC error response") - if span != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) span.SetStatus(trace.StatusError, err.Error()) } return err @@ -454,15 +453,10 @@ func (s *server) MultiLinearSearch( }() r, err := s.LinearSearch(ctx, query) if err != nil { - st, msg, err := status.ParseError(err, codes.Internal, - "failed to parse LinearSearch gRPC error response", - &errdetails.RequestInfo{ - RequestId: query.GetConfig().GetRequestId(), - ServingData: errdetails.Serialize(query), - }) - if sspan != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) sspan.SetStatus(trace.StatusError, err.Error()) } mu.Lock() @@ -480,19 +474,10 @@ func (s *server) MultiLinearSearch( } wg.Wait() if errs != nil { - st, msg, err := status.ParseError(errs, codes.Internal, - "failed to parse MultiLinearSearch gRPC error response", - &errdetails.RequestInfo{ - RequestId: strings.Join(rids, ","), - ServingData: errdetails.Serialize(reqs), - }, - &errdetails.ResourceInfo{ - ResourceType: ngtResourceType + "/ngt.MultiLinearSearch", - ResourceName: fmt.Sprintf("%s: %s(%s)", apiName, s.name, s.ip), - }) - if span != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) span.SetStatus(trace.StatusError, err.Error()) } return nil, err @@ -530,15 +515,10 @@ func (s *server) MultiLinearSearchByID( defer wg.Done() r, err := s.LinearSearchByID(ctx, query) if err != nil { - st, msg, err := status.ParseError(err, codes.Internal, - "failed to parse LinearSearchByID gRPC error response", - &errdetails.RequestInfo{ - RequestId: query.GetConfig().GetRequestId(), - ServingData: errdetails.Serialize(query), - }) - if sspan != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) sspan.SetStatus(trace.StatusError, err.Error()) } mu.Lock() @@ -556,19 +536,10 @@ func (s *server) MultiLinearSearchByID( } wg.Wait() if errs != nil { - st, msg, err := status.ParseError(errs, codes.Internal, - "failed to parse MultiLinearSearchByID gRPC error response", - &errdetails.RequestInfo{ - RequestId: strings.Join(rids, ","), - ServingData: errdetails.Serialize(reqs), - }, - &errdetails.ResourceInfo{ - ResourceType: ngtResourceType + "/ngt.MultiLinearSearchByID", - ResourceName: fmt.Sprintf("%s: %s(%s)", apiName, s.name, s.ip), - }) - if span != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) span.SetStatus(trace.StatusError, err.Error()) } return nil, err diff --git a/pkg/agent/core/ngt/handler/grpc/object.go b/pkg/agent/core/ngt/handler/grpc/object.go index e55c19963b..cd72fc96d0 100644 --- a/pkg/agent/core/ngt/handler/grpc/object.go +++ b/pkg/agent/core/ngt/handler/grpc/object.go @@ -151,10 +151,10 @@ func (s *server) StreamGetObject(stream vald.Object_StreamGetObjectServer) (err }() res, err := s.GetObject(ctx, req) if err != nil { - st, msg, err := status.ParseError(err, codes.Internal, "failed to parse GetObject gRPC error response") - if sspan != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Object_StreamVector{ @@ -170,10 +170,10 @@ func (s *server) StreamGetObject(stream vald.Object_StreamGetObjectServer) (err }, nil }) if err != nil { - st, msg, err := status.ParseError(err, codes.Internal, "failed to parse StreamGetObject gRPC error response") - if span != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) span.SetStatus(trace.StatusError, err.Error()) } diff --git a/pkg/agent/core/ngt/handler/grpc/remove.go b/pkg/agent/core/ngt/handler/grpc/remove.go index b246b2434c..e4c6f9b10e 100644 --- a/pkg/agent/core/ngt/handler/grpc/remove.go +++ b/pkg/agent/core/ngt/handler/grpc/remove.go @@ -157,10 +157,10 @@ func (s *server) StreamRemove(stream vald.Remove_StreamRemoveServer) (err error) }() res, err := s.Remove(ctx, req) if err != nil { - st, msg, err := status.ParseError(err, codes.Internal, "failed to parse Remove gRPC error response") - if sspan != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Object_StreamLocation{ @@ -176,10 +176,10 @@ func (s *server) StreamRemove(stream vald.Remove_StreamRemoveServer) (err error) }, nil }) if err != nil { - st, msg, err := status.ParseError(err, codes.Internal, "failed to parse StreamRemove gRPC error response") - if span != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) span.SetStatus(trace.StatusError, err.Error()) } return err @@ -314,20 +314,11 @@ func (s *server) RemoveByTimestamp( return true }) if errs != nil { - st, msg, err := status.ParseError(errs, codes.Internal, - "failed to parse "+vald.RemoveByTimestampRPCName+" gRPC error response", - &errdetails.RequestInfo{ - ServingData: errdetails.Serialize(req), - }, - &errdetails.ResourceInfo{ - ResourceType: ngtResourceType + "/ngt.Remove", - ResourceName: fmt.Sprintf("%s: %s(%s)", apiName, s.name, s.ip), - }, - ) + st, _ = status.FromError(err) log.Error(err) - if span != nil { + if st != nil && span != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) span.SetStatus(trace.StatusError, err.Error()) } return nil, err diff --git a/pkg/agent/core/ngt/handler/grpc/search.go b/pkg/agent/core/ngt/handler/grpc/search.go index 6543fd9ced..81b6831379 100644 --- a/pkg/agent/core/ngt/handler/grpc/search.go +++ b/pkg/agent/core/ngt/handler/grpc/search.go @@ -348,10 +348,10 @@ func (s *server) StreamSearch(stream vald.Search_StreamSearchServer) (err error) }() res, err := s.Search(ctx, req) if err != nil { - st, msg, err := status.ParseError(err, codes.Internal, "failed to parse Search gRPC error response") - if sspan != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Search_StreamResponse{ @@ -367,11 +367,10 @@ func (s *server) StreamSearch(stream vald.Search_StreamSearchServer) (err error) }, nil }) if err != nil { - st, msg, err := status.ParseError(err, codes.Internal, - "failed to parse StreamSearch gRPC error response") - if span != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) span.SetStatus(trace.StatusError, err.Error()) } return err @@ -396,10 +395,10 @@ func (s *server) StreamSearchByID(stream vald.Search_StreamSearchByIDServer) (er }() res, err := s.SearchByID(ctx, req) if err != nil { - st, msg, err := status.ParseError(err, codes.Internal, "failed to parse SearchByID gRPC error response") - if sspan != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Search_StreamResponse{ @@ -415,10 +414,10 @@ func (s *server) StreamSearchByID(stream vald.Search_StreamSearchByIDServer) (er }, nil }) if err != nil { - st, msg, err := status.ParseError(err, codes.Internal, "failed to parse StreamSearchByID gRPC error response") - if span != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) span.SetStatus(trace.StatusError, err.Error()) } return err @@ -456,15 +455,10 @@ func (s *server) MultiSearch( }() r, err := s.Search(ctx, query) if err != nil { - st, msg, err := status.ParseError(err, codes.Internal, - "failed to parse Search gRPC error response", - &errdetails.RequestInfo{ - RequestId: query.GetConfig().GetRequestId(), - ServingData: errdetails.Serialize(query), - }) - if sspan != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) sspan.SetStatus(trace.StatusError, err.Error()) } mu.Lock() @@ -482,19 +476,10 @@ func (s *server) MultiSearch( } wg.Wait() if errs != nil { - st, msg, err := status.ParseError(errs, codes.Internal, - "failed to parse MultiSearch gRPC error response", - &errdetails.RequestInfo{ - RequestId: strings.Join(rids, ","), - ServingData: errdetails.Serialize(reqs), - }, - &errdetails.ResourceInfo{ - ResourceType: ngtResourceType + "/ngt.MultiSearch", - ResourceName: fmt.Sprintf("%s: %s(%s)", apiName, s.name, s.ip), - }) - if span != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) span.SetStatus(trace.StatusError, err.Error()) } return nil, err @@ -532,15 +517,10 @@ func (s *server) MultiSearchByID( defer wg.Done() r, err := s.SearchByID(ctx, query) if err != nil { - st, msg, err := status.ParseError(err, codes.Internal, - "failed to parse SearchByID gRPC error response", - &errdetails.RequestInfo{ - RequestId: query.GetConfig().GetRequestId(), - ServingData: errdetails.Serialize(query), - }) - if sspan != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) sspan.SetStatus(trace.StatusError, err.Error()) } mu.Lock() @@ -558,19 +538,10 @@ func (s *server) MultiSearchByID( } wg.Wait() if errs != nil { - st, msg, err := status.ParseError(errs, codes.Internal, - "failed to parse MultiSearchByID gRPC error response", - &errdetails.RequestInfo{ - RequestId: strings.Join(rids, ","), - ServingData: errdetails.Serialize(reqs), - }, - &errdetails.ResourceInfo{ - ResourceType: ngtResourceType + "/ngt.MultiSearchByID", - ResourceName: fmt.Sprintf("%s: %s(%s)", apiName, s.name, s.ip), - }) - if span != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) span.SetStatus(trace.StatusError, err.Error()) } return nil, err diff --git a/pkg/agent/core/ngt/handler/grpc/update.go b/pkg/agent/core/ngt/handler/grpc/update.go index 04508938e2..8b45ce59da 100644 --- a/pkg/agent/core/ngt/handler/grpc/update.go +++ b/pkg/agent/core/ngt/handler/grpc/update.go @@ -191,10 +191,10 @@ func (s *server) StreamUpdate(stream vald.Update_StreamUpdateServer) (err error) }() res, err := s.Update(ctx, req) if err != nil { - st, msg, err := status.ParseError(err, codes.Internal, "failed to parse Update gRPC error response") - if sspan != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Object_StreamLocation{ @@ -210,10 +210,10 @@ func (s *server) StreamUpdate(stream vald.Update_StreamUpdateServer) (err error) }, nil }) if err != nil { - st, msg, err := status.ParseError(err, codes.Internal, "failed to parse StreamUpdate gRPC error response") - if span != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) span.SetStatus(trace.StatusError, err.Error()) } return err diff --git a/pkg/agent/core/ngt/handler/grpc/upsert.go b/pkg/agent/core/ngt/handler/grpc/upsert.go index 9bf49a2ea4..a69ee241a6 100644 --- a/pkg/agent/core/ngt/handler/grpc/upsert.go +++ b/pkg/agent/core/ngt/handler/grpc/upsert.go @@ -152,10 +152,10 @@ func (s *server) StreamUpsert(stream vald.Upsert_StreamUpsertServer) (err error) }() res, err := s.Upsert(ctx, req) if err != nil { - st, msg, err := status.ParseError(err, codes.Internal, "failed to parse Upsert gRPC error response") - if sspan != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Object_StreamLocation{ @@ -171,10 +171,10 @@ func (s *server) StreamUpsert(stream vald.Upsert_StreamUpsertServer) (err error) }, nil }) if err != nil { - st, msg, err := status.ParseError(err, codes.Internal, "failed to parse StreamUpsert gRPC error response") - if span != nil { + st, _ = status.FromError(err) + if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) span.SetStatus(trace.StatusError, err.Error()) } return err @@ -318,19 +318,10 @@ func (s *server) MultiUpsert( } if err != nil { - st, msg, err := status.ParseError(err, codes.Internal, - "failed to parse MultiUpsert gRPC error response", - &errdetails.RequestInfo{ - RequestId: strings.Join(ids, ","), - ServingData: errdetails.Serialize(reqs), - }, - &errdetails.ResourceInfo{ - ResourceType: ngtResourceType + "/ngt.MultiUpsert", - ResourceName: fmt.Sprintf("%s: %s(%s)", apiName, s.name, s.ip), - }, info.Get()) - if span != nil { + st, _ = status.FromError(err) + if st != nil && span != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), msg)...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) span.SetStatus(trace.StatusError, err.Error()) } return nil, err From 4d1422185e7c203a7b63ad0d9cd85cee083e231b Mon Sep 17 00:00:00 2001 From: datelier <57349093+datelier@users.noreply.github.com> Date: Wed, 2 Oct 2024 16:28:27 +0900 Subject: [PATCH 2/6] fix typo --- pkg/agent/core/ngt/handler/grpc/insert.go | 8 ++--- .../core/ngt/handler/grpc/linear_search.go | 32 +++++++++---------- pkg/agent/core/ngt/handler/grpc/object.go | 8 ++--- pkg/agent/core/ngt/handler/grpc/remove.go | 12 +++---- pkg/agent/core/ngt/handler/grpc/search.go | 32 +++++++++---------- pkg/agent/core/ngt/handler/grpc/update.go | 8 ++--- pkg/agent/core/ngt/handler/grpc/upsert.go | 12 +++---- 7 files changed, 56 insertions(+), 56 deletions(-) diff --git a/pkg/agent/core/ngt/handler/grpc/insert.go b/pkg/agent/core/ngt/handler/grpc/insert.go index 6709f755eb..1793678650 100644 --- a/pkg/agent/core/ngt/handler/grpc/insert.go +++ b/pkg/agent/core/ngt/handler/grpc/insert.go @@ -162,10 +162,10 @@ func (s *server) StreamInsert(stream vald.Insert_StreamInsertServer) (err error) }() res, err := s.Insert(ctx, req) if err != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Object_StreamLocation{ @@ -181,10 +181,10 @@ func (s *server) StreamInsert(stream vald.Insert_StreamInsertServer) (err error) }, nil }) if err != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && span != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) } return err diff --git a/pkg/agent/core/ngt/handler/grpc/linear_search.go b/pkg/agent/core/ngt/handler/grpc/linear_search.go index daaef46ad7..cad8947920 100644 --- a/pkg/agent/core/ngt/handler/grpc/linear_search.go +++ b/pkg/agent/core/ngt/handler/grpc/linear_search.go @@ -344,10 +344,10 @@ func (s *server) StreamLinearSearch(stream vald.Search_StreamLinearSearchServer) }() res, err := s.LinearSearch(ctx, req) if err != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Search_StreamResponse{ @@ -363,10 +363,10 @@ func (s *server) StreamLinearSearch(stream vald.Search_StreamLinearSearchServer) }, nil }) if err != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) } return err @@ -393,10 +393,10 @@ func (s *server) StreamLinearSearchByID( }() res, err := s.LinearSearchByID(ctx, req) if err != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Search_StreamResponse{ @@ -412,10 +412,10 @@ func (s *server) StreamLinearSearchByID( }, nil }) if err != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) } return err @@ -453,10 +453,10 @@ func (s *server) MultiLinearSearch( }() r, err := s.LinearSearch(ctx, query) if err != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) sspan.SetStatus(trace.StatusError, err.Error()) } mu.Lock() @@ -474,10 +474,10 @@ func (s *server) MultiLinearSearch( } wg.Wait() if errs != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) } return nil, err @@ -515,10 +515,10 @@ func (s *server) MultiLinearSearchByID( defer wg.Done() r, err := s.LinearSearchByID(ctx, query) if err != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) sspan.SetStatus(trace.StatusError, err.Error()) } mu.Lock() @@ -536,10 +536,10 @@ func (s *server) MultiLinearSearchByID( } wg.Wait() if errs != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) } return nil, err diff --git a/pkg/agent/core/ngt/handler/grpc/object.go b/pkg/agent/core/ngt/handler/grpc/object.go index cd72fc96d0..9ab12ce889 100644 --- a/pkg/agent/core/ngt/handler/grpc/object.go +++ b/pkg/agent/core/ngt/handler/grpc/object.go @@ -151,10 +151,10 @@ func (s *server) StreamGetObject(stream vald.Object_StreamGetObjectServer) (err }() res, err := s.GetObject(ctx, req) if err != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Object_StreamVector{ @@ -170,10 +170,10 @@ func (s *server) StreamGetObject(stream vald.Object_StreamGetObjectServer) (err }, nil }) if err != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) } diff --git a/pkg/agent/core/ngt/handler/grpc/remove.go b/pkg/agent/core/ngt/handler/grpc/remove.go index e4c6f9b10e..3c3b5b75c8 100644 --- a/pkg/agent/core/ngt/handler/grpc/remove.go +++ b/pkg/agent/core/ngt/handler/grpc/remove.go @@ -157,10 +157,10 @@ func (s *server) StreamRemove(stream vald.Remove_StreamRemoveServer) (err error) }() res, err := s.Remove(ctx, req) if err != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Object_StreamLocation{ @@ -176,10 +176,10 @@ func (s *server) StreamRemove(stream vald.Remove_StreamRemoveServer) (err error) }, nil }) if err != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) } return err @@ -314,11 +314,11 @@ func (s *server) RemoveByTimestamp( return true }) if errs != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) log.Error(err) if st != nil && span != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) } return nil, err diff --git a/pkg/agent/core/ngt/handler/grpc/search.go b/pkg/agent/core/ngt/handler/grpc/search.go index 81b6831379..7d99fc705a 100644 --- a/pkg/agent/core/ngt/handler/grpc/search.go +++ b/pkg/agent/core/ngt/handler/grpc/search.go @@ -348,10 +348,10 @@ func (s *server) StreamSearch(stream vald.Search_StreamSearchServer) (err error) }() res, err := s.Search(ctx, req) if err != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Search_StreamResponse{ @@ -367,10 +367,10 @@ func (s *server) StreamSearch(stream vald.Search_StreamSearchServer) (err error) }, nil }) if err != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) } return err @@ -395,10 +395,10 @@ func (s *server) StreamSearchByID(stream vald.Search_StreamSearchByIDServer) (er }() res, err := s.SearchByID(ctx, req) if err != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Search_StreamResponse{ @@ -414,10 +414,10 @@ func (s *server) StreamSearchByID(stream vald.Search_StreamSearchByIDServer) (er }, nil }) if err != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) } return err @@ -455,10 +455,10 @@ func (s *server) MultiSearch( }() r, err := s.Search(ctx, query) if err != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) sspan.SetStatus(trace.StatusError, err.Error()) } mu.Lock() @@ -476,10 +476,10 @@ func (s *server) MultiSearch( } wg.Wait() if errs != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) } return nil, err @@ -517,10 +517,10 @@ func (s *server) MultiSearchByID( defer wg.Done() r, err := s.SearchByID(ctx, query) if err != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) sspan.SetStatus(trace.StatusError, err.Error()) } mu.Lock() @@ -538,10 +538,10 @@ func (s *server) MultiSearchByID( } wg.Wait() if errs != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) } return nil, err diff --git a/pkg/agent/core/ngt/handler/grpc/update.go b/pkg/agent/core/ngt/handler/grpc/update.go index 8b45ce59da..80ca662b47 100644 --- a/pkg/agent/core/ngt/handler/grpc/update.go +++ b/pkg/agent/core/ngt/handler/grpc/update.go @@ -191,10 +191,10 @@ func (s *server) StreamUpdate(stream vald.Update_StreamUpdateServer) (err error) }() res, err := s.Update(ctx, req) if err != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Object_StreamLocation{ @@ -210,10 +210,10 @@ func (s *server) StreamUpdate(stream vald.Update_StreamUpdateServer) (err error) }, nil }) if err != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) } return err diff --git a/pkg/agent/core/ngt/handler/grpc/upsert.go b/pkg/agent/core/ngt/handler/grpc/upsert.go index a69ee241a6..40ab31d080 100644 --- a/pkg/agent/core/ngt/handler/grpc/upsert.go +++ b/pkg/agent/core/ngt/handler/grpc/upsert.go @@ -152,10 +152,10 @@ func (s *server) StreamUpsert(stream vald.Upsert_StreamUpsertServer) (err error) }() res, err := s.Upsert(ctx, req) if err != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { sspan.RecordError(err) - sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + sspan.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) sspan.SetStatus(trace.StatusError, err.Error()) } return &payload.Object_StreamLocation{ @@ -171,10 +171,10 @@ func (s *server) StreamUpsert(stream vald.Upsert_StreamUpsertServer) (err error) }, nil }) if err != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && sspan != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) } return err @@ -318,10 +318,10 @@ func (s *server) MultiUpsert( } if err != nil { - st, _ = status.FromError(err) + st, _ := status.FromError(err) if st != nil && span != nil { span.RecordError(err) - span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Massage())...) + span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) } return nil, err From ae5db44ec093d1ee65990b105f3070c5a7ab6d4a Mon Sep 17 00:00:00 2001 From: datelier <57349093+datelier@users.noreply.github.com> Date: Wed, 2 Oct 2024 16:40:37 +0900 Subject: [PATCH 3/6] fix typo --- pkg/agent/core/ngt/handler/grpc/linear_search.go | 8 ++++---- pkg/agent/core/ngt/handler/grpc/object.go | 2 +- pkg/agent/core/ngt/handler/grpc/remove.go | 2 +- pkg/agent/core/ngt/handler/grpc/search.go | 8 ++++---- pkg/agent/core/ngt/handler/grpc/update.go | 2 +- pkg/agent/core/ngt/handler/grpc/upsert.go | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/agent/core/ngt/handler/grpc/linear_search.go b/pkg/agent/core/ngt/handler/grpc/linear_search.go index cad8947920..ec60589d78 100644 --- a/pkg/agent/core/ngt/handler/grpc/linear_search.go +++ b/pkg/agent/core/ngt/handler/grpc/linear_search.go @@ -364,7 +364,7 @@ func (s *server) StreamLinearSearch(stream vald.Search_StreamLinearSearchServer) }) if err != nil { st, _ := status.FromError(err) - if st != nil && sspan != nil { + if st != nil && span != nil { span.RecordError(err) span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) @@ -413,7 +413,7 @@ func (s *server) StreamLinearSearchByID( }) if err != nil { st, _ := status.FromError(err) - if st != nil && sspan != nil { + if st != nil && span != nil { span.RecordError(err) span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) @@ -475,7 +475,7 @@ func (s *server) MultiLinearSearch( wg.Wait() if errs != nil { st, _ := status.FromError(err) - if st != nil && sspan != nil { + if st != nil && span != nil { span.RecordError(err) span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) @@ -537,7 +537,7 @@ func (s *server) MultiLinearSearchByID( wg.Wait() if errs != nil { st, _ := status.FromError(err) - if st != nil && sspan != nil { + if st != nil && span != nil { span.RecordError(err) span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) diff --git a/pkg/agent/core/ngt/handler/grpc/object.go b/pkg/agent/core/ngt/handler/grpc/object.go index 9ab12ce889..0207df9714 100644 --- a/pkg/agent/core/ngt/handler/grpc/object.go +++ b/pkg/agent/core/ngt/handler/grpc/object.go @@ -171,7 +171,7 @@ func (s *server) StreamGetObject(stream vald.Object_StreamGetObjectServer) (err }) if err != nil { st, _ := status.FromError(err) - if st != nil && sspan != nil { + if st != nil && span != nil { span.RecordError(err) span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) diff --git a/pkg/agent/core/ngt/handler/grpc/remove.go b/pkg/agent/core/ngt/handler/grpc/remove.go index 3c3b5b75c8..2b357f3ee0 100644 --- a/pkg/agent/core/ngt/handler/grpc/remove.go +++ b/pkg/agent/core/ngt/handler/grpc/remove.go @@ -177,7 +177,7 @@ func (s *server) StreamRemove(stream vald.Remove_StreamRemoveServer) (err error) }) if err != nil { st, _ := status.FromError(err) - if st != nil && sspan != nil { + if st != nil && span != nil { span.RecordError(err) span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) diff --git a/pkg/agent/core/ngt/handler/grpc/search.go b/pkg/agent/core/ngt/handler/grpc/search.go index 7d99fc705a..aa4a445941 100644 --- a/pkg/agent/core/ngt/handler/grpc/search.go +++ b/pkg/agent/core/ngt/handler/grpc/search.go @@ -368,7 +368,7 @@ func (s *server) StreamSearch(stream vald.Search_StreamSearchServer) (err error) }) if err != nil { st, _ := status.FromError(err) - if st != nil && sspan != nil { + if st != nil && span != nil { span.RecordError(err) span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) @@ -415,7 +415,7 @@ func (s *server) StreamSearchByID(stream vald.Search_StreamSearchByIDServer) (er }) if err != nil { st, _ := status.FromError(err) - if st != nil && sspan != nil { + if st != nil && span != nil { span.RecordError(err) span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) @@ -477,7 +477,7 @@ func (s *server) MultiSearch( wg.Wait() if errs != nil { st, _ := status.FromError(err) - if st != nil && sspan != nil { + if st != nil && span != nil { span.RecordError(err) span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) @@ -539,7 +539,7 @@ func (s *server) MultiSearchByID( wg.Wait() if errs != nil { st, _ := status.FromError(err) - if st != nil && sspan != nil { + if st != nil && span != nil { span.RecordError(err) span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) diff --git a/pkg/agent/core/ngt/handler/grpc/update.go b/pkg/agent/core/ngt/handler/grpc/update.go index 80ca662b47..b1cc7b433b 100644 --- a/pkg/agent/core/ngt/handler/grpc/update.go +++ b/pkg/agent/core/ngt/handler/grpc/update.go @@ -211,7 +211,7 @@ func (s *server) StreamUpdate(stream vald.Update_StreamUpdateServer) (err error) }) if err != nil { st, _ := status.FromError(err) - if st != nil && sspan != nil { + if st != nil && span != nil { span.RecordError(err) span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) diff --git a/pkg/agent/core/ngt/handler/grpc/upsert.go b/pkg/agent/core/ngt/handler/grpc/upsert.go index 40ab31d080..18ebd37d3c 100644 --- a/pkg/agent/core/ngt/handler/grpc/upsert.go +++ b/pkg/agent/core/ngt/handler/grpc/upsert.go @@ -172,7 +172,7 @@ func (s *server) StreamUpsert(stream vald.Upsert_StreamUpsertServer) (err error) }) if err != nil { st, _ := status.FromError(err) - if st != nil && sspan != nil { + if st != nil && span != nil { span.RecordError(err) span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, err.Error()) From 2378fd15d4dac1b6ac66e8f6c857e85a0cb3d6ec Mon Sep 17 00:00:00 2001 From: datelier <57349093+datelier@users.noreply.github.com> Date: Thu, 3 Oct 2024 09:43:08 +0900 Subject: [PATCH 4/6] fix typo --- pkg/agent/core/ngt/handler/grpc/linear_search.go | 12 ++++++------ pkg/agent/core/ngt/handler/grpc/remove.go | 8 ++++---- pkg/agent/core/ngt/handler/grpc/search.go | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pkg/agent/core/ngt/handler/grpc/linear_search.go b/pkg/agent/core/ngt/handler/grpc/linear_search.go index ec60589d78..28bb156750 100644 --- a/pkg/agent/core/ngt/handler/grpc/linear_search.go +++ b/pkg/agent/core/ngt/handler/grpc/linear_search.go @@ -474,11 +474,11 @@ func (s *server) MultiLinearSearch( } wg.Wait() if errs != nil { - st, _ := status.FromError(err) + st, _ := status.FromError(errs) if st != nil && span != nil { - span.RecordError(err) + span.RecordError(errs) span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) - span.SetStatus(trace.StatusError, err.Error()) + span.SetStatus(trace.StatusError, errs.Error()) } return nil, err } @@ -536,11 +536,11 @@ func (s *server) MultiLinearSearchByID( } wg.Wait() if errs != nil { - st, _ := status.FromError(err) + st, _ := status.FromError(errs) if st != nil && span != nil { - span.RecordError(err) + span.RecordError(errs) span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) - span.SetStatus(trace.StatusError, err.Error()) + span.SetStatus(trace.StatusError, errs.Error()) } return nil, err } diff --git a/pkg/agent/core/ngt/handler/grpc/remove.go b/pkg/agent/core/ngt/handler/grpc/remove.go index 2b357f3ee0..00baf1e216 100644 --- a/pkg/agent/core/ngt/handler/grpc/remove.go +++ b/pkg/agent/core/ngt/handler/grpc/remove.go @@ -314,12 +314,12 @@ func (s *server) RemoveByTimestamp( return true }) if errs != nil { - st, _ := status.FromError(err) - log.Error(err) + st, _ := status.FromError(errs) + log.Error(errs) if st != nil && span != nil { - span.RecordError(err) + span.RecordError(errs) span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) - span.SetStatus(trace.StatusError, err.Error()) + span.SetStatus(trace.StatusError, errs.Error()) } return nil, err } diff --git a/pkg/agent/core/ngt/handler/grpc/search.go b/pkg/agent/core/ngt/handler/grpc/search.go index aa4a445941..33699bbb9d 100644 --- a/pkg/agent/core/ngt/handler/grpc/search.go +++ b/pkg/agent/core/ngt/handler/grpc/search.go @@ -476,11 +476,11 @@ func (s *server) MultiSearch( } wg.Wait() if errs != nil { - st, _ := status.FromError(err) + st, _ := status.FromError(errs) if st != nil && span != nil { - span.RecordError(err) + span.RecordError(errs) span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) - span.SetStatus(trace.StatusError, err.Error()) + span.SetStatus(trace.StatusError, errs.Error()) } return nil, err } @@ -538,11 +538,11 @@ func (s *server) MultiSearchByID( } wg.Wait() if errs != nil { - st, _ := status.FromError(err) + st, _ := status.FromError(errs) if st != nil && span != nil { - span.RecordError(err) + span.RecordError(errs) span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) - span.SetStatus(trace.StatusError, err.Error()) + span.SetStatus(trace.StatusError, errs.Error()) } return nil, err } From a189a5fb46857f1ba7c711944be4546ccc3c72c9 Mon Sep 17 00:00:00 2001 From: datelier <57349093+datelier@users.noreply.github.com> Date: Thu, 3 Oct 2024 09:52:24 +0900 Subject: [PATCH 5/6] fix typo --- pkg/agent/core/ngt/handler/grpc/linear_search.go | 4 ++-- pkg/agent/core/ngt/handler/grpc/remove.go | 2 +- pkg/agent/core/ngt/handler/grpc/search.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/agent/core/ngt/handler/grpc/linear_search.go b/pkg/agent/core/ngt/handler/grpc/linear_search.go index 28bb156750..e1f9fca49f 100644 --- a/pkg/agent/core/ngt/handler/grpc/linear_search.go +++ b/pkg/agent/core/ngt/handler/grpc/linear_search.go @@ -480,7 +480,7 @@ func (s *server) MultiLinearSearch( span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, errs.Error()) } - return nil, err + return nil, errs } return res, nil } @@ -542,7 +542,7 @@ func (s *server) MultiLinearSearchByID( span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, errs.Error()) } - return nil, err + return nil, errs } return res, nil } diff --git a/pkg/agent/core/ngt/handler/grpc/remove.go b/pkg/agent/core/ngt/handler/grpc/remove.go index 00baf1e216..14f78aa22f 100644 --- a/pkg/agent/core/ngt/handler/grpc/remove.go +++ b/pkg/agent/core/ngt/handler/grpc/remove.go @@ -321,7 +321,7 @@ func (s *server) RemoveByTimestamp( span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, errs.Error()) } - return nil, err + return nil, errs } if locs == nil || len(locs.GetLocations()) == 0 { err := status.WrapWithNotFound( diff --git a/pkg/agent/core/ngt/handler/grpc/search.go b/pkg/agent/core/ngt/handler/grpc/search.go index 33699bbb9d..b438a01a91 100644 --- a/pkg/agent/core/ngt/handler/grpc/search.go +++ b/pkg/agent/core/ngt/handler/grpc/search.go @@ -482,7 +482,7 @@ func (s *server) MultiSearch( span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, errs.Error()) } - return nil, err + return nil, errs } return res, nil } @@ -544,7 +544,7 @@ func (s *server) MultiSearchByID( span.SetAttributes(trace.FromGRPCStatus(st.Code(), st.Message())...) span.SetStatus(trace.StatusError, errs.Error()) } - return nil, err + return nil, errs } return res, nil } From b55e79517f72d73913c1be4bd89ee412ac86fcc7 Mon Sep 17 00:00:00 2001 From: datelier <57349093+datelier@users.noreply.github.com> Date: Thu, 3 Oct 2024 10:03:38 +0900 Subject: [PATCH 6/6] fix imported and not used error --- pkg/agent/core/ngt/handler/grpc/linear_search.go | 1 - pkg/agent/core/ngt/handler/grpc/remove.go | 1 - pkg/agent/core/ngt/handler/grpc/search.go | 1 - pkg/agent/core/ngt/handler/grpc/update.go | 1 - pkg/agent/core/ngt/handler/grpc/upsert.go | 2 -- 5 files changed, 6 deletions(-) diff --git a/pkg/agent/core/ngt/handler/grpc/linear_search.go b/pkg/agent/core/ngt/handler/grpc/linear_search.go index e1f9fca49f..d66f74e9d0 100644 --- a/pkg/agent/core/ngt/handler/grpc/linear_search.go +++ b/pkg/agent/core/ngt/handler/grpc/linear_search.go @@ -23,7 +23,6 @@ import ( "github.com/vdaas/vald/internal/info" "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/net/grpc" - "github.com/vdaas/vald/internal/net/grpc/codes" "github.com/vdaas/vald/internal/net/grpc/errdetails" "github.com/vdaas/vald/internal/net/grpc/status" "github.com/vdaas/vald/internal/observability/attribute" diff --git a/pkg/agent/core/ngt/handler/grpc/remove.go b/pkg/agent/core/ngt/handler/grpc/remove.go index 14f78aa22f..2d3ec18b10 100644 --- a/pkg/agent/core/ngt/handler/grpc/remove.go +++ b/pkg/agent/core/ngt/handler/grpc/remove.go @@ -23,7 +23,6 @@ import ( "github.com/vdaas/vald/internal/info" "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/net/grpc" - "github.com/vdaas/vald/internal/net/grpc/codes" "github.com/vdaas/vald/internal/net/grpc/errdetails" "github.com/vdaas/vald/internal/net/grpc/status" "github.com/vdaas/vald/internal/observability/attribute" diff --git a/pkg/agent/core/ngt/handler/grpc/search.go b/pkg/agent/core/ngt/handler/grpc/search.go index b438a01a91..119a4bc727 100644 --- a/pkg/agent/core/ngt/handler/grpc/search.go +++ b/pkg/agent/core/ngt/handler/grpc/search.go @@ -23,7 +23,6 @@ import ( "github.com/vdaas/vald/internal/info" "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/net/grpc" - "github.com/vdaas/vald/internal/net/grpc/codes" "github.com/vdaas/vald/internal/net/grpc/errdetails" "github.com/vdaas/vald/internal/net/grpc/status" "github.com/vdaas/vald/internal/observability/attribute" diff --git a/pkg/agent/core/ngt/handler/grpc/update.go b/pkg/agent/core/ngt/handler/grpc/update.go index b1cc7b433b..a38307654c 100644 --- a/pkg/agent/core/ngt/handler/grpc/update.go +++ b/pkg/agent/core/ngt/handler/grpc/update.go @@ -23,7 +23,6 @@ import ( "github.com/vdaas/vald/internal/info" "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/net/grpc" - "github.com/vdaas/vald/internal/net/grpc/codes" "github.com/vdaas/vald/internal/net/grpc/errdetails" "github.com/vdaas/vald/internal/net/grpc/status" "github.com/vdaas/vald/internal/observability/attribute" diff --git a/pkg/agent/core/ngt/handler/grpc/upsert.go b/pkg/agent/core/ngt/handler/grpc/upsert.go index 18ebd37d3c..6c75e4ecec 100644 --- a/pkg/agent/core/ngt/handler/grpc/upsert.go +++ b/pkg/agent/core/ngt/handler/grpc/upsert.go @@ -20,7 +20,6 @@ import ( "github.com/vdaas/vald/apis/grpc/v1/payload" "github.com/vdaas/vald/apis/grpc/v1/vald" "github.com/vdaas/vald/internal/errors" - "github.com/vdaas/vald/internal/info" "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/net/grpc" "github.com/vdaas/vald/internal/net/grpc/codes" @@ -28,7 +27,6 @@ import ( "github.com/vdaas/vald/internal/net/grpc/status" "github.com/vdaas/vald/internal/observability/trace" "github.com/vdaas/vald/internal/safety" - "github.com/vdaas/vald/internal/strings" "github.com/vdaas/vald/internal/sync" )