Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce ResilienceContext.OperationKey #1380

Merged
merged 1 commit into from
Jul 3, 2023
Merged

Conversation

martintmk
Copy link
Contributor

@martintmk martintmk commented Jul 3, 2023

Details on the issue fix or feature implementation

This PR introduces ResilienceContext.OperationKey that can be assigned to each ResilienceContext. It's immutable property that is specified at the time of the ResilienceContext creation:

var context = ResilienceContext.Get("my-operation");
var key = context.OperationKey; // my-operation

Operation key flows to telemetry and is included in logs and metrics. The main scenario is to distinguish the particular operation at call site and to improve the telemetry. It should have low cardinality.

This also fills the feature gap we had between Polly V7 and Polly V8.

Contributes to #1365

Confirm the following

  • I started this PR by branching from the head of the default branch
  • I have targeted the PR to merge into the default branch
  • I have included unit tests for the issue/feature
  • I have successfully run a local build

@martintmk martintmk added the v8 Issues related to the new version 8 of the Polly library. label Jul 3, 2023
@martintmk martintmk added this to the v8.0.0 milestone Jul 3, 2023
@codecov
Copy link

codecov bot commented Jul 3, 2023

Codecov Report

Merging #1380 (c1698f1) into main (158a2f8) will increase coverage by 0.04%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1380      +/-   ##
==========================================
+ Coverage   83.63%   83.68%   +0.04%     
==========================================
  Files         269      269              
  Lines        6411     6429      +18     
  Branches     1004     1004              
==========================================
+ Hits         5362     5380      +18     
  Misses        840      840              
  Partials      209      209              
Flag Coverage Δ
macos 83.68% <100.00%> (?)
windows 83.68% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...Core/CircuitBreaker/CircuitBreakerManualControl.cs 100.00% <100.00%> (ø)
src/Polly.Core/ResilienceContext.cs 100.00% <100.00%> (ø)
.../Polly.Core/ResilienceStrategy.Async.ValueTaskT.cs 100.00% <100.00%> (ø)
src/Polly.Core/ResilienceStrategy.SyncT.cs 100.00% <100.00%> (ø)
...s/Telemetry/ResilienceTelemetryDiagnosticSource.cs 100.00% <100.00%> (ø)
...xtensions/Telemetry/TelemetryResilienceStrategy.cs 100.00% <100.00%> (ø)
...lly/Utilities/Wrappers/ResilienceContextFactory.cs 100.00% <100.00%> (ø)

@martincostello
Copy link
Member

Are you planning on making any other new additions today? If not (or after them) I can look at publishing an alpha.5 with this change and the manual control changes and re-test in my app.

@martintmk
Copy link
Contributor Author

Are you planning on making any other new additions today? If not (or after them) I can look at publishing an alpha.5 with this change and the manual control changes and re-test in my app.

Nope, I think I am mostly done with V8 (until API review). I'll only address issues as they come based on the feedback.

@martintmk martintmk enabled auto-merge (squash) July 3, 2023 08:56
@martintmk martintmk merged commit a806318 into main Jul 3, 2023
12 checks passed
@martintmk martintmk deleted the mtomka/operationkey branch July 3, 2023 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v8 Issues related to the new version 8 of the Polly library.
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants