Fix Context Values are not logged.

Only the Sentry hook uses the values of the passed context. Therefore, we removed the values from our log statements when we shifted them from an extra `WithField` call to the context.
We fix this behavior by introducing a Logrus Hook that copies a fixed set of context values to the logging data.
This commit is contained in:
Maximilian Paß
2023-08-21 13:21:48 +02:00
parent a7d27e8f65
commit 306512bf9c
5 changed files with 50 additions and 6 deletions

View File

@ -194,10 +194,14 @@ type ContextKey string
// Keys to reference information (for logging or monitoring).
const (
KeyRunnerID = "runner_id"
KeyEnvironmentID = "environment_id"
KeyRunnerID = "runner_id"
KeyEnvironmentID = "environment_id"
KeyRunnerDestroyReason = "destroy_reason"
)
// LoggedContextKeys defines which keys will be logged if a context is passed to logrus. See ContextHook.
var LoggedContextKeys = []ContextKey{KeyRunnerID, KeyEnvironmentID, KeyRunnerDestroyReason}
// WebSocketMessageType is the type for the messages from Poseidon to the client.
type WebSocketMessageType string