Skip to content

Commit e530900

Browse files
committed
Fixed additional null refs in workflow activity enrichment methods
1 parent a761d78 commit e530900

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

src/WorkflowCore/Services/WorkflowActivity.cs

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,6 @@ internal static Activity StartPoll(string type)
3535

3636
return activity;
3737
}
38-
39-
internal static void Enrich(WorkflowInstance workflow, string action)
40-
{
41-
var activity = Activity.Current;
42-
if (activity != null)
43-
{
44-
activity.DisplayName = $"workflow {action} {workflow.WorkflowDefinitionId}";
45-
activity.SetTag("workflow.id", workflow.Id);
46-
activity.SetTag("workflow.definition", workflow.WorkflowDefinitionId);
47-
activity.SetTag("workflow.status", workflow.Status);
48-
}
49-
}
50-
5138
internal static void Enrich(WorkflowStep workflowStep)
5239
{
5340
var activity = Activity.Current;
@@ -57,10 +44,18 @@ internal static void Enrich(WorkflowStep workflowStep)
5744
? "inline"
5845
: workflowStep.Name;
5946

60-
activity.DisplayName += $" step {stepName}";
47+
if (string.IsNullOrEmpty(activity.DisplayName))
48+
{
49+
activity.DisplayName = $"step {stepName}";
50+
}
51+
else
52+
{
53+
activity.DisplayName += $" step {stepName}";
54+
}
55+
6156
activity.SetTag("workflow.step.id", workflowStep.Id);
6257
activity.SetTag("workflow.step.name", stepName);
63-
activity.SetTag("workflow.step.type", workflowStep.BodyType.Name);
58+
activity.SetTag("workflow.step.type", workflowStep.BodyType?.Name);
6459
}
6560
}
6661

@@ -69,10 +64,10 @@ internal static void Enrich(WorkflowExecutorResult result)
6964
var activity = Activity.Current;
7065
if (activity != null)
7166
{
72-
activity.SetTag("workflow.subscriptions.count", result.Subscriptions.Count);
73-
activity.SetTag("workflow.errors.count", result.Errors.Count);
67+
activity.SetTag("workflow.subscriptions.count", result?.Subscriptions?.Count);
68+
activity.SetTag("workflow.errors.count", result?.Errors?.Count);
7469

75-
if (result.Errors.Count > 0)
70+
if (result?.Errors?.Count > 0)
7671
{
7772
activity.SetStatus(Status.Error);
7873
activity.SetStatus(ActivityStatusCode.Error);
@@ -85,10 +80,10 @@ internal static void Enrich(Event evt)
8580
var activity = Activity.Current;
8681
if (activity != null)
8782
{
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);
83+
activity.DisplayName = $"workflow process {evt?.EventName}";
84+
activity.SetTag("workflow.event.id", evt?.Id);
85+
activity.SetTag("workflow.event.name", evt?.EventName);
86+
activity.SetTag("workflow.event.processed", evt?.IsProcessed);
9287
}
9388
}
9489

0 commit comments

Comments
 (0)