Key4.Grpc.LogPropertyInterceptor 1.0.0.7-b
Key4.Grpc.LogPropertyInterceptor
Collection de middlewares et d'Intercepteurs gRPC pour .NET permettant de propager des propriétés entre microservices dans le but de les exposer au logger.
Si la configuration du projet est "Development" ou "Staging", renvois le message et la pile d'appel de l'exception. Pour toute autre configuration, ne renvoie que le message.
Configuration
Startup
Ajouter l'intercepteur à la configuration gRPC dans Startup.cs du projet gRPC serveur.
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
...
services.AddGrpc(options => options.Interceptors.Add<ServerExceptionInterceptor>());
}
Exemple
Exemple d'erreur renvoyé par un client gRPC lorsqu'une exception est levée au niveau du serveur.
Exemple d'erreur lorsque l'environement est Development ou Staging.
Grpc.Core.RpcException: Status(StatusCode="Internal", Detail="Id must be specified")
Exemple d'erreur lorsque l'environement n'est pas Development ou Staging.
Grpc.Core.RpcException: Status(StatusCode="Internal", Detail="Id must be specified
at key4.Infrastructure.Genericity.CQRS.BaseCommandHandler`4.Validation(TQuery request) in C:\Repos\key4register.core\Infrastructure\key4.Infrastructure.Genericity\CQRS\BaseCommandHandler.cs:line 38
at key4.Infrastructure.Genericity.CQRS.BaseUpdateCommandHandler`4.Handle(TQuery request, CancellationToken cancellationToken) in C:\Repos\key4register.core\Infrastructure\key4.Infrastructure.Genericity\CQRS\BaseUpdateCommandHandler.cs:line 19
at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 ne
...
No packages depend on Key4.Grpc.LogPropertyInterceptor.
.NET 5.0
- Grpc.Core.Api (>= 2.38.1)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 5.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 5.0.0)
| Version | Downloads | Last updated |
|---|---|---|
| 2.0.0.11-b | 11 | 12/08/2022 |
| 1.0.1.10-b | 13 | 12/08/2022 |
| 1.0.0.7-b | 11 | 12/08/2022 |
| 1.0.0.6-b | 12 | 12/08/2022 |