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

Ensure servicemethod is logged #28

Merged
merged 2 commits into from
Aug 20, 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
45 changes: 44 additions & 1 deletion internal/wire/wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,50 @@ const (
type Type uint16

func (t Type) String() string {
return fmt.Sprintf("0x%04X", uint16(t))
switch t {
case StartMessageType:
return "StartMessage"
case CompletionMessageType:
return "CompletionMessage"
case SuspensionMessageType:
return "SuspensionMessage"
case ErrorMessageType:
return "ErrorMessage"
case EntryAckMessageType:
return "EntryAckMessage"
case EndMessageType:
return "EndMessage"
case InputEntryMessageType:
return "InputEntryMessage"
case OutputEntryMessageType:
return "OutputEntryMessage"
case GetStateEntryMessageType:
return "GetStateEntryMessage"
case SetStateEntryMessageType:
return "SetStateEntryMessage"
case ClearStateEntryMessageType:
return "ClearStateEntryMessage"
case ClearAllStateEntryMessageType:
return "ClearAllStateEntryMessage"
case GetStateKeysEntryMessageType:
return "GetStateKeysEntryMessage"
case SleepEntryMessageType:
return "SleepEntryMessage"
case CallEntryMessageType:
return "CallEntryMessage"
case OneWayCallEntryMessageType:
return "OneWayCallEntryMessage"
case AwakeableEntryMessageType:
return "AwakeableEntryMessage"
case CompleteAwakeableEntryMessageType:
return "CompleteAwakeableEntryMessage"
case RunEntryMessageType:
return "RunEntryMessage"
case SelectorEntryMessageType:
return "SelectorEntryMessage"
default:
return fmt.Sprintf("0x%04X", uint16(t))
}
}

func (t Type) UInt32() *uint32 {
Expand Down
10 changes: 8 additions & 2 deletions server/restate.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ type serviceMethod struct {

// takes care of function call
func (r *Restate) callHandler(serviceProtocolVersion protocol.ServiceProtocolVersion, service, method string, writer http.ResponseWriter, request *http.Request) {
logger := r.systemLog.With("method", slog.StringValue(fmt.Sprintf("%s/%s", service, method)))
serviceMethod := fmt.Sprintf("%s/%s", service, method)

logger := r.systemLog.With("method", slog.StringValue(serviceMethod))

writer.Header().Add("x-restate-server", xRestateServer)
writer.Header().Add("content-type", serviceProtocolVersionToHeaderValue(serviceProtocolVersion))
Expand All @@ -263,7 +265,11 @@ func (r *Restate) callHandler(serviceProtocolVersion protocol.ServiceProtocolVer

machine := state.NewMachine(handler, conn, request.Header)

if err := machine.Start(request.Context(), r.dropReplayLogs, r.logHandler); err != nil {
logHandler := r.logHandler.WithAttrs([]slog.Attr{
slog.String("method", serviceMethod),
})

if err := machine.Start(request.Context(), r.dropReplayLogs, logHandler); err != nil {
r.systemLog.LogAttrs(request.Context(), slog.LevelError, "Failed to handle invocation", log.Error(err))
}
}
Expand Down
Loading