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:
@@ -19,9 +19,7 @@ func (hook *SentryHook) Fire(entry *logrus.Entry) error {
|
||||
var hub *sentry.Hub
|
||||
if entry.Context != nil {
|
||||
hub = sentry.GetHubFromContext(entry.Context)
|
||||
// This might overwrite valid data when not the request context is passed.
|
||||
entry.Data[dto.KeyRunnerID] = entry.Context.Value(dto.ContextKey(dto.KeyRunnerID))
|
||||
entry.Data[dto.KeyEnvironmentID] = entry.Context.Value(dto.ContextKey(dto.KeyEnvironmentID))
|
||||
injectContextValuesIntoData(entry)
|
||||
}
|
||||
if hub == nil {
|
||||
hub = sentry.CurrentHub()
|
||||
|
Reference in New Issue
Block a user