CcAcca.ApplicationInsights.ProblemDetails
2.0.0
dotnet add package CcAcca.ApplicationInsights.ProblemDetails --version 2.0.0
NuGet\Install-Package CcAcca.ApplicationInsights.ProblemDetails -Version 2.0.0
<PackageReference Include="CcAcca.ApplicationInsights.ProblemDetails" Version="2.0.0" />
paket add CcAcca.ApplicationInsights.ProblemDetails --version 2.0.0
#r "nuget: CcAcca.ApplicationInsights.ProblemDetails, 2.0.0"
// Install CcAcca.ApplicationInsights.ProblemDetails as a Cake Addin #addin nuget:?package=CcAcca.ApplicationInsights.ProblemDetails&version=2.0.0 // Install CcAcca.ApplicationInsights.ProblemDetails as a Cake Tool #tool nuget:?package=CcAcca.ApplicationInsights.ProblemDetails&version=2.0.0
ApplicationInsights.ProblemDetails
Overview
MS Application Insights integration for the Hellang.Middleware.ProblemDetails package.
Enriches request telemetry with custom dimensions extracted from a ProblemDetail response:
Usage
Prerequisites
Ensure your ASP.Net Core application has been configured with:
- MS Application Insights SDK; see official guidance
- Hellang.Middleware.ProblemDetails package. For guidance see:
Steps
Install package
dotnet add package CcAcca.ApplicationInsights.ProblemDetails
Register the library with .Net Core dependency injection system. In
Statup.ConfigureServices
method add:services.AddProblemDetailTelemetryInitializer()
Configuration / customization
Configure which ProblemDetail responses are sent to application insights:
services.AddProblemDetailTelemetryInitializer(o => { o.ShouldSend = (ctx, problem) => problem.Status >= StatusCodes.Status500InternalServerError; })
Configure which properties of an ProblemDetail should be sent to application insights:
services.AddProblemDetailTelemetryInitializer(o => { o.IncludeErrorsValue = (ctx, problem) => !SensitiveUrl(ctx); o.IncludeExtensionsValue = (ctx, problem) => !SensitiveUrl(ctx); o.IncludeRawJson = (ctx, problem) => !SensitiveUrl(ctx); });
Configure the values of the dimensions sent to application insights:
services.AddProblemDetailTelemetryInitializer(o => { o.MapDimensions = (ctx, problem, dimensions) => { var sensitiveFields = new[] {"SSN", "SocialSecurityNumber", "AccountNumber"}; var isSensitive = dimensions.Any(d => sensitiveFields.Any(f => d.Key.Contains(f))); var sanitized = isSensitive ? dimensions .Where(d => !sensitiveFields.Concat(new[] {DefaultDimensionCollector.RawDimensionKey}) .Any(f => d.Key.Contains(f))) : dimensions; return new Dictionary<string, string>(sanitized); }; });
Configure when a ProblemDetail should be considered a success/failure
// only status codes >= 500 treat as a failure services.AddProblemDetailTelemetryInitializer(options => { options.IsFailure = ProblemDetailsTelemetryOptions.ServerErrorIsFailure; });
Override the default serializer: see
ProblemDetailsTelemetryOptions.SerializeValue
Override the default dimension collector for low level control: see
DefaultDimensionCollector
Develop
To build and run tests you can use:
- the dotnet cli tool
- any IDE/editor that understands MSBuild eg Visual Studio or Visual Studio Code
Recommended workflow
- Develop on a feature branch created from master:
- create a branch from master.
- perform all the code changes into the newly created branch.
- merge master into your branch, then run tests locally (eg
dotnet test src/CcAcca.ApplicationInsights.ProblemDetails.Tests
) - on the new branch, bump the version number in CcAcca.ApplicationInsights.ProblemDetails.csproj; follow semver
- update CHANGELOG.md
- raise the PR (pull request) for code review & merge request to master branch.
- PR will auto trigger a limited CI build (compile and test only)
- approval of the PR will merge your branch code changes into the master
CI server
Github actions is used to run the dotnet cli tool to perform the build and test. See the yaml build definition for details.
Notes:
- The CI build is configured to run on every commit to any branch
- PR completion to master will also publish the nuget package for CcAcca.ApplicationInsights.ProblemDetails to Nuget gallery
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Hellang.Middleware.ProblemDetails (>= 5.0.0)
- Microsoft.ApplicationInsights.AspNetCore (>= 2.21.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.0.0 | 59,031 | 11/18/2023 |
2.0.0-beta.2 | 118 | 9/17/2023 |
2.0.0-beta.1 | 73 | 9/17/2023 |
1.1.1 | 112,320 | 12/2/2021 |
1.1.0 | 31,549 | 6/2/2021 |
1.0.2 | 945 | 6/1/2021 |
1.0.1 | 941 | 4/20/2021 |
1.0.0 | 1,112 | 3/29/2021 |