Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public ValueTask IsolateCircuitAsync(ResilienceContext context)
lock (_lock)
{
var exception = new IsolatedCircuitException();
_telemetry.UpdateTelemetrySource(exception);
_telemetry.SetTelemetrySource(exception);
SetLastHandledOutcome_NeedsLock(Outcome.FromException<T>(exception));
OpenCircuitFor_NeedsLock(Outcome.FromResult<T>(default), TimeSpan.MaxValue, manual: true, context, out task);
_circuitState = CircuitState.Isolated;
Expand Down Expand Up @@ -159,7 +159,7 @@ public ValueTask CloseCircuitAsync(ResilienceContext context)

if (exception is not null)
{
_telemetry.UpdateTelemetrySource(exception);
_telemetry.SetTelemetrySource(exception);
return Outcome.FromException<T>(exception);
}

Expand Down Expand Up @@ -311,12 +311,12 @@ private void SetLastHandledOutcome_NeedsLock(Outcome<T> outcome)
private BrokenCircuitException CreateBrokenCircuitException()
{
TimeSpan retryAfter = _blockedUntil - _timeProvider.GetUtcNow();
BrokenCircuitException exception = _breakingException switch
var exception = _breakingException switch
{
Exception ex => new BrokenCircuitException(BrokenCircuitException.DefaultMessage, retryAfter, ex),
_ => new BrokenCircuitException(BrokenCircuitException.DefaultMessage, retryAfter)
};
_telemetry.UpdateTelemetrySource(exception);
_telemetry.SetTelemetrySource(exception);
return exception;
}

Expand Down
1 change: 0 additions & 1 deletion src/Polly.Core/ExecutionRejectedException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,4 @@ protected ExecutionRejectedException(SerializationInfo info, StreamingContext co
/// Gets the source of the strategy which has thrown the exception, if known.
/// </summary>
public virtual ResilienceTelemetrySource? TelemetrySource { get; internal set; }

}
2 changes: 1 addition & 1 deletion src/Polly.Core/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Polly.CircuitBreaker.BrokenCircuitException.BrokenCircuitException(string! messa
Polly.CircuitBreaker.BrokenCircuitException.BrokenCircuitException(System.TimeSpan retryAfter) -> void
Polly.CircuitBreaker.BrokenCircuitException.RetryAfter.get -> System.TimeSpan?
virtual Polly.ExecutionRejectedException.TelemetrySource.get -> Polly.Telemetry.ResilienceTelemetrySource?
Polly.Telemetry.ResilienceStrategyTelemetry.UpdateTelemetrySource(Polly.ExecutionRejectedException! exception) -> void
Polly.Telemetry.ResilienceStrategyTelemetry.SetTelemetrySource(Polly.ExecutionRejectedException! exception) -> void
4 changes: 2 additions & 2 deletions src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ internal ResilienceStrategyTelemetry(ResilienceTelemetrySource source, Telemetry
internal ResilienceTelemetrySource TelemetrySource { get; }

/// <summary>
/// Updates the source of the telemetry on the provided exception.
/// Sets the source of the telemetry on the provided exception.
/// </summary>
/// <param name="exception">The to-be-updated exception.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
public void UpdateTelemetrySource(ExecutionRejectedException exception)
public void SetTelemetrySource(ExecutionRejectedException exception)
{
Guard.NotNull(exception);

Expand Down
2 changes: 1 addition & 1 deletion src/Polly.Core/Timeout/TimeoutResilienceStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected internal override async ValueTask<Outcome<TResult>> ExecuteCore<TResul
timeout,
e);

_telemetry.UpdateTelemetrySource(timeoutException);
_telemetry.SetTelemetrySource(timeoutException);
return Outcome.FromException<TResult>(timeoutException.TrySetStackTrace());
}

Expand Down
6 changes: 3 additions & 3 deletions src/Polly.RateLimiting/RateLimiterResilienceStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ protected override async ValueTask<Outcome<TResult>> ExecuteCore<TResult, TState
await OnLeaseRejected(new OnRateLimiterRejectedArguments(context, lease)).ConfigureAwait(context.ContinueOnCapturedContext);
}

var exception = retryAfter.HasValue
? new RateLimiterRejectedException(retryAfter.Value)
var exception = retryAfter is not null
? new RateLimiterRejectedException(retryAfterValue)
: new RateLimiterRejectedException();

_telemetry.UpdateTelemetrySource(exception);
_telemetry.SetTelemetrySource(exception);

return Outcome.FromException<TResult>(exception.TrySetStackTrace());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,22 @@ public void Report_NoListener_ShouldNotThrow()
}

[Fact]
public void UpdateTelemetrySource_Ok()
public void SetTelemetrySource_Ok()
{
var sut = new ResilienceStrategyTelemetry(_source, null);
var exception = new TimeoutRejectedException();

sut.UpdateTelemetrySource(exception);
sut.SetTelemetrySource(exception);

exception.TelemetrySource.Should().Be(_source);
}

[Fact]
public void UpdateTelemetrySource_ShouldThrow()
public void SetTelemetrySource_ShouldThrow()
{
ExecutionRejectedException? exception = null;

_sut.Invoking(s => s.UpdateTelemetrySource(exception!))
_sut.Invoking(s => s.SetTelemetrySource(exception!))
.Should()
.Throw<ArgumentNullException>();
}
Expand Down