Testing your instrumentation
The idea of testing logs might look wild – logs are not intended to stay in one place or retain a specific structure. It’s not the case for traces.
Instrumentation directly affects your ability to evaluate production health and usage. Testing auto-instrumentation could be limited to basic happy case validation – we only need to check that it’s enabled and emits some data in the right format. This would help us detect potential problems with dependency updates. Manual instrumentation needs more attention.
Let’s see how we can test any instrumentation in ASP.NET Core applications. We’re going to rely on the integration testing capabilities provided by the Microsoft.AspNetCore.Mvc.Testing
NuGet package. You can find more details about it in the ASP.NET Core testing documentation available at https://learn.microsoft.com/aspnet/core/test/integration-tests. It allows us to modify the ASP.NET Core application’...