Skip to content

Commit 776fc60

Browse files
Merge pull request #3 from rogeralsing/patch-1
Fix double invocation of action
2 parents 35680c9 + 8967ae0 commit 776fc60

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Ubiquitous.Metrics/Metrics.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public static async Task<T> Measure<T>(
161161

162162
try {
163163
var task = action();
164-
result = task.IsCompleted ? task.Result : await action();
164+
result = task.IsCompleted ? task.Result : await task;
165165
}
166166
catch (Exception) {
167167
errorCount?.Inc(labels);
@@ -199,7 +199,7 @@ public static async Task<T> Measure<T>(
199199

200200
try {
201201
var task = action();
202-
result = task.IsCompleted ? task.Result : await action();
202+
result = task.IsCompleted ? task.Result : await task;
203203
}
204204
catch (Exception) {
205205
errorCount?.Inc(labels: labels);
@@ -238,7 +238,7 @@ public static async Task<T> Measure<T>(
238238

239239
try {
240240
var task = action();
241-
result = task.IsCompleted ? task.Result : await action();
241+
result = task.IsCompleted ? task.Result : await task;
242242
}
243243
catch (Exception) {
244244
errorCount?.Inc(labels);
@@ -253,4 +253,4 @@ public static async Task<T> Measure<T>(
253253
return result;
254254
}
255255
}
256-
}
256+
}

0 commit comments

Comments
 (0)