public override async Task UnaryServerHandler()

in src/Middleware/Grpc/Server/ServerApiRequestLogger.cs [16:50]


    public override async Task<TResponse> UnaryServerHandler<TRequest, TResponse>(
        TRequest request,
        ServerCallContext context,
        UnaryServerMethod<TRequest, TResponse> continuation)
    {
        DateTime start = DateTime.Now;
        string peerAddress = ParsePeerAddress(context.Peer);

        var apiRequestLogger = _logger.ForContext(Constants.ComponentFieldKey, Constants.ComponentValueServer)
                            .ForContext(Constants.MethodTypeFieldKey, MethodType.Unary.ToString().ToLower())
                            .ForContext(Constants.RequestIDLogKey, RequestIdInterceptor.GetRequestID(context))
                            .ForContext(Constants.StartTimeKey, start.ToString("yyyy-MM-ddTHH:mm:sszzz"))
                            .ForContext(Constants.PeerAddressKey, peerAddress)
                            .WithServiceProperties(context.Method)
                            // readding here since source field seems to get removed, even after adding in interceptor.cs
                            .ForContext("source", "ApiRequestLog");

        try
        {
            return await continuation(request, context);
        }
        catch (Exception ex)
        {
            apiRequestLogger.Error(ex, $"Error thrown by {context.Method}.");
            throw;
        }
        finally
        {
            var duration = DateTime.Now - start;
            apiRequestLogger = apiRequestLogger.ForContext(Constants.StatusCodeKey, context.Status.StatusCode)
                                               .ForContext(Constants.TimeMsKey, duration.TotalMilliseconds);

            apiRequestLogger.Information("finished call");
        }
    }