Skip to content

Commit

Permalink
Activity Execute/Compensate exceptions should be logged!
Browse files Browse the repository at this point in the history
  • Loading branch information
phatboyg committed May 25, 2023
1 parent e450919 commit 8ef45cf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/MassTransit/Courier/CompensateActivityHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,15 @@ public async Task Send(ConsumeContext<RoutingSlip> context, IPipe<ConsumeContext

await result.Evaluate().ConfigureAwait(false);
}
catch (Exception ex)
catch (Exception exception)
{
await compensateContext.Failed(ex).Evaluate().ConfigureAwait(false);
await context.NotifyFaulted(timer.Elapsed, TypeCache<TActivity>.ShortName, exception).ConfigureAwait(false);

activity?.AddExceptionEvent(exception);

instrument?.AddException(exception);

await compensateContext.Failed(exception).Evaluate().ConfigureAwait(false);
}

await context.NotifyConsumed(timer.Elapsed, TypeCache<TActivity>.ShortName).ConfigureAwait(false);
Expand Down
5 changes: 5 additions & 0 deletions src/MassTransit/Courier/ExecuteActivityHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public async Task Send(ConsumeContext<RoutingSlip> context, IPipe<ConsumeContext
if (executeContext.Result == null || !executeContext.Result.IsFaulted(out var faultException) || faultException != exception)
executeContext.Result = executeContext.Faulted(exception);

await context.NotifyFaulted(timer.Elapsed, TypeCache<TActivity>.ShortName, exception).ConfigureAwait(false);

activity?.AddExceptionEvent(exception);
instrument?.AddException(exception);

await executeContext.Result.Evaluate().ConfigureAwait(false);
}

Expand Down

0 comments on commit 8ef45cf

Please sign in to comment.