Add Attempt count to PolicyResult [general: expand info on Policy execution available in PolicyResult]
See original GitHub issueWe are using ExecuteAndCapture
in our application, the policy is defined in configuration but executed elsewhere. I’d like to log whether a retry has happened (and how many) but all I have is PolicyResult
to work from.
In one part of the app, we define a function which builds a policy:
config.BuildExceptionPolicy(() => Policy.Handle<IOxception>().RetryAsync(2));
And execute it in another:
var policy = step.BuildExceptionPolicy();
return policy.ExecuteAndCaptureAsync(async () => { ... } );
If the outcome is Failure, I log the final exception but along side that I’d like to log the number of attempts that were taken.
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
c# - Polly timeout policy clarification
When I analyze the policy result how do I understand if the timeout ... its timing-out CancellationToken into ct, during policy execution.
Read more >A YANG Data Model for Routing Policy RFC 9067
A YANG Data Model for Routing Policy (RFC 9067, October 2021)
Read more >K35932460: Troubleshooting | BIG-IP APM operations guide
Go to System > Logs > Configuration > Options > Access Policy. In Access Policy Logging, for Access Policy,SSO, Portal Access, and VDI,...
Read more >Pega Platform 8.7.4 Patch Resolved Issues
When attempting to migrate the rules schema to RULES85 and temp data schema DATA85, the upgrade was becoming stuck in a loop while...
Read more >Aruba ClearPass Policy Manager User Guide
Adding a Static Host List as an Authentication Source ... The ClearPass Policy Manager 6.6 User Guide provides a general overview of ClearPass...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @TrevorPilley.
Because of the way the Polly execute methods are generalised, capturing the number of attempts into the
PolicyResult
is not that straightforward..ExecuteAndCaptureAsync(...)
is agnostic to (and has no knowledge of) whether what is being run underneath is a retry policy, circuit-breaker policy without retries (or indeed some new kind of action-transforming policy in the future).An approach in the meantime could be something like :
@joelhulen : I suggest we leave this issue open for a while so that others can comment if they would also like additional execution metadata in
PolicyResult
.I think the proper way to do this now is with a context.