From baca8dbb0a8000fec1ffbb66e44c65c0dd59584f Mon Sep 17 00:00:00 2001 From: Jack Kleeman Date: Fri, 16 Aug 2024 13:40:11 +0100 Subject: [PATCH 1/2] Ensure method is logged --- server/restate.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server/restate.go b/server/restate.go index e56cd24..c9a273b 100644 --- a/server/restate.go +++ b/server/restate.go @@ -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)) @@ -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)) } } From fcb4f5598c4aa302756411fb0c0ddcfcd65fc597 Mon Sep 17 00:00:00 2001 From: Jack Kleeman Date: Fri, 16 Aug 2024 16:05:48 +0100 Subject: [PATCH 2/2] Log the full method name in trace mode --- internal/wire/wire.go | 45 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/internal/wire/wire.go b/internal/wire/wire.go index 0a7c5b8..4cf991c 100644 --- a/internal/wire/wire.go +++ b/internal/wire/wire.go @@ -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 {