<PackageReference Include="Polly.Core" Version="8.5.1" />

ResilienceStrategyTelemetry

public sealed class ResilienceStrategyTelemetry
Resilience telemetry is used by individual resilience strategies to report some important events.
using Polly.Utils; using System.ComponentModel; using System.Runtime.CompilerServices; namespace Polly.Telemetry { [NullableContext(1)] [Nullable(0)] public sealed class ResilienceStrategyTelemetry { internal bool Enabled { get; } [Nullable(2)] [field: Nullable(2)] internal TelemetryListener Listener { [NullableContext(2)] get; } internal ResilienceTelemetrySource TelemetrySource { get; } internal ResilienceStrategyTelemetry(ResilienceTelemetrySource source, [Nullable(2)] TelemetryListener listener) { TelemetrySource = source; Listener = listener; Enabled = (listener != null); } [EditorBrowsable(EditorBrowsableState.Never)] public void SetTelemetrySource(ExecutionRejectedException exception) { Guard.NotNull(exception, "exception"); exception.TelemetrySource = TelemetrySource; } public void Report<[Nullable(2)] TArgs>(ResilienceEvent resilienceEvent, ResilienceContext context, TArgs args) { Guard.NotNull(context, "context"); if (Listener != null && resilienceEvent.Severity != 0) { TelemetryListener listener = Listener; TelemetryEventArguments<object, TArgs> args2 = new TelemetryEventArguments<object, TArgs>(TelemetrySource, resilienceEvent, context, args, (Outcome<object>?)null); listener.Write<object, TArgs>(ref args2); } } public void Report<[Nullable(2)] TArgs, [Nullable(2)] TResult>(ResilienceEvent resilienceEvent, ResilienceContext context, [Nullable(new byte[] { 0, 1 })] Outcome<TResult> outcome, TArgs args) { if (Listener != null && resilienceEvent.Severity != 0) { TelemetryListener listener = Listener; TelemetryEventArguments<TResult, TArgs> args2 = new TelemetryEventArguments<TResult, TArgs>(TelemetrySource, resilienceEvent, context, args, (Outcome<TResult>?)outcome); listener.Write<TResult, TArgs>(ref args2); } } internal void Report<[Nullable(0)] TArgs, [Nullable(2)] TResult>(ResilienceEvent resilienceEvent, TArgs args) where TArgs : IOutcomeArguments<TResult> { if (Listener != null && resilienceEvent.Severity != 0) { TelemetryListener listener = Listener; TelemetryEventArguments<TResult, TArgs> args2 = new TelemetryEventArguments<TResult, TArgs>(TelemetrySource, resilienceEvent, ((IOutcomeArguments<TResult>)args).Context, args, (Outcome<TResult>?)((IOutcomeArguments<TResult>)args).Outcome); listener.Write<TResult, TArgs>(ref args2); } } } }