Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: user errors are not logged #2919

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading