Esempio n. 1
0
 private async Task LogRequest(string metricsKey)
 {
     var action = new RequestLog {
         Path    = Request.Path,
         Query   = Request.QueryString.Value,
         Headers = Request.Headers.GroupBy(s => s.Key)
                   .ToDictionary(s => s.Key, s => s.SelectMany(v => v.Value).ToArray())
     };
     var ip = Request.Headers["CF-Connecting-IP"].FirstOrDefault() ??
              Request.Headers["X-Forwarded-For"].FirstOrDefault() ??
              Request.HttpContext.Connection.RemoteIpAddress.ToString();
     await _sql.IngestAccess(ip, action.ToJson());
 }