Skip to content

Commit

Permalink
Fixed additional null refs in workflow activity enrichment methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jakenuts committed Aug 1, 2024
1 parent a761d78 commit e530900
Showing 1 changed file with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions src/WorkflowCore/Services/WorkflowActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,6 @@ internal static Activity StartPoll(string type)

return activity;
}

internal static void Enrich(WorkflowInstance workflow, string action)
{
var activity = Activity.Current;
if (activity != null)
{
activity.DisplayName = $"workflow {action} {workflow.WorkflowDefinitionId}";
activity.SetTag("workflow.id", workflow.Id);
activity.SetTag("workflow.definition", workflow.WorkflowDefinitionId);
activity.SetTag("workflow.status", workflow.Status);
}
}

internal static void Enrich(WorkflowStep workflowStep)
{
var activity = Activity.Current;
Expand All @@ -57,10 +44,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 +64,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 +80,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 e530900

Please sign in to comment.