Refactor incident tagging logic in tracing middleware
Reorganized the logic for setting tags when incidents are present in `OpenTelemetryTracingWorkflowExecutionMiddleware`. The new structure ensures consistent tag setting for error status and incidents, improving code readability and maintainability.
This commit is contained in:
parent
41e1062148
commit
2aa312850d
|
|
@ -54,10 +54,6 @@ public class OpenTelemetryTracingWorkflowExecutionMiddleware(WorkflowMiddlewareD
|
|||
activity.AddEvent(new ActivityEvent("Faulted"));
|
||||
activity.SetStatus(ActivityStatusCode.Error);
|
||||
activity.SetTag("error", true);
|
||||
activity.SetTag("hasIncidents", true);
|
||||
|
||||
if (context.Incidents.Count > 0)
|
||||
activity.SetTag("error.message", JsonSerializer.Serialize(context.Incidents, _incidentSerializerOptions));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -68,6 +64,16 @@ public class OpenTelemetryTracingWorkflowExecutionMiddleware(WorkflowMiddlewareD
|
|||
})));
|
||||
}
|
||||
|
||||
if(context.Incidents.Any())
|
||||
{
|
||||
activity.SetStatus(ActivityStatusCode.Error);
|
||||
activity.SetTag("hasIncidents", true);
|
||||
activity.SetTag("error", true);
|
||||
|
||||
if (context.Incidents.Count > 0)
|
||||
activity.SetTag("error.message", JsonSerializer.Serialize(context.Incidents, _incidentSerializerOptions));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(context.CorrelationId))
|
||||
activity.SetTag("correlationId", context.CorrelationId);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue