Skip to content

Commit

Permalink
Merge pull request #220 from yaananth/yaananth-patch-2
Browse files Browse the repository at this point in the history
add more keys for events while logging
  • Loading branch information
cschleiden committed Jul 19, 2023
2 parents cf95b44 + 9008bc3 commit 6bda8a1
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions internal/workflow/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,21 @@ func (e *executor) Close() {
}

func (e *executor) executeEvent(event *history.Event) error {
e.logger.Debug("Executing event",
fields := []any{
log.InstanceIDKey, e.workflowState.Instance().InstanceID,
log.EventIDKey, event.ID,
log.SeqIDKey, event.SequenceID,
log.EventTypeKey, event.Type,
log.ScheduleEventIDKey, event.ScheduleEventID,
log.IsReplayingKey, e.workflowState.Replaying(),
)
}

attributesFields := getAttributesLoggingFields(event)
if attributesFields != nil {
fields = append(fields, attributesFields...)
}

e.logger.Debug("Executing event", fields)

var err error

Expand Down Expand Up @@ -676,3 +683,30 @@ func (e *executor) createNewEvent(eventType history.EventType, attributes interf
opts...,
)
}

func getAttributesLoggingFields(event *history.Event) []any {
switch event.Type {
case history.EventType_WorkflowExecutionStarted:
attributes := event.Attributes.(*history.ExecutionStartedAttributes)
return []any{
log.WorkflowNameKey, attributes.Name,
}
case history.EventType_SubWorkflowScheduled:
attributes := event.Attributes.(*history.SubWorkflowScheduledAttributes)
return []any{
log.WorkflowNameKey, attributes.Name,
}
case history.EventType_SignalReceived:
attributes := event.Attributes.(*history.SignalReceivedAttributes)
return []any{
log.SignalNameKey, attributes.Name,
}
case history.EventType_ActivityScheduled:
attributes := event.Attributes.(*history.ActivityScheduledAttributes)
return []any{
log.ActivityNameKey, attributes.Name,
}
default:
return nil
}
}

0 comments on commit 6bda8a1

Please sign in to comment.