dotnet / dotnet/extensions

Improve discoverability of DI prerequisites in AspNetCore.Diagnostics.Middleware package

Open
#4,684 0 comments 4 reactions 0 assignees View on GitHub
area-telemetry enhancement
Dominant language
C#
Stars
3.2k
Forks
894
Avg merge
1d 12h
Merged PRs (30d)
23

Description

Similar to #4675.

Currently if you want to enable either HttpLogging enrichment or redaction you have to know that you need to reference `Microsoft.Extensions.Compliance.Redaction` package and register `AddRedaction()` in the `IServiceCollection`. If you don't do that you'll get an exception saying that service container cannot find `IRedactorProvider`. As a solution, we can make `IRedactorProvider` optional, and use `NullRedactor` when it is not registered.

Another issue is that `AddHttpLogEnricher` in addition to registering HttpLogEnricher registers redaction. It could be unobvious from user's perspective. For example, a user registers only HttpLogEnricher and he/she doesn't expect that it will require `IRedactorProvider`, but the package will and during start up the application will throw the exception mentioned above.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.