Uncategorized

Trace logging with exception in Application Insights

By default, Masstransit logs retries as warnings if they are resolved by the retry process; otherwise, they are logged as errors. Additionally, Masstransit provides the exception in both cases for tracing purposes.

However, there’s a potential confusion when using Application Insights: it logs every entry with a supplied exception as an exception with an Exception severity level. Unfortunately, the severity level isn’t a presented field in the AI user interface, making it easy to overlook. Both our sysops and we developers misinterpret these logged entries as actual exceptions, which led to unnecessary investigation and troubleshooting.

To mitigate this confusion, remember that you can filter out these non-exceptional logs by specifying the severity level. Specifically, filtering for “Error” severity level will narrow down the logs to actual exceptions.

I hope this blog post can save others some valuable time and prevent unnecessary confusion and alarm. Happy coding!

Method color in Visual Studio 2019

I didn’t like the new color on methods in VS 2019. I tried to find which color I should change. I didn’t find one but you can revert to the 2017 style by disabling Tools > Options > Text Editor > C# > Advanced > Use enhanced colors for C# and Basic.

Sadly this reverts all of the 2019 color enhancements back to 2017. If any one know which color controls the method only please drop me a line.

Pathfinding and environmental awareness

We’ve produced a very short devlog about the pathfinding / environmental awareness part of the AI development process for Virtual Warfighter. It describes how we’ve solved the problem of allowing AI soldiers to make different pathfinding choices, more intelligent than just take the shortest path.

We will probably expand upon this in the future by describing more, such as how to make the AI avoid exposed routes in favor of more concealed ones, if possible.

All this is part of the work being done for our upcoming coop game mode.

Mini test suite for async CQS backend

Our backend consists of a WebApi backend sporting an async CQS API (Not involving Event sourcing). I wanted a fluent syntax setup for our scenario tests, here is an actual example from the resulting code. (Code removed that are customer specific)

[TestClass]
public class When_doing_a_complete_booking : BusinessTest
{
	private Booking _result;
	private DateTime _date;

	[TestInitialize]
	public void Context()
	{
		Guid bookingKey = Guid.Empty;
		_date = DateTime.Now.AddDays(5);

		_result = Given(db => /* Setup here */)
			.When(() => new SearchQuery{ Date = _date, ...})
			.And(result =>
			{
				bookingKey = result.First().BookingKey;
				return new ReserveCommand { BookingKey = bookingKey, ... };
			})
			.And(() => new ConfirmCommand
			{
				BookingKey = bookingKey, 
				...
			})
			.Then(db => db.Set<Booking>().FirstOrDefaultAsync(b => b.BookingKey == bookingKey));
	}

	[TestMethod]
	public void It_should_book_correctly ()
	{
		Assert.IsNotNull(_result);
		Assert.IsTrue(...);
	}
}

(more…)