Skip to content

Commit cc7a881

Browse files
committed
Update activity status on failure execute.
Signed-off-by: qq362220083 <[email protected]>
1 parent 88a0fcf commit cc7a881

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/MySqlConnector/MySqlDataReader.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,13 @@ internal static async Task<MySqlDataReader> CreateAsync(CommandListPosition comm
474474
await dataReader.NextResultAsync(ioBehavior, cancellationToken).ConfigureAwait(false);
475475
}
476476
}
477-
catch (Exception)
477+
catch (Exception ex)
478478
{
479+
if (activity is { IsAllDataRequested: true })
480+
{
481+
activity.SetException(ex);
482+
activity.Stop();
483+
}
479484
dataReader.Dispose();
480485
throw;
481486
}

src/MySqlConnector/Utilities/ActivitySourceHelper.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ internal static class ActivitySourceHelper
3636
return activity;
3737
}
3838

39-
public static void SetSuccess(this Activity activity) => activity.SetTag(StatusCodeTagName, "OK");
39+
public static void SetSuccess(this Activity activity)
40+
{
41+
if (activity.Duration == TimeSpan.Zero)
42+
{
43+
activity.SetTag(StatusCodeTagName, "OK");
44+
}
45+
}
4046

4147
public static void SetException(this Activity activity, Exception exception)
4248
{

0 commit comments

Comments
 (0)