Skip to content

Commit

Permalink
fix: user errors are not logged
Browse files Browse the repository at this point in the history
fixes: #2858
  • Loading branch information
stuartwdouglas committed Oct 1, 2024
1 parent 5bac043 commit b100dcf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions backend/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,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
}

Expand Down Expand Up @@ -413,6 +421,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:
Expand All @@ -430,6 +439,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,
Expand Down
2 changes: 1 addition & 1 deletion docs/content/docs/reference/verbs.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ data class EchoRequest
data class EchoResponse

@Verb
fun echo(ctx: Context, request: EchoRequest): EchoResponse {
fun echo(request: EchoRequest): EchoResponse {
// ...
}
```
Expand Down

0 comments on commit b100dcf

Please sign in to comment.