示例#1
0
        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;
        }
示例#3
0
        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();
        }
示例#4
0
 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);
 }
示例#5
0
		/// <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);
		}
示例#6
0
        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)
				
			};
		}
示例#8
0
        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()
            });
        }
示例#9
0
        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)

            };
        }
示例#10
0
        /// <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);
        }
示例#11
0
 /// <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();
 }
示例#14
0
		private static void EndRequest(object sender, RequestResultArgs e) {
			GlimpseTimer.Stop("Query - " + e.Url);
		}