Skip to content
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

test: improve default correlation unit tests #501

Conversation

stijnmoreels
Copy link
Member

Improve asynchronous default correlation unit tests.

Closes #344

@netlify
Copy link

netlify bot commented Jan 4, 2023

Deploy Preview for arcus-observability ready!

Name Link
🔨 Latest commit 435fa84
🔍 Latest deploy log https://app.netlify.com/sites/arcus-observability/deploys/63b7da8d2dcbea000895ce05
😎 Deploy Preview https://deploy-preview-501--arcus-observability.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

DefaultCorrelationInfoAccessor.Instance.SetCorrelationInfo(
new CorrelationInfo(operationId, transactionId));
await Task.Run(() => DefaultCorrelationInfoAccessor.Instance.SetCorrelationInfo(
new CorrelationInfo(operationId, transactionId)));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, we avoid the warning here but it is actually a bad practice, as it is by no means necessary to startup another thread just for this. See also this: https://blog.stephencleary.com/2013/11/taskrun-etiquette-examples-using.html

Why is the SetCorrelationInfoAsync method even declared as async ? I don't think that is even necessary ?
Moreover, I think this complete testcase can be synchronous ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test case was made because we had a problem with setting our correlation in an asynchronously setting. It really is a unit test to secure this fix.
Also note that this is testing deprecated functionality.

Copy link
Member

@fgheysels fgheysels Jan 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah.
In that case, it would have been good if the name of the test described that we're specifically testing this in an async context.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added ...InAsyncContext to the test's name.

@fgheysels fgheysels assigned stijnmoreels and unassigned fgheysels Jan 5, 2023
DefaultCorrelationInfoAccessor.Instance.SetCorrelationInfo(
new CorrelationInfo(operationId, transactionId));
await Task.Run(() => DefaultCorrelationInfoAccessor.Instance.SetCorrelationInfo(
new CorrelationInfo(operationId, transactionId)));
}
Copy link
Member

@fgheysels fgheysels Jan 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah.
In that case, it would have been good if the name of the test described that we're specifically testing this in an async context.

@fgheysels fgheysels assigned stijnmoreels and unassigned fgheysels Jan 6, 2023
@stijnmoreels stijnmoreels merged commit 013f964 into arcus-azure:main Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve DefaultCorrelationInfoAccessor tests
2 participants