Skip to content

Commit e827f8e

Browse files
authored
Merge pull request #1154 from OctopusDeploy/sast/sl/more-activities-in-tentacle-client
Add activity traces for retries
2 parents f076eb6 + 59c0517 commit e827f8e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

source/Octopus.Tentacle.Client/Execution/RpcCallExecutor.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,16 @@ public async Task<T> ExecuteWithRetries<T>(
6464

6565
try
6666
{
67+
var attemptNumber = 1;
6768
var response = await rpcCallRetryHandler.ExecuteWithRetries(
6869
async ct =>
6970
{
71+
using var attemptActivity = TentacleClient.ActivitySource.StartActivity($"{nameof(RpcCallExecutor)}.{nameof(ExecuteWithRetries)} - Attempt");
72+
attemptActivity?.AddTag("octopus.tentacle.rpc_call.service", rpcCall.Service);
73+
attemptActivity?.AddTag("octopus.tentacle.rpc_call.name", rpcCall.Name);
74+
attemptActivity?.AddTag("octopus.tentacle.rpc_call.attempt_number", attemptNumber);
75+
attemptNumber++;
76+
7077
var start = DateTimeOffset.UtcNow;
7178

7279
try
@@ -85,6 +92,7 @@ public async Task<T> ExecuteWithRetries<T>(
8592
onRetryAction: async (lastException, sleepDuration, retryCount, totalRetryDuration, elapsedDuration, _) =>
8693
{
8794
await Task.CompletedTask;
95+
activity?.AddEvent(new ActivityEvent("Retry"));
8896

8997
onErrorAction?.Invoke(lastException);
9098

@@ -95,6 +103,7 @@ public async Task<T> ExecuteWithRetries<T>(
95103
onTimeoutAction: async (timeoutDuration, elapsedDuration, retryCount, _) =>
96104
{
97105
await Task.CompletedTask;
106+
activity?.AddEvent(new ActivityEvent("Timeout"));
98107

99108
if (retryCount > 0)
100109
{

0 commit comments

Comments
 (0)