Skip to content

Commit

Permalink
Add TelemetrySource to RateLimiterRejectedException
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-csala committed Oct 17, 2024
1 parent 363bf4a commit 1971906
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 122 deletions.
2 changes: 1 addition & 1 deletion src/Polly.Core/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ Polly.CircuitBreaker.BrokenCircuitException.BrokenCircuitException(string! messa
Polly.CircuitBreaker.BrokenCircuitException.BrokenCircuitException(string! message, System.TimeSpan retryAfter, System.Exception! inner) -> void
Polly.CircuitBreaker.BrokenCircuitException.BrokenCircuitException(System.TimeSpan retryAfter) -> void
Polly.CircuitBreaker.BrokenCircuitException.RetryAfter.get -> System.TimeSpan?
Polly.Telemetry.ResilienceStrategyTelemetry.TelemetrySource.get -> Polly.Telemetry.ResilienceTelemetrySource!
Polly.Telemetry.ResilienceStrategyTelemetry.GetTelemetrySource() -> string!
16 changes: 13 additions & 3 deletions src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,21 @@ internal ResilienceStrategyTelemetry(ResilienceTelemetrySource source, Telemetry

internal TelemetryListener? Listener { get; }

internal ResilienceTelemetrySource TelemetrySource { get; }

Check failure on line 22 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / mutations-legacy

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 22 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / mutations-legacy

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 22 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / mutations-legacy

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 22 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / mutations-core

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 22 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / mutations-core

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 22 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / mutations-core

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 22 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / windows-latest

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 22 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / windows-latest

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 22 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / windows-latest

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

#pragma warning (disable: S4049 CA1024)

Check warning on line 24 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / build-docs

Expected 'disable' or 'restore'

Check warning on line 24 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / build-docs

Expected 'disable' or 'restore'

Check warning on line 24 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / build-docs

Expected 'disable' or 'restore'

Check warning on line 24 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / build-docs

Expected 'disable' or 'restore'

Check warning on line 24 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / build-docs

Expected 'disable' or 'restore'

Check failure on line 24 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / mutations-legacy

Expected 'disable' or 'restore'

Check failure on line 24 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / mutations-legacy

Expected 'disable' or 'restore'

Check failure on line 24 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / mutations-legacy

Expected 'disable' or 'restore'

Check failure on line 24 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / mutations-core

Expected 'disable' or 'restore'

Check failure on line 24 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / mutations-core

Expected 'disable' or 'restore'

Check failure on line 24 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / mutations-core

Expected 'disable' or 'restore'

Check failure on line 24 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / windows-latest

Expected 'disable' or 'restore'

Check failure on line 24 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / windows-latest

Expected 'disable' or 'restore'

Check failure on line 24 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / windows-latest

Expected 'disable' or 'restore'
/// <summary>
/// Gets BlahBlahBlah.
/// Returns the concatenated telemetry source.
/// </summary>
/// <value>dummy.</value>
public ResilienceTelemetrySource TelemetrySource { get; } // Fix visibility
/// <returns>The concatenated telemetry source.</returns>
public string GetTelemetrySource()
{
var pipelineName = TelemetrySource?.PipelineName ?? "(null)";
var pipelineInstanceName = TelemetrySource?.PipelineInstanceName ?? "(null)";
var strategyName = TelemetrySource?.StrategyName ?? "(null)";
return $"{pipelineName}/{pipelineInstanceName}/{strategyName}";
}

Check failure on line 35 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / mutations-legacy

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 35 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / mutations-core

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 35 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / windows-latest

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)
#pragma warning (restore S4049 CA1024)

Check warning on line 36 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / build-docs

Expected 'disable' or 'restore'

Check warning on line 36 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / build-docs

Expected 'disable' or 'restore'

Check warning on line 36 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / build-docs

Expected 'disable' or 'restore'

Check warning on line 36 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / build-docs

Expected 'disable' or 'restore'

Check warning on line 36 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / build-docs

Expected 'disable' or 'restore'

Check failure on line 36 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / mutations-legacy

Expected 'disable' or 'restore'

Check failure on line 36 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / mutations-legacy

Expected 'disable' or 'restore'

Check failure on line 36 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / mutations-legacy

Expected 'disable' or 'restore'

Check failure on line 36 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / mutations-core

Expected 'disable' or 'restore'

Check failure on line 36 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / mutations-core

Expected 'disable' or 'restore'

Check failure on line 36 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / mutations-core

Expected 'disable' or 'restore'

Check failure on line 36 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / windows-latest

Expected 'disable' or 'restore'

Check failure on line 36 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / windows-latest

Expected 'disable' or 'restore'

Check failure on line 36 in src/Polly.Core/Telemetry/ResilienceStrategyTelemetry.cs

View workflow job for this annotation

GitHub Actions / windows-latest

Expected 'disable' or 'restore'

/// <summary>
/// Reports an event that occurred in a resilience strategy.
Expand Down
10 changes: 4 additions & 6 deletions src/Polly.RateLimiting/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#nullable enable
Polly.RateLimiting.RateLimiterRejectedException.RateLimiterRejectedException(Polly.Telemetry.ResilienceTelemetrySource! telemetrySource) -> void
Polly.RateLimiting.RateLimiterRejectedException.RateLimiterRejectedException(Polly.Telemetry.ResilienceTelemetrySource! telemetrySource, System.TimeSpan retryAfter) -> void
Polly.RateLimiting.RateLimiterRejectedException.RateLimiterRejectedException(string! message, Polly.Telemetry.ResilienceTelemetrySource! telemetrySource) -> void
Polly.RateLimiting.RateLimiterRejectedException.RateLimiterRejectedException(string! message, Polly.Telemetry.ResilienceTelemetrySource! telemetrySource, System.Exception! inner) -> void
Polly.RateLimiting.RateLimiterRejectedException.RateLimiterRejectedException(string! message, Polly.Telemetry.ResilienceTelemetrySource! telemetrySource, System.TimeSpan retryAfter) -> void
Polly.RateLimiting.RateLimiterRejectedException.RateLimiterRejectedException(string! message, Polly.Telemetry.ResilienceTelemetrySource! telemetrySource, System.TimeSpan retryAfter, System.Exception! inner) -> void
Polly.RateLimiting.RateLimiterRejectedException.RateLimiterRejectedException(string! message, string! telemetrySource) -> void
Polly.RateLimiting.RateLimiterRejectedException.RateLimiterRejectedException(string! message, string! telemetrySource, System.Exception! inner) -> void
Polly.RateLimiting.RateLimiterRejectedException.RateLimiterRejectedException(string! message, string! telemetrySource, System.TimeSpan retryAfter) -> void
Polly.RateLimiting.RateLimiterRejectedException.RateLimiterRejectedException(string! message, string! telemetrySource, System.TimeSpan retryAfter, System.Exception! inner) -> void
Polly.RateLimiting.RateLimiterRejectedException.TelemetrySource.get -> string?
62 changes: 10 additions & 52 deletions src/Polly.RateLimiting/RateLimiterRejectedException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#endif
using System.Threading.RateLimiting;

using Polly.Telemetry;

namespace Polly.RateLimiting;

/// <summary>
Expand All @@ -23,14 +21,6 @@ public RateLimiterRejectedException()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="RateLimiterRejectedException"/> class.
/// </summary>
/// <param name="telemetrySource">The source pipeline and strategy names.</param>
public RateLimiterRejectedException(ResilienceTelemetrySource telemetrySource)
: base("The operation could not be executed because it was rejected by the rate limiter.")
=> TelemetrySource = ComposeTelemetrySource(telemetrySource);

/// <summary>
/// Initializes a new instance of the <see cref="RateLimiterRejectedException"/> class.
/// </summary>
Expand All @@ -39,15 +29,6 @@ public RateLimiterRejectedException(TimeSpan retryAfter)
: base($"The operation could not be executed because it was rejected by the rate limiter. It can be retried after '{retryAfter}'.")
=> RetryAfter = retryAfter;

/// <summary>
/// Initializes a new instance of the <see cref="RateLimiterRejectedException"/> class.
/// </summary>
/// <param name="telemetrySource">The source pipeline and strategy names.</param>
/// <param name="retryAfter">The retry after value.</param>
public RateLimiterRejectedException(ResilienceTelemetrySource telemetrySource, TimeSpan retryAfter)
: base($"The operation could not be executed because it was rejected by the rate limiter. It can be retried after '{retryAfter}'.")
=> (TelemetrySource, RetryAfter) = (ComposeTelemetrySource(telemetrySource), retryAfter);

/// <summary>
/// Initializes a new instance of the <see cref="RateLimiterRejectedException"/> class.
/// </summary>
Expand All @@ -62,9 +43,9 @@ public RateLimiterRejectedException(string message)
/// </summary>
/// <param name="message">The message that describes the error.</param>
/// <param name="telemetrySource">The source pipeline and strategy names.</param>
public RateLimiterRejectedException(string message, ResilienceTelemetrySource telemetrySource)
public RateLimiterRejectedException(string message, string telemetrySource)
: base(message)
=> TelemetrySource = ComposeTelemetrySource(telemetrySource);
=> TelemetrySource = telemetrySource;

/// <summary>
/// Initializes a new instance of the <see cref="RateLimiterRejectedException"/> class.
Expand All @@ -81,9 +62,9 @@ public RateLimiterRejectedException(string message, TimeSpan retryAfter)
/// <param name="message">The message that describes the error.</param>
/// <param name="telemetrySource">The source pipeline and strategy names.</param>
/// <param name="retryAfter">The retry after value.</param>
public RateLimiterRejectedException(string message, ResilienceTelemetrySource telemetrySource, TimeSpan retryAfter)
public RateLimiterRejectedException(string message, string telemetrySource, TimeSpan retryAfter)
: base(message)
=> (TelemetrySource, RetryAfter) = (ComposeTelemetrySource(telemetrySource), retryAfter);
=> (TelemetrySource, RetryAfter) = (telemetrySource, retryAfter);

/// <summary>
/// Initializes a new instance of the <see cref="RateLimiterRejectedException"/> class.
Expand All @@ -101,9 +82,9 @@ public RateLimiterRejectedException(string message, Exception inner)
/// <param name="message">The message that describes the error.</param>
/// <param name="telemetrySource">The source pipeline and strategy names.</param>
/// <param name="inner">The inner exception.</param>
public RateLimiterRejectedException(string message, ResilienceTelemetrySource telemetrySource, Exception inner)
public RateLimiterRejectedException(string message, string telemetrySource, Exception inner)
: base(message, inner)
=> TelemetrySource = ComposeTelemetrySource(telemetrySource);
=> TelemetrySource = telemetrySource;

/// <summary>
/// Initializes a new instance of the <see cref="RateLimiterRejectedException"/> class.
Expand All @@ -122,9 +103,9 @@ public RateLimiterRejectedException(string message, TimeSpan retryAfter, Excepti
/// <param name="telemetrySource">The source pipeline and strategy names.</param>
/// <param name="retryAfter">The retry after value.</param>
/// <param name="inner">The inner exception.</param>
public RateLimiterRejectedException(string message, ResilienceTelemetrySource telemetrySource, TimeSpan retryAfter, Exception inner)
public RateLimiterRejectedException(string message, string telemetrySource, TimeSpan retryAfter, Exception inner)
: base(message, inner)
=> (TelemetrySource, RetryAfter) = (ComposeTelemetrySource(telemetrySource), retryAfter);
=> (TelemetrySource, RetryAfter) = (telemetrySource, retryAfter);

/// <summary>
/// Gets the amount of time to wait before retrying again.
Expand All @@ -140,14 +121,6 @@ public RateLimiterRejectedException(string message, ResilienceTelemetrySource te
/// </summary>
public string? TelemetrySource { get; }

private static string ComposeTelemetrySource(ResilienceTelemetrySource telemetrySource)
{
var pipelineName = telemetrySource?.PipelineName ?? "(null)";
var pipelineInstanceName = telemetrySource?.PipelineInstanceName ?? "(null)";
var strategyName = telemetrySource?.StrategyName ?? "(null)";
return $"{pipelineName}/{pipelineInstanceName}/{strategyName}";
}

#pragma warning disable RS0016 // Add public types and members to the declared API
#if !NETCOREAPP
/// <summary>
Expand Down Expand Up @@ -176,23 +149,8 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont
{
Guard.NotNull(info);

if (TelemetrySource is not null)
{
info.AddValue(nameof(TelemetrySource), TelemetrySource);
}
else
{
info.AddValue(nameof(TelemetrySource), "(null)/(null)/(null)");
}

if (RetryAfter.HasValue)
{
info.AddValue(nameof(RetryAfter), RetryAfter.Value.TotalSeconds);
}
else
{
info.AddValue(nameof(RetryAfter), -1.0);
}
info.AddValue(nameof(TelemetrySource), TelemetrySource ?? "(null)/(null)/(null)");
info.AddValue(nameof(RetryAfter), RetryAfter.HasValue ? RetryAfter.Value.TotalSeconds : -1.0);

base.GetObjectData(info, context);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Polly.RateLimiting/RateLimiterResilienceStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected override async ValueTask<Outcome<TResult>> ExecuteCore<TResult, TState
await OnLeaseRejected(new OnRateLimiterRejectedArguments(context, lease)).ConfigureAwait(context.ContinueOnCapturedContext);
}

var source = _telemetry.TelemetrySource;
var source = _telemetry.GetTelemetrySource();
var exception = retryAfter.HasValue ? new RateLimiterRejectedException(source, retryAfter.Value) : new RateLimiterRejectedException(source);

return Outcome.FromException<TResult>(exception.TrySetStackTrace());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,27 @@ public void Enabled_Ok()
new ResilienceStrategyTelemetry(_source, null).Enabled.Should().BeFalse();
}

[Fact]
public void GetTelemetrySource_Ok()
{
var source = new ResilienceTelemetrySource("builder", "instance", "strategy_name");
new ResilienceStrategyTelemetry(source, null).GetTelemetrySource().Should().Be("builder/instance/strategy_name");
}

[Fact]
public void GetTelemetrySource_Null_Ok()
{
ResilienceTelemetrySource? source = null;
new ResilienceStrategyTelemetry(source!, null).GetTelemetrySource().Should().Be("(null)/(null)/(null)");
}

[Fact]
public void GetTelemetrySource_Nulls_Ok()
{
var source = new ResilienceTelemetrySource(null, null, null);
new ResilienceStrategyTelemetry(source, null).GetTelemetrySource().Should().Be("(null)/(null)/(null)");
}

[Fact]
public void Report_NoOutcome_OK()
{
Expand Down
64 changes: 5 additions & 59 deletions test/Polly.RateLimiting.Tests/RateLimiterRejectedExceptionTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Polly.RateLimiting;
using Polly.Telemetry;

namespace Polly.Core.Tests.Timeout;

Expand All @@ -8,7 +7,6 @@ public class RateLimiterRejectedExceptionTests
private readonly string _telemetrySource = "MyPipeline/MyPipelineInstance/MyRateLimiterStrategy";
private readonly string _message = "dummy";
private readonly TimeSpan _retryAfter = TimeSpan.FromSeconds(4);
private readonly ResilienceTelemetrySource _source = new("MyPipeline", "MyPipelineInstance", "MyRateLimiterStrategy");

[Fact]
public void Ctor_Ok()
Expand All @@ -20,48 +18,6 @@ public void Ctor_Ok()
exception.TelemetrySource.Should().BeNull();
}

[Fact]
public void Ctor_TelemetrySource_Ok()
{
var exception = new RateLimiterRejectedException(_source);
exception.InnerException.Should().BeNull();
exception.Message.Should().Be("The operation could not be executed because it was rejected by the rate limiter.");
exception.RetryAfter.Should().BeNull();
exception.TelemetrySource.Should().Be(_telemetrySource);
}

[Fact]
public void Ctor_TelemetrySource_Null_Ok()
{
// Arrange
ResilienceTelemetrySource? source = null;

// Act
var exception = new RateLimiterRejectedException(source!);

// Assert
exception.InnerException.Should().BeNull();
exception.Message.Should().Be("The operation could not be executed because it was rejected by the rate limiter.");
exception.RetryAfter.Should().BeNull();
exception.TelemetrySource.Should().Be("(null)/(null)/(null)");
}

[Fact]
public void Ctor_TelemetrySource_Nulls_Ok()
{
// Arrange
var source = new ResilienceTelemetrySource(null, null, null);

// Act
var exception = new RateLimiterRejectedException(source);

// Arrange
exception.InnerException.Should().BeNull();
exception.Message.Should().Be("The operation could not be executed because it was rejected by the rate limiter.");
exception.RetryAfter.Should().BeNull();
exception.TelemetrySource.Should().Be("(null)/(null)/(null)");
}

[Fact]
public void Ctor_RetryAfter_Ok()
{
Expand All @@ -72,16 +28,6 @@ public void Ctor_RetryAfter_Ok()
exception.TelemetrySource.Should().BeNull();
}

[Fact]
public void Ctor_TelemetrySource_RetryAfter_Ok()
{
var exception = new RateLimiterRejectedException(_source, _retryAfter);
exception.InnerException.Should().BeNull();
exception.Message.Should().Be($"The operation could not be executed because it was rejected by the rate limiter. It can be retried after '00:00:04'.");
exception.RetryAfter.Should().Be(_retryAfter);
exception.TelemetrySource.Should().Be(_telemetrySource);
}

[Fact]
public void Ctor_Message_Ok()
{
Expand All @@ -95,7 +41,7 @@ public void Ctor_Message_Ok()
[Fact]
public void Ctor_Message_TelemetrySource_Ok()
{
var exception = new RateLimiterRejectedException(_message, _source);
var exception = new RateLimiterRejectedException(_message, _telemetrySource);
exception.InnerException.Should().BeNull();
exception.Message.Should().Be(_message);
exception.RetryAfter.Should().BeNull();
Expand All @@ -115,7 +61,7 @@ public void Ctor_Message_RetryAfter_Ok()
[Fact]
public void Ctor_Message_TelemetrySource_RetryAfter_Ok()
{
var exception = new RateLimiterRejectedException(_message, _source, _retryAfter);
var exception = new RateLimiterRejectedException(_message, _telemetrySource, _retryAfter);
exception.InnerException.Should().BeNull();
exception.Message.Should().Be(_message);
exception.RetryAfter.Should().Be(_retryAfter);
Expand All @@ -135,7 +81,7 @@ public void Ctor_Message_InnerException_Ok()
[Fact]
public void Ctor_Message_TelemetrySource_InnerException_Ok()
{
var exception = new RateLimiterRejectedException(_message, _source, new InvalidOperationException());
var exception = new RateLimiterRejectedException(_message, _telemetrySource, new InvalidOperationException());
exception.InnerException.Should().BeOfType<InvalidOperationException>();
exception.Message.Should().Be(_message);
exception.RetryAfter.Should().BeNull();
Expand All @@ -155,7 +101,7 @@ public void Ctor_Message_RetryAfter_InnerException_Ok()
[Fact]
public void Ctor_Message_TelemetrySource_RetryAfter_InnerException_Ok()
{
var exception = new RateLimiterRejectedException(_message, _source, _retryAfter, new InvalidOperationException());
var exception = new RateLimiterRejectedException(_message, _telemetrySource, _retryAfter, new InvalidOperationException());
exception.InnerException.Should().BeOfType<InvalidOperationException>();
exception.Message.Should().Be(_message);
exception.RetryAfter.Should().Be(_retryAfter);
Expand All @@ -173,7 +119,7 @@ public void BinaryDeserialization_Ok()
result = SerializeAndDeserializeException(new RateLimiterRejectedException());
result.RetryAfter.Should().BeNull();

result = SerializeAndDeserializeException(new RateLimiterRejectedException(_source));
result = SerializeAndDeserializeException(new RateLimiterRejectedException(_telemetrySource));
result.TelemetrySource.Should().Be(_telemetrySource);
}

Expand Down

0 comments on commit 1971906

Please sign in to comment.