-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Allow changing the severity of resilience events #2072
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine to me - just needs docs and tests!
src/Snippets/Docs/Telemetry.cs
Outdated
telemetryOptions.SeverityProvider = ev => | ||
{ | ||
if (ev.EventName == "OnRetry") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if we would expose all the telemetry event name constants via a simple static class then the branching logic would safer. It would also help users of the API to use switch expression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would require to expose a lot of public members for a limited audience. Let's wait and see. My vote would be to not expose anything unless absolutely necessary. Consumers of this API can just hardcode the strings, these won't change anyway as they are considered public contract as part of telemetry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this specific case you could also do nameof(RetryStrategyOptions<>.OnRetry)
(I think).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nameof
won't work for all cases. For example
- in case of rate limiter
OnRateLimiterRejected
event name vsOnRejected
options property - in case of circuit breaker
OnCircuitHalfOpened
event name vsOnHalfOpened
options property - in case of latency
Chaos.OnLatency
event name vsOnLatencyInjected
options property - etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would require to expose a lot of public members for a limited audience. Let's wait and see. My vote would be to not expose anything unless absolutely necessary. Consumers of this API can just hardcode the strings, these won't change anyway as they are considered public contract as part of telemetry.
If you are saying that it is already implicitly part of the public contract then I don't see why it is a problem to make it explicit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just more public area to cover :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can consider adding it at a later date if this functionality becomes popular and there's user demand for it.
This would meet my needs. Thanks for the heads up! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2072 +/- ##
==========================================
+ Coverage 83.69% 83.77% +0.07%
==========================================
Files 312 313 +1
Lines 7114 7148 +34
Branches 1054 1055 +1
==========================================
+ Hits 5954 5988 +34
Misses 789 789
Partials 371 371
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
docs/advanced/telemetry.md
Outdated
return args.Event.Severity; | ||
}; | ||
|
||
builder.AddTimeout(TimeSpan.FromSeconds(1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example seems a bit pointless because
- you have a single Timeout strategy
- and you override the
OnRetry
telemetry event's severity
Can you either override the OnTimeout
or add a Retry strategy to the pipeline?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@martintmk Are you planning on any other PRs anytime soon? If not, once this is merged we can do an 8.4.0 to release this and the other recent changes. |
I am thinking about finalizing the nullability changes during the weekend and that one chaos outcome strategy bug where exceptions are ignored. |
Hi @martintmk, Thank you for supporting this feature! We currently configure Polly using the public static IHttpStandardResiliencePipelineBuilder AddResilienceStrategies(this IHttpClientBuilder builder) => builder
.AddStandardResilienceHandler()
.Configure((options, serviceProvider) =>
{
// configure ...
}); We add the standard resilience strategies to each typed http client. Is it possible to set the event severity with the above approach? |
You can configure global
|
Pull Request
The issue or feature being addressed
#1859
Details on the issue fix or feature implementation
This can be used to customize the severity of resilience events as:
Confirm the following