private void FinalizeRequestProcessing(RavenBaseApiController controller, HttpResponseMessage response, Stopwatch sw) { LogHttpRequestStatsParams logHttpRequestStatsParam = null; try { StringBuilder sb = null; if (controller.CustomRequestTraceInfo != null) { sb = new StringBuilder(); foreach (var action in controller.CustomRequestTraceInfo) { action(sb); sb.AppendLine(); } while (sb.Length > 0) { if (!char.IsWhiteSpace(sb[sb.Length - 1])) { break; } sb.Length--; } } logHttpRequestStatsParam = new LogHttpRequestStatsParams( sw, GetHeaders(controller.InnerHeaders), controller.InnerRequest.Method.Method, response != null ? (int)response.StatusCode : 500, controller.InnerRequest.RequestUri.ToString(), sb != null ? sb.ToString() : null ); } catch (Exception e) { Logger.WarnException("Could not gather information to log request stats", e); } if (logHttpRequestStatsParam == null || sw == null) { return; } sw.Stop(); controller.MarkRequestDuration(sw.ElapsedMilliseconds); LogHttpRequestStats(controller, logHttpRequestStatsParam, controller.TenantName); TraceRequest(logHttpRequestStatsParam, controller.TenantName); }
private void FinalizeRequestProcessing(RavenBaseApiController controller, HttpResponseMessage response, Stopwatch sw) { LogHttpRequestStatsParams logHttpRequestStatsParam = null; try { StringBuilder sb = null; if (controller.CustomRequestTraceInfo != null && controller.CustomRequestTraceInfo.Count > 0) { sb = new StringBuilder(); foreach (var action in controller.CustomRequestTraceInfo) { action(sb); sb.AppendLine(); } while (sb.Length > 0) { if (!char.IsWhiteSpace(sb[sb.Length - 1])) break; sb.Length--; } } logHttpRequestStatsParam = new LogHttpRequestStatsParams( sw, GetHeaders(controller.InnerHeaders), controller.InnerRequest.Method.Method, response != null ? (int)response.StatusCode : 500, controller.InnerRequest.RequestUri.ToString(), sb != null ? sb.ToString() : null, controller.InnerRequestsCount ); } catch (Exception e) { Logger.WarnException("Could not gather information to log request stats", e); } if (logHttpRequestStatsParam == null || sw == null) return; sw.Stop(); if (landlord.IsDatabaseLoaded(controller.TenantName ?? Constants.SystemDatabase)) { controller.MarkRequestDuration(sw.ElapsedMilliseconds); } var curReq = Interlocked.Increment(ref reqNum); LogHttpRequestStats(controller, logHttpRequestStatsParam, controller.TenantName, curReq); if (controller.IsInternalRequest == false) { TraceTraffic(controller, logHttpRequestStatsParam, controller.TenantName); } RememberRecentRequests(logHttpRequestStatsParam, controller.TenantName); }
private void FinalizeRequestProcessing(RavenBaseApiController controller, HttpResponseMessage response, Stopwatch sw) { LogHttpRequestStatsParams logHttpRequestStatsParam = null; try { StringBuilder sb = null; if (controller.CustomRequestTraceInfo != null) { sb = new StringBuilder(); foreach (var action in controller.CustomRequestTraceInfo) { action(sb); sb.AppendLine(); } while (sb.Length > 0) { if (!char.IsWhiteSpace(sb[sb.Length - 1])) break; sb.Length--; } } logHttpRequestStatsParam = new LogHttpRequestStatsParams( sw, GetHeaders(controller.InnerHeaders), controller.InnerRequest.Method.Method, response != null ? (int) response.StatusCode : 500, controller.InnerRequest.RequestUri.PathAndQuery, sb != null ? sb.ToString() : null ); } catch (Exception e) { Logger.WarnException("Could not gather information to log request stats", e); } if (logHttpRequestStatsParam == null || sw == null) return; sw.Stop(); controller.MarkRequestDuration(sw.ElapsedMilliseconds); LogHttpRequestStats(logHttpRequestStatsParam, controller.TenantName); TraceRequest(logHttpRequestStatsParam, controller.TenantName); }
private void FinalizeRequestProcessing(RavenBaseApiController controller, HttpResponseMessage response, Stopwatch sw) { LogHttpRequestStatsParams logHttpRequestStatsParam = null; try { StringBuilder sb = null; if (controller.CustomRequestTraceInfo != null && controller.CustomRequestTraceInfo.Count > 0) { sb = new StringBuilder(); foreach (var action in controller.CustomRequestTraceInfo) { try { action(sb); } catch (Exception e) { Logger.WarnException("Could not gather information to log request stats custom info, so far got " + sb, e); } sb.AppendLine(); } while (sb.Length > 0) { if (!char.IsWhiteSpace(sb[sb.Length - 1])) { break; } sb.Length--; } } var innerRequest = controller.InnerRequest; var httpRequestHeaders = innerRequest.Headers; var httpContentHeaders = innerRequest.Content == null ? null : innerRequest.Content.Headers; logHttpRequestStatsParam = new LogHttpRequestStatsParams( sw, new Lazy <HttpHeaders>(() => RavenBaseApiController.CloneRequestHttpHeaders(httpRequestHeaders, httpContentHeaders)), controller.InnerRequest.Method.Method, response != null ? (int)response.StatusCode : 500, controller.InnerRequest.RequestUri.ToString(), sb != null ? sb.ToString() : null, controller.InnerRequestsCount ); } catch (Exception e) { Logger.WarnException("Could not gather information to log request stats", e); } if (logHttpRequestStatsParam == null || sw == null) { return; } sw.Stop(); if (landlord.IsDatabaseLoaded(controller.TenantName ?? Constants.SystemDatabase)) { controller.MarkRequestDuration(sw.ElapsedMilliseconds); } var curReq = Interlocked.Increment(ref reqNum); LogHttpRequestStats(controller, logHttpRequestStatsParam, controller.TenantName, curReq); if (controller.IsInternalRequest == false) { TraceTraffic(controller, logHttpRequestStatsParam, controller.TenantName); } RememberRecentRequests(logHttpRequestStatsParam, controller.TenantName); }