TelemetryUtil
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace Polly.Telemetry
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
internal static class TelemetryUtil
{
internal const string PollyDiagnosticSource = "Polly";
internal const string ExecutionAttempt = "ExecutionAttempt";
[System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1
})]
internal static readonly ResiliencePropertyKey<string> StrategyKey = new ResiliencePropertyKey<string>("Polly.StrategyKey");
public static ResilienceStrategyTelemetry CreateTelemetry([System.Runtime.CompilerServices.Nullable(2)] DiagnosticSource diagnosticSource, [System.Runtime.CompilerServices.Nullable(2)] string builderName, ResilienceProperties builderProperties, [System.Runtime.CompilerServices.Nullable(2)] string strategyName, string strategyType)
{
return new ResilienceStrategyTelemetry(new ResilienceTelemetrySource(builderName, builderProperties, strategyName, strategyType), diagnosticSource);
}
public static void ReportExecutionAttempt<[System.Runtime.CompilerServices.Nullable(2)] TResult>(ResilienceStrategyTelemetry telemetry, ResilienceContext context, [System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1
})] Outcome<TResult> outcome, int attempt, TimeSpan executionTime, bool handled)
{
if (telemetry.IsEnabled) {
ExecutionAttemptArguments executionAttemptArguments = ExecutionAttemptArguments.Get(attempt, executionTime, handled);
telemetry.Report("ExecutionAttempt", new OutcomeArguments<TResult, ExecutionAttemptArguments>(context, outcome, executionAttemptArguments));
ExecutionAttemptArguments.Return(executionAttemptArguments);
}
}
}
}