Skip to content

Commit

Permalink
Adds logs to create job (#935)
Browse files Browse the repository at this point in the history
  • Loading branch information
alishakawaguchi authored Dec 20, 2023
1 parent 1df3d8e commit 9e00707
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions backend/internal/connect/interceptors/logging/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...,
Expand Down
9 changes: 8 additions & 1 deletion backend/services/mgmt/v1alpha1/job-service/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -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")
}

Expand All @@ -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")
}

Expand Down Expand Up @@ -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")
}

Expand All @@ -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 {
Expand Down

0 comments on commit 9e00707

Please sign in to comment.