< Summary

Information
Class: Elsa.Workflows.Middleware.Activities.ExecutionLogMiddleware
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Middleware/Activities/ExecutionLogMiddleware.cs
Line coverage
100%
Covered lines: 22
Uncovered lines: 0
Coverable lines: 22
Total lines: 61
Line coverage: 100%
Branch coverage
87%
Covered branches: 7
Total branches: 8
Branch coverage: 87.5%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
InvokeAsync()87.5%88100%
IsActivityBookmarked(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Middleware/Activities/ExecutionLogMiddleware.cs

#LineLine coverage
 1using Elsa.Workflows.Models;
 2using Elsa.Workflows.Pipelines.ActivityExecution;
 3using JetBrains.Annotations;
 4
 5namespace Elsa.Workflows.Middleware.Activities;
 6
 7/// <summary>
 8/// Adds extension methods to <see cref="ExecutionLogMiddleware"/>.
 9/// </summary>
 10public static class ExecutionLogMiddlewareExtensions
 11{
 12    /// <summary>
 13    /// Installs the <see cref="ExecutionLogMiddleware"/> component in the activity execution pipeline.
 14    /// </summary>
 15    public static IActivityExecutionPipelineBuilder UseExecutionLogging(this IActivityExecutionPipelineBuilder pipelineB
 16}
 17
 18/// <summary>
 19/// An activity execution middleware component that extracts execution details as <see cref="WorkflowExecutionLogEntry"/
 20/// </summary>
 21[UsedImplicitly]
 42122public class ExecutionLogMiddleware(ActivityMiddlewareDelegate next) : IActivityExecutionMiddleware
 23{
 24    /// <inheritdoc />
 25    public async ValueTask InvokeAsync(ActivityExecutionContext context)
 26    {
 301927        context.AddExecutionLogEntry(IsActivityBookmarked(context) ? "Resumed" : "Started");
 28
 29        try
 30        {
 301931            await next(context);
 32
 300633            if (context.Status == ActivityStatus.Running)
 34            {
 206835                if (IsActivityBookmarked(context))
 4536                    context.AddExecutionLogEntry("Suspended");
 37            }
 300638        }
 1339        catch (Exception exception)
 40        {
 1341            context.AddExecutionLogEntry("Faulted",
 1342                message: exception.Message,
 1343                payload: new
 1344                {
 1345                    Exception = exception.GetType().FullName,
 1346                    exception.Message,
 1347                    exception.Source,
 1348                    exception.Data,
 1349                    exception.StackTrace,
 1350                    InnerException = exception.InnerException?.GetType().FullName,
 1351                });
 52
 1353            throw;
 54        }
 300655    }
 56
 57    private static bool IsActivityBookmarked(ActivityExecutionContext context)
 58    {
 517759        return context.WorkflowExecutionContext.Bookmarks.Any(b => b.ActivityNodeId.Equals(context.ActivityNode.NodeId))
 60    }
 61}