ASP.NET Core MVC tracing.
dotnet add package Byndyusoft.AspNetCore.Instrumentation.Tracing
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers()
.AddTracing();
...
}
}
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers()
.AddTracing(options =>
{
options.TagRequestParamsInTrace = true;
options.EnrichLogsWithParams = true;
options.EnrichLogsWithHttpInfo = true;
options.ValueMaxStringLength = 50;
options.Formatter = new SystemTextJsonFormatter
{
Options = new JsonSerializerOptions(JsonSerializerDefaults.Web)
{
Converters =
{
new JsonStringEnumConverter()
}
}
};
});
...
}
}
There are some default option parameters:
- EnrichTraceWithTaggedRequestParams — if true then http request params will be added to trace tags. Default: true. For more detail how params are extracted, refer to page.
- EnrichLogsWithParams — if true then every log will be enriched with request params during this request. Default: true. For more detail how params are extracted, refer to page.
- EnrichLogsWithHttpInfo — if true then every log will be enriched with request http info during this request. Default: true.
- ValueMaxStringLength — maximum number of serialized request and response body string length. This string will be written to trace events and/or logs. The excess will be trimmed. Default: null - unlimited.
- Formatter — it is used to serialize request and response body. Default: SystemTextJsonFormatter.
Masked serialization package Byndyusoft.MaskedSerialization is used to hide sensitive data. Is it implemented in NewtonsoftJsonFormatter.cs class.
To contribute, you will need to setup your local environment, see prerequisites. For the contribution and workflow guide, see package development lifecycle.
A detailed overview on how to contribute can be found in the contributing guide.
Make sure you have installed all of the following prerequisites on your development machine:
- Git - Download & Install Git. OSX and Linux machines typically have this already installed.
- .NET Core (version 8.0 or higher) - Download & Install .NET Core.
- source code
- unit-tests
- example application
- Implement package logic in
src
- Add or addapt unit-tests (prefer before and simultaneously with coding) in
tests
- Add or change the documentation as needed
- Open pull request in the correct branch. Target the project's
master
branch