-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update activity status on failure MySqlDataReader. #1171
Conversation
Signed-off-by: qq362220083 <362220083@qq.com>
public static void SetSuccess(this Activity activity) => activity.SetTag(StatusCodeTagName, "OK"); | ||
public static void SetSuccess(this Activity activity) | ||
{ | ||
if (activity.Duration == TimeSpan.Zero) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, is this a workaround for a lack of an IsStopped
property (dotnet/runtime#63353) to check if the Activity is still running? A comment would be helpful here, but I think checking Status
would be clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uh, activity only supports Status
property in .net 6 and above.
Here is the resolve to set the Exception first, and then set the Success to cause the state to be overwritten.
set the Exception should have the highest priority.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks; I hadn't checked the docs thoroughly to see where the API was available.
{ | ||
activity.SetException(ex); | ||
activity.Stop(); | ||
} | ||
dataReader.Dispose(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MySqlDataReader.DisposeAsync
will still Stop the activity and set it to successful. Seems like that logic ought to change to if if (Activity.Status == ActivityStatusCode.Unset)
to avoid overwriting the status if it's already an error.
Thanks! This is definitely an omission in MySqlConnector's activity-handling code; thanks for fixing it. Left just a couple of comments about state management in the face of tracking this exception. |
Signed-off-by: qq362220083 <362220083@qq.com>
Thanks for the contribution! This is included in 2.1.9. |
When MySqlDataReader has exception, the activity status needs to be updated.