public RavenTiming(RequestResultArgs request, MiniProfiler profiler) : base(profiler, null, null) { if (profiler == null) throw new ArgumentNullException("profiler"); _requestUrl = request.Url; var commandTextBuilder = new StringBuilder(); // Basic request information // HTTP GET - 200 (Cached) commandTextBuilder.AppendFormat("HTTP {0} - {1} ({2})\n", request.Method, request.HttpResult, request.Status); // Request URL commandTextBuilder.AppendFormat("{0}\n\n", FormatUrl()); // Append query var query = FormatQuery(); if (!String.IsNullOrWhiteSpace(query)) { commandTextBuilder.AppendFormat("{0}\n\n", query); } // Append POSTed data, if any (multi-get, PATCH, etc.) if (!String.IsNullOrWhiteSpace(request.PostedData)) { commandTextBuilder.Append(request.PostedData); } // Set the command string to a formatted string CommandString = commandTextBuilder.ToString(); }
private static void IncludeTiming(RequestResultArgs request) { if (MiniProfiler.Current == null) return; var elapsedTicks = (long)ElapsedTicks.Invoke(MiniProfiler.Current, null); var elapsedSeconds = elapsedTicks / (double)Stopwatch.Frequency; var profilingStartedAt = DateTime.UtcNow.AddSeconds(-elapsedSeconds); #pragma warning disable 612,618 var secs = (request.At - profilingStartedAt).TotalSeconds; var timing = new SqlTiming // The default constructor is obsolete. We know about that; this is a hack anyway. { Id = Guid.NewGuid(), CommandString = FormatQuery(request.Url), StartMilliseconds = (decimal)secs * 1000, DurationMilliseconds = (decimal)request.DurationMilliseconds, FirstFetchDurationMilliseconds = (decimal)request.DurationMilliseconds, ExecuteType = ToExecuteType(request.Status), }; #pragma warning restore 612,618 MiniProfiler.Current.Head.AddSqlTiming(timing); MiniProfiler.Current.HasSqlTimings = true; }
private static string BuildCommandString(RequestResultArgs request) { var url = request.Url; var commandTextBuilder = new StringBuilder(); // Basic request information // HTTP GET - 200 (Cached) commandTextBuilder.AppendFormat("HTTP {0} - {1} ({2})\n", request.Method, request.HttpResult, request.Status); // Request URL commandTextBuilder.AppendFormat("{0}\n\n", FormatUrl(url)); // Append query var query = FormatQuery(url); if (!String.IsNullOrWhiteSpace(query)) { commandTextBuilder.AppendFormat("{0}\n\n", query); } // Append POSTed data, if any (multi-get, PATCH, etc.) if (!String.IsNullOrWhiteSpace(request.PostedData)) { commandTextBuilder.Append(request.PostedData); } // Set the command string to a formatted string return commandTextBuilder.ToString(); }
private static void EndRequest(object sender, RequestResultArgs e) { string queryName = e.Url.Split('?')[0]; if (queryName.StartsWith("/databases", StringComparison.InvariantCultureIgnoreCase)) { // Trim out the database prefix to the query queryName = "/" + String.Join("/", queryName.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Skip(2)); } NewRelic.Api.Agent.NewRelic.RecordResponseTimeMetric("RavenDB/Query" + queryName, (long)e.DurationMilliseconds); }
/// <summary> /// Register the action as associated with <param name="sender"/> /// </summary> public void RecordAction(object sender, RequestResultArgs requestResultArgs) { var profilingInformationHolder = sender as IHoldProfilingInformation; if (profilingInformationHolder == null) return; profilingInformationHolder.ProfilingInformation.Requests.Add(requestResultArgs); leastRecentlyUsedCache.Push(profilingInformationHolder.ProfilingInformation); }
private static void IncludeTiming(RequestResultArgs request) { if (MiniProfiler.Current == null || MiniProfiler.Current.Head == null) return; MiniProfiler.Current.Head.AddCustomTiming("raven", new RavenTiming(request, MiniProfiler.Current) { Id = Guid.NewGuid(), DurationMilliseconds = (decimal)request.DurationMilliseconds, FirstFetchDurationMilliseconds = (decimal)request.DurationMilliseconds, ExecuteType = request.Status.ToString() }); }
private RequestResultArgs FilterRequest(RequestResultArgs input) { return new RequestResultArgs { At = input.At, HttpResult = input.HttpResult, Method = input.Method, Status = input.Status, Url = input.Url, PostedData = FilterData(input.PostedData), Result = FilterData(input.Result) }; }
private static void IncludeTiming(RequestResultArgs request) { if (MiniProfiler.Current == null || MiniProfiler.Current.Head == null) return; var formattedRequest = JsonFormatter.FormatRequest(request); MiniProfiler.Current.Head.AddCustomTiming("raven", new CustomTiming(MiniProfiler.Current, BuildCommandString(formattedRequest)) { Id = Guid.NewGuid(), DurationMilliseconds = (decimal)formattedRequest.DurationMilliseconds, FirstFetchDurationMilliseconds = (decimal)formattedRequest.DurationMilliseconds, ExecuteType = formattedRequest.Status.ToString() }); }
public static RequestResultArgs FormatRequest(RequestResultArgs input) { return new RequestResultArgs { DurationMilliseconds = input.DurationMilliseconds, At = input.At, HttpResult = input.HttpResult, Method = input.Method, Status = input.Status, Url = input.Url, PostedData = FilterData(input.PostedData), Result = FilterData(input.Result) }; }
/// <summary> /// Register the action as associated with the sender /// </summary> public void RecordAction(object sender, RequestResultArgs requestResultArgs) { var profilingInformationHolder = sender as IHoldProfilingInformation; if (profilingInformationHolder == null) { return; } profilingInformationHolder.ProfilingInformation.Requests = new List <RequestResultArgs>(profilingInformationHolder.ProfilingInformation.Requests) { requestResultArgs }; leastRecentlyUsedCache.Push(profilingInformationHolder.ProfilingInformation); }
/// <summary> /// Invoke the LogRequest event /// </summary> internal void OnLogRequest(IHoldProfilingInformation sender, RequestResultArgs args) { var handler = LogRequest; if (handler != null) handler(sender, args); }
/// <summary> /// Invoke the LogRequest event /// </summary> internal void InvokeLogRequest(IHoldProfilingInformation sender, RequestResultArgs e) { var handler = LogRequest; if (handler != null) handler(sender, e); }
private static void EndRequest(object sender, RequestResultArgs e) { IDisposable request; if (_Requests.TryRemove(e.Url, out request)) if (request != null) request.Dispose(); }
private static void EndRequest(object sender, RequestResultArgs e) { GlimpseTimer.Stop("Query - " + e.Url); }