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

Log from activity interceptor #22

Merged
merged 2 commits into from
Sep 4, 2024
Merged
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
20 changes: 11 additions & 9 deletions temporal/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,16 @@ type contextKey struct{}
var loggerContextKey = contextKey{}

func (a *activityInboundInterceptor) ExecuteActivity(ctx context.Context, in *temporalsdk_interceptor.ExecuteActivityInput) (interface{}, error) {
ctx = context.WithValue(ctx, loggerContextKey, a.logger)
info := temporalsdk_activity.GetInfo(ctx)
logger := a.logger.WithValues(
"ActivityID", info.ActivityID,
"ActivityType", info.ActivityType.Name,
)

ctx = context.WithValue(ctx, loggerContextKey, logger)

logger.V(1).Info("Executing activity.")

return a.Next.ExecuteActivity(ctx, in)
}

Expand All @@ -83,12 +92,5 @@ func GetLogger(ctx context.Context) logr.Logger {
return logr.Discard()
}

logger := v.(logr.Logger)

info := temporalsdk_activity.GetInfo(ctx)

return logger.WithValues(
"ActivityID", info.ActivityID,
"ActivityType", info.ActivityType.Name,
)
return v.(logr.Logger)
}
Loading