public override async Task UnaryServerHandler()

in src/Middleware/Grpc/Server/CtxLogger.cs [29:59]


    public override async Task<TResponse> UnaryServerHandler<TRequest, TResponse>(
        TRequest request,
        ServerCallContext context,
        UnaryServerMethod<TRequest, TResponse> continuation)
    {
        if (request is IMessage message)
        {
            var req = FilterLogs(message);
            var ctxDictionary = new Dictionary<string, object>
            {
                { Constants.MethodFieldKey, context.Method },
                { "request", req },
                // readding here since source field seems to get removed, even after adding in interceptor.cs
                { "source", "CtxLog" },
                { Constants.RequestIDLogKey, RequestIdInterceptor.GetRequestID(context) }
            };
            // Serialize the dictionary to a JSON string
            var jsonCtxDict = JsonConvert.SerializeObject(ctxDictionary, new JsonSerializerSettings{TypeNameHandling = TypeNameHandling.Auto});
            context.RequestHeaders.Add("ctxlog-data", jsonCtxDict);
        }

        try
        {
            return await continuation(request, context);
        }
        catch (Exception ex)
        {
            _logger.Error(ex, $"Error thrown by {context.Method}.");
            throw;
        }
    }