< Summary

Information
Class: Elsa.Resilience.RetryTelemetryListener
Assembly: Elsa.Resilience.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Resilience.Core/Services/RetryTelemetryListener.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 12
Coverable lines: 12
Total lines: 27
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Write(...)0%4260%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Resilience.Core/Services/RetryTelemetryListener.cs

#LineLine coverage
 1using Elsa.Resilience.Models;
 2using Elsa.Workflows;
 3using Polly.Retry;
 4using Polly.Telemetry;
 5
 6namespace Elsa.Resilience;
 7
 8public class RetryTelemetryListener : TelemetryListener
 9{
 10    public override void Write<TResult, TArgs>(in TelemetryEventArguments<TResult, TArgs> args)
 11    {
 012        if (args.Event.EventName != "OnRetry" || args.Arguments is not OnRetryArguments<TResult> retryArgs)
 013            return;
 14
 015        var ctx = args.Context;
 16
 017        if (!ctx.Properties.TryGetValue<ActivityExecutionContext>(new(nameof(ActivityExecutionContext)), out var activit
 018            return;
 19
 020        var attempt = retryArgs.AttemptNumber;
 021        var delay = retryArgs.RetryDelay;
 022        var outcome = retryArgs.Outcome;
 023        var record = new RetryAttempt(activityExecutionContext, attempt, delay, outcome.Result, outcome.Exception);
 024        var records = (List<RetryAttempt>)activityExecutionContext.TransientProperties[RetryAttempt.RetriesKey];
 025        records.Add(record);
 026    }
 27}