Always log Runner and Environment ID.

Systematically log the runner id and the environment id by adding the information at the findRunnerMiddleware.
This commit is contained in:
Maximilian Paß
2023-07-14 18:17:42 +02:00
parent 0bfef5e105
commit e7df777db4
11 changed files with 39 additions and 25 deletions

View File

@ -3,6 +3,7 @@ package logging
import (
"context"
"github.com/getsentry/sentry-go"
"github.com/openHPI/poseidon/pkg/dto"
"github.com/sirupsen/logrus"
)
@ -28,6 +29,9 @@ 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))
}
if hub == nil {
hub = sentry.CurrentHub()