From 9e007078d9151fe29ddc6f35a3f6349bc0870f7e Mon Sep 17 00:00:00 2001 From: alishakawaguchi Date: Wed, 20 Dec 2023 11:39:03 -0800 Subject: [PATCH] Adds logs to create job (#935) --- .../internal/connect/interceptors/logging/interceptor.go | 2 ++ backend/services/mgmt/v1alpha1/job-service/jobs.go | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/internal/connect/interceptors/logging/interceptor.go b/backend/internal/connect/interceptors/logging/interceptor.go index 76d7ed78e4..b4f80f9438 100644 --- a/backend/internal/connect/interceptors/logging/interceptor.go +++ b/backend/internal/connect/interceptors/logging/interceptor.go @@ -48,6 +48,8 @@ func (i *Interceptor) WrapUnary(next connect.UnaryFunc) connect.UnaryFunc { fields = append(fields, "connect.code", connect.CodeInternal.String()) } + i.logger.Error(err.Error()) + i.logger.Info( "finished call", fields..., diff --git a/backend/services/mgmt/v1alpha1/job-service/jobs.go b/backend/services/mgmt/v1alpha1/job-service/jobs.go index 3366391576..4aa888976b 100644 --- a/backend/services/mgmt/v1alpha1/job-service/jobs.go +++ b/backend/services/mgmt/v1alpha1/job-service/jobs.go @@ -302,7 +302,7 @@ func (s *Service) CreateJob( req *connect.Request[mgmtv1alpha1.CreateJobRequest], ) (*connect.Response[mgmtv1alpha1.CreateJobResponse], error) { logger := logger_interceptor.GetLoggerFromContextOrDefault(ctx) - logger = logger.With("jobName", req.Msg.JobName) + logger = logger.With("jobName", req.Msg.JobName, "accountId", req.Msg.AccountId) accountUuid, err := s.verifyUserInAccount(ctx, req.Msg.AccountId) if err != nil { @@ -331,6 +331,7 @@ func (s *Service) CreateJob( connectionUuids = append(connectionUuids, destUuid) } + logger.Info("verifying connections") count, err := s.db.Q.AreConnectionsInAccount(ctx, s.db.Db, db_queries.AreConnectionsInAccountParams{ AccountId: *accountUuid, ConnectionIds: connectionUuids, @@ -339,6 +340,7 @@ func (s *Service) CreateJob( return nil, err } if count != int64(len(connectionUuids)) { + logger.Error("connection is not in account") return nil, nucleuserrors.NewForbidden("provided connection id is not in account") } @@ -354,6 +356,7 @@ func (s *Service) CreateJob( } if !verifyConnectionIdsUnique(connectionIds) { + logger.Error("connection ids are not unqiue") return nil, nucleuserrors.NewBadRequest("connections ids are not unique") } @@ -424,11 +427,14 @@ func (s *Service) CreateJob( }) } + logger.Info("verifying temporal workspace") hasNs, err := s.temporalWfManager.DoesAccountHaveTemporalWorkspace(ctx, req.Msg.AccountId, logger) if err != nil { + logger.Error("unable to verify account temporal workspace. error: %w", err) return nil, err } if !hasNs { + logger.Error("temporal namespace not configured") return nil, nucleuserrors.NewBadRequest("must first configure temporal namespace in account settings") } @@ -445,6 +451,7 @@ func (s *Service) CreateJob( if err != nil { return nil, fmt.Errorf("unable to create job: %w", err) } + logger.Info("created job", "jobId", cj.ID) tScheduleClient, err := s.temporalWfManager.GetScheduleClientByAccount(ctx, req.Msg.AccountId, logger) if err != nil {