Extensions to the Polly libraries to enrich telemetry with metadata and exception summaries.
$ dotnet add package Microsoft.Extensions.ResilienceExtensions to the Polly libraries to enrich telemetry with metadata and exception summaries.
From the command-line:
dotnet add package Microsoft.Extensions.Resilience
Or directly in the C# project file:
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Resilience" Version="[CURRENTVERSION]" />
</ItemGroup>
The services can be registered using the following method:
public static IServiceCollection AddResilienceEnricher(this IServiceCollection services)
This will optionally consume the IExceptionSummarizer service if it has been registered and add that data to Polly's telemetry. It will also include RequestMetadata that can be set or retrieved with these extensions:
public static void SetRequestMetadata(this ResilienceContext context, RequestMetadata requestMetadata)
public static RequestMetadata? GetRequestMetadata(this ResilienceContext context)
See the Polly docs for details about working with ResilienceContext.
We welcome feedback and contributions in our GitHub repo.