Refactor logging to exclude activity state
Logging throughout the application, specifically in ActivityExecutionContextExtensions.cs, SendEmail.cs, and more, has been refactored to exclude activity state from log entries. There have also been updates to other files, such as introducing JetBrains.Annotations and modifying certain methods. Additionally, the IHttpMessageHandlerProvider.cs file has been removed.
This commit is contained in:
parent
277ac35bb1
commit
143b1b8364
|
|
@ -87,6 +87,7 @@ services
|
|||
|
||||
identity.IdentityOptions = options => identitySection.Bind(options);
|
||||
identity.TokenOptions = options => identityTokenSection.Bind(options);
|
||||
identity.UseStoreBasedApplicationProvider();
|
||||
identity.UseConfigurationBasedUserProvider(options => identitySection.Bind(options));
|
||||
identity.UseConfigurationBasedApplicationProvider(options => identitySection.Bind(options));
|
||||
identity.UseConfigurationBasedRoleProvider(options => identitySection.Bind(options));
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
namespace Elsa.Api.Client.Contracts;
|
||||
|
||||
/// <summary>
|
||||
/// Provides an <see cref="HttpMessageHandler"/> instance.
|
||||
/// </summary>
|
||||
public interface IHttpMessageHandlerProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns an <see cref="HttpMessageHandler"/> instance.
|
||||
/// </summary>
|
||||
HttpMessageHandler GetHandler();
|
||||
}
|
||||
|
|
@ -1,11 +1,13 @@
|
|||
using Elsa.Api.Client.Resources.WorkflowInstances.Models;
|
||||
using Elsa.Api.Client.Shared.Models;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Elsa.Api.Client.Resources.ActivityExecutions.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a single workflow execution, associated with an individual activity instance.
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
public class ActivityExecutionRecord : Entity
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ public class SendEmail : Activity
|
|||
catch (Exception e)
|
||||
{
|
||||
logger.LogWarning(e, "Error while sending email message");
|
||||
context.AddExecutionLogEntry("Error", e.Message, payload: new { e.StackTrace }, includeActivityState: true);
|
||||
context.AddExecutionLogEntry("Error", e.Message, payload: new { e.StackTrace });
|
||||
await context.ScheduleActivityAsync(Error, OnErrorCompletedAsync);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public partial class ActivityExecutionContext
|
|||
WorkflowExecutionContext.Bookmarks.RemoveWhere(x => x.ActivityNodeId == NodeId);
|
||||
|
||||
// Add an execution log entry.
|
||||
AddExecutionLogEntry("Canceled", payload: JournalData, includeActivityState: true);
|
||||
AddExecutionLogEntry("Canceled", payload: JournalData);
|
||||
|
||||
await _cancellationRegistration.DisposeAsync();
|
||||
await this.SendSignalAsync(new CancelSignal());
|
||||
|
|
|
|||
|
|
@ -12,12 +12,9 @@ public partial class ActivityExecutionContext
|
|||
/// <param name="message">The message of the event.</param>
|
||||
/// <param name="source">The source of the activity. For example, the source file name and line number in case of composite activities.</param>
|
||||
/// <param name="payload">Any contextual data related to this event.</param>
|
||||
/// <param name="includeActivityState">True to include activity state with this event, false otherwise.</param>
|
||||
/// <returns>Returns the created <see cref="WorkflowExecutionLogEntry"/>.</returns>
|
||||
public WorkflowExecutionLogEntry AddExecutionLogEntry(string eventName, string? message = default, string? source = default, object? payload = default, bool includeActivityState = false)
|
||||
public WorkflowExecutionLogEntry AddExecutionLogEntry(string eventName, string? message = default, string? source = default, object? payload = default)
|
||||
{
|
||||
var activityState = includeActivityState ? ActivityState : default;
|
||||
|
||||
var logEntry = new WorkflowExecutionLogEntry(
|
||||
Id,
|
||||
ParentActivityExecutionContext?.Id,
|
||||
|
|
@ -26,7 +23,7 @@ public partial class ActivityExecutionContext
|
|||
Activity.Version,
|
||||
Activity.Name,
|
||||
NodeId,
|
||||
activityState,
|
||||
null,
|
||||
_systemClock.UtcNow,
|
||||
WorkflowExecutionContext.ExecutionLogSequence++,
|
||||
eventName,
|
||||
|
|
|
|||
|
|
@ -469,7 +469,7 @@ public static class ActivityExecutionContextExtensions
|
|||
}
|
||||
|
||||
// Add an execution log entry.
|
||||
context.AddExecutionLogEntry("Completed", payload: context.JournalData, includeActivityState: true);
|
||||
context.AddExecutionLogEntry("Completed", payload: context.JournalData);
|
||||
|
||||
// Send a signal.
|
||||
await context.SendSignalAsync(new ActivityCompleted(result));
|
||||
|
|
@ -563,7 +563,7 @@ public static class ActivityExecutionContextExtensions
|
|||
context.WorkflowExecutionContext.Bookmarks.RemoveWhere(x => x.ActivityNodeId == context.NodeId);
|
||||
|
||||
// Add an execution log entry.
|
||||
context.AddExecutionLogEntry("Canceled", payload: context.JournalData, includeActivityState: true);
|
||||
context.AddExecutionLogEntry("Canceled", payload: context.JournalData);
|
||||
|
||||
await context.SendSignalAsync(new CancelSignal());
|
||||
await publisher.SendAsync(new ActivityCancelled(context));
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using Elsa.Extensions;
|
|||
using Elsa.Workflows.Contracts;
|
||||
using Elsa.Workflows.Models;
|
||||
using Elsa.Workflows.Pipelines.ActivityExecution;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Elsa.Workflows.Middleware.Activities;
|
||||
|
||||
|
|
@ -19,6 +20,7 @@ public static class ExecutionLogMiddlewareExtensions
|
|||
/// <summary>
|
||||
/// An activity execution middleware component that extracts execution details as <see cref="WorkflowExecutionLogEntry"/> objects.
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
public class ExecutionLogMiddleware : IActivityExecutionMiddleware
|
||||
{
|
||||
private readonly ActivityMiddlewareDelegate _next;
|
||||
|
|
@ -34,7 +36,7 @@ public class ExecutionLogMiddleware : IActivityExecutionMiddleware
|
|||
/// <inheritdoc />
|
||||
public async ValueTask InvokeAsync(ActivityExecutionContext context)
|
||||
{
|
||||
context.AddExecutionLogEntry(IsActivityBookmarked(context) ? "Resumed" : "Started", includeActivityState: true);
|
||||
context.AddExecutionLogEntry(IsActivityBookmarked(context) ? "Resumed" : "Started");
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -43,13 +45,12 @@ public class ExecutionLogMiddleware : IActivityExecutionMiddleware
|
|||
if (context.Status == ActivityStatus.Running)
|
||||
{
|
||||
if (IsActivityBookmarked(context))
|
||||
context.AddExecutionLogEntry("Suspended", payload: context.JournalData, includeActivityState: true);
|
||||
context.AddExecutionLogEntry("Suspended", payload: context.JournalData);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
context.AddExecutionLogEntry("Faulted",
|
||||
includeActivityState: true,
|
||||
message: exception.Message,
|
||||
payload: new
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public record WorkflowExecutionLogEntry(
|
|||
int ActivityTypeVersion,
|
||||
string? ActivityName,
|
||||
string NodeId,
|
||||
IDictionary<string, object>? ActivityState,
|
||||
[property: Obsolete("USe ActivityInstanceId instead to locate activity state from ActivityExecutionLog")]IDictionary<string, object>? ActivityState,
|
||||
DateTimeOffset Timestamp,
|
||||
long Sequence,
|
||||
string? EventName,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using Elsa.Workflows.Runtime.Contracts;
|
|||
using Elsa.Workflows.Runtime.Features;
|
||||
using Elsa.Workflows.Runtime.Models;
|
||||
using Elsa.Workflows.Runtime.Options;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Elsa.Workflows.Runtime.Providers;
|
||||
|
|
@ -11,6 +12,7 @@ namespace Elsa.Workflows.Runtime.Providers;
|
|||
/// <summary>
|
||||
/// Provides workflows to the system that are registered with <see cref="WorkflowRuntimeFeature"/>
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
public class ClrWorkflowProvider : IWorkflowProvider
|
||||
{
|
||||
private readonly IWorkflowBuilderFactory _workflowBuilderFactory;
|
||||
|
|
@ -18,7 +20,7 @@ public class ClrWorkflowProvider : IWorkflowProvider
|
|||
private readonly RuntimeOptions _options;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// Initializes a new instance of the <see cref="ClrWorkflowProvider"/> class.
|
||||
/// </summary>
|
||||
public ClrWorkflowProvider(
|
||||
IOptions<RuntimeOptions> options,
|
||||
|
|
|
|||
Loading…
Reference in a new issue