From eaf08b2e3518f865cb79b5e7cf53b9a30c5976f5 Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Tue, 1 Oct 2024 19:07:13 +1000 Subject: [PATCH] fix: user errors are not logged (#2919) fixes: #2858 --- backend/runner/runner.go | 12 ++++++++++++ docs/content/docs/reference/verbs.md | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/runner/runner.go b/backend/runner/runner.go index 7f46699dae..e98aba5aac 100644 --- a/backend/runner/runner.go +++ b/backend/runner/runner.go @@ -213,8 +213,16 @@ func (s *Service) Call(ctx context.Context, req *connect.Request[ftlv1.CallReque } response, err := deployment.plugin.Client.Call(ctx, req) if err != nil { + deploymentLogger := s.getDeploymentLogger(ctx, deployment.key) + deploymentLogger.Errorf(err, "Call to deployments %s failed to perform gRPC call", deployment.key) return nil, connect.NewError(connect.CodeOf(err), err) + } else if response.Msg.GetError() != nil { + // This is a user level error (i.e. something wrong in the users app) + // Log it to the deployment logger + deploymentLogger := s.getDeploymentLogger(ctx, deployment.key) + deploymentLogger.Errorf(fmt.Errorf("%v", response.Msg.GetError().GetMessage()), "Call to deployments %s failed", deployment.key) } + return connect.NewResponse(response.Msg), nil } @@ -414,6 +422,7 @@ func (s *Service) registrationLoop(ctx context.Context, send func(request *ftlv1 func (s *Service) streamLogsLoop(ctx context.Context, send func(request *ftlv1.StreamDeploymentLogsRequest) error) error { delay := time.Millisecond * 500 + logger := log.FromContext(ctx) select { case entry := <-s.deploymentLogQueue: @@ -431,6 +440,9 @@ func (s *Service) streamLogsLoop(ctx context.Context, send func(request *ftlv1.S if reqStr, ok := entry.Attributes["request"]; ok { request = &reqStr } + // We also just output the log normally, so it shows up in the pod logs and gets synced to DD etc. + // It's not clear if we should output this here on or on the controller side. + logger.Log(entry) err := send(&ftlv1.StreamDeploymentLogsRequest{ RequestKey: request, diff --git a/docs/content/docs/reference/verbs.md b/docs/content/docs/reference/verbs.md index 80fd1a6f50..648da0bd39 100644 --- a/docs/content/docs/reference/verbs.md +++ b/docs/content/docs/reference/verbs.md @@ -53,7 +53,7 @@ data class EchoRequest data class EchoResponse @Verb -fun echo(ctx: Context, request: EchoRequest): EchoResponse { +fun echo(request: EchoRequest): EchoResponse { // ... } ```