Commit 73b375b7 authored by justcoding121's avatar justcoding121

#466 Added diagnostic timer

parent 6ab646f5
using System;
using System.Collections.Generic;
using System.Net;
using System.Threading;
using StreamExtended;
......@@ -25,6 +26,11 @@ namespace Titanium.Web.Proxy.EventArguments
protected readonly IBufferPool bufferPool;
protected readonly ExceptionHandler exceptionFunc;
/// <summary>
/// Relative milliseconds for various events.
/// </summary>
public Dictionary<string, DateTime> TimeLine { get; set; } = new Dictionary<string, DateTime>();
/// <summary>
/// Initializes a new instance of the <see cref="SessionEventArgsBase" /> class.
/// </summary>
......@@ -34,6 +40,7 @@ namespace Titanium.Web.Proxy.EventArguments
bufferSize = server.BufferSize;
bufferPool = server.BufferPool;
exceptionFunc = server.ExceptionFunc;
TimeLine.Add("Session Created", DateTime.Now);
}
protected SessionEventArgsBase(ProxyServer server, ProxyEndPoint endPoint,
......
......@@ -165,6 +165,8 @@ namespace Titanium.Web.Proxy
//we need this to syphon out data from connection if API user changes them.
request.SetOriginalHeaders();
args.TimeLine.Add("Request Received", DateTime.Now);
// If user requested interception do it
await invokeBeforeRequest(args);
......@@ -213,6 +215,8 @@ namespace Titanium.Web.Proxy
//for connection pool, retry fails until cache is exhausted.
var result = await retryPolicy<ServerConnectionException>().ExecuteAsync(async (serverConnection) =>
{
args.TimeLine.Add("Server Connection Created", DateTime.Now);
// if upgrading to websocket then relay the request without reading the contents
if (request.UpgradeToWebSocket)
{
......@@ -378,6 +382,8 @@ namespace Titanium.Web.Proxy
{
await handleHttpSessionResponse(args);
}
args.TimeLine.Add("Response Sent", DateTime.Now);
}
/// <summary>
......
using System.Net;
using System;
using System.Net;
using System.Threading.Tasks;
using Titanium.Web.Proxy.EventArguments;
using Titanium.Web.Proxy.Extensions;
......@@ -23,6 +24,8 @@ namespace Titanium.Web.Proxy
// read response & headers from server
await args.WebSession.ReceiveResponse(cancellationToken);
args.TimeLine.Add("Response Received", DateTime.Now);
var response = args.WebSession.Response;
args.ReRequest = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment