Skip to content

Commit

Permalink
Merge pull request #1281 from jakenuts/fix-morenullrefs-in-workflow-a…
Browse files Browse the repository at this point in the history
…ctivity

Fix morenullrefs in workflow activity
  • Loading branch information
danielgerlag authored Aug 14, 2024
2 parents b40d184 + bb7b4ac commit ff6eb9b
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/WorkflowCore/Services/WorkflowActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ internal static void Enrich(WorkflowInstance workflow, string action)
}
}


internal static void Enrich(WorkflowStep workflowStep)
{
var activity = Activity.Current;
Expand All @@ -57,10 +58,18 @@ internal static void Enrich(WorkflowStep workflowStep)
? "inline"
: workflowStep.Name;

activity.DisplayName += $" step {stepName}";
if (string.IsNullOrEmpty(activity.DisplayName))
{
activity.DisplayName = $"step {stepName}";
}
else
{
activity.DisplayName += $" step {stepName}";
}

activity.SetTag("workflow.step.id", workflowStep.Id);
activity.SetTag("workflow.step.name", stepName);
activity.SetTag("workflow.step.type", workflowStep.BodyType.Name);
activity.SetTag("workflow.step.type", workflowStep.BodyType?.Name);
}
}

Expand All @@ -69,10 +78,10 @@ internal static void Enrich(WorkflowExecutorResult result)
var activity = Activity.Current;
if (activity != null)
{
activity.SetTag("workflow.subscriptions.count", result.Subscriptions.Count);
activity.SetTag("workflow.errors.count", result.Errors.Count);
activity.SetTag("workflow.subscriptions.count", result?.Subscriptions?.Count);
activity.SetTag("workflow.errors.count", result?.Errors?.Count);

if (result.Errors.Count > 0)
if (result?.Errors?.Count > 0)
{
activity.SetStatus(Status.Error);
activity.SetStatus(ActivityStatusCode.Error);
Expand All @@ -85,10 +94,10 @@ internal static void Enrich(Event evt)
var activity = Activity.Current;
if (activity != null)
{
activity.DisplayName = $"workflow process {evt.EventName}";
activity.SetTag("workflow.event.id", evt.Id);
activity.SetTag("workflow.event.name", evt.EventName);
activity.SetTag("workflow.event.processed", evt.IsProcessed);
activity.DisplayName = $"workflow process {evt?.EventName}";
activity.SetTag("workflow.event.id", evt?.Id);
activity.SetTag("workflow.event.name", evt?.EventName);
activity.SetTag("workflow.event.processed", evt?.IsProcessed);
}
}

Expand Down

0 comments on commit ff6eb9b

Please sign in to comment.