Skip to content

Commit ff6eb9b

Browse files
authored
Merge pull request #1281 from jakenuts/fix-morenullrefs-in-workflow-activity
Fix morenullrefs in workflow activity
2 parents b40d184 + bb7b4ac commit ff6eb9b

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/WorkflowCore/Services/WorkflowActivity.cs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ internal static void Enrich(WorkflowInstance workflow, string action)
4848
}
4949
}
5050

51+
5152
internal static void Enrich(WorkflowStep workflowStep)
5253
{
5354
var activity = Activity.Current;
@@ -57,10 +58,18 @@ internal static void Enrich(WorkflowStep workflowStep)
5758
? "inline"
5859
: workflowStep.Name;
5960

60-
activity.DisplayName += $" step {stepName}";
61+
if (string.IsNullOrEmpty(activity.DisplayName))
62+
{
63+
activity.DisplayName = $"step {stepName}";
64+
}
65+
else
66+
{
67+
activity.DisplayName += $" step {stepName}";
68+
}
69+
6170
activity.SetTag("workflow.step.id", workflowStep.Id);
6271
activity.SetTag("workflow.step.name", stepName);
63-
activity.SetTag("workflow.step.type", workflowStep.BodyType.Name);
72+
activity.SetTag("workflow.step.type", workflowStep.BodyType?.Name);
6473
}
6574
}
6675

@@ -69,10 +78,10 @@ internal static void Enrich(WorkflowExecutorResult result)
6978
var activity = Activity.Current;
7079
if (activity != null)
7180
{
72-
activity.SetTag("workflow.subscriptions.count", result.Subscriptions.Count);
73-
activity.SetTag("workflow.errors.count", result.Errors.Count);
81+
activity.SetTag("workflow.subscriptions.count", result?.Subscriptions?.Count);
82+
activity.SetTag("workflow.errors.count", result?.Errors?.Count);
7483

75-
if (result.Errors.Count > 0)
84+
if (result?.Errors?.Count > 0)
7685
{
7786
activity.SetStatus(Status.Error);
7887
activity.SetStatus(ActivityStatusCode.Error);
@@ -85,10 +94,10 @@ internal static void Enrich(Event evt)
8594
var activity = Activity.Current;
8695
if (activity != null)
8796
{
88-
activity.DisplayName = $"workflow process {evt.EventName}";
89-
activity.SetTag("workflow.event.id", evt.Id);
90-
activity.SetTag("workflow.event.name", evt.EventName);
91-
activity.SetTag("workflow.event.processed", evt.IsProcessed);
97+
activity.DisplayName = $"workflow process {evt?.EventName}";
98+
activity.SetTag("workflow.event.id", evt?.Id);
99+
activity.SetTag("workflow.event.name", evt?.EventName);
100+
activity.SetTag("workflow.event.processed", evt?.IsProcessed);
92101
}
93102
}
94103

0 commit comments

Comments
 (0)