Add request number counting to incoming HTTP requests in the same way that this was already being done for outgoing HTTP requests.

This allows us to associate debug logging messages with the right request.
It also allows us to put a request number on 'long request' logging even if other debug logging is not enabled, which gives us some idea of whether every request is suffering this problem or only some.
This is a separate internal number not associated with any incoming number in the opensim-request-id header, this will be clarified when logging of this incoming request number is re-enabled.
This commit also adds port number to HTTP IN logging to allow us to distinguish between different request numbers on different ports.
0.7.4-extended
Justin Clark-Casey (justincc) 2012-09-21 00:09:17 +01:00
parent 1ebde81d6a
commit 6739f0752b
2 changed files with 42 additions and 19 deletions

View File

@ -62,6 +62,15 @@ namespace OpenSim.Framework.Servers.HttpServer
/// </value> /// </value>
public int DebugLevel { get; set; } public int DebugLevel { get; set; }
/// <summary>
/// Request number for diagnostic purposes.
/// </summary>
/// <remarks>
/// This is an internal number. In some debug situations an external number may also be supplied in the
/// opensim-request-id header but we are not currently logging this.
/// </remarks>
public int RequestNumber { get; private set; }
private volatile int NotSocketErrors = 0; private volatile int NotSocketErrors = 0;
public volatile bool HTTPDRunning = false; public volatile bool HTTPDRunning = false;
@ -302,6 +311,8 @@ namespace OpenSim.Framework.Servers.HttpServer
private void OnRequest(object source, RequestEventArgs args) private void OnRequest(object source, RequestEventArgs args)
{ {
RequestNumber++;
try try
{ {
IHttpClientContext context = (IHttpClientContext)source; IHttpClientContext context = (IHttpClientContext)source;
@ -411,7 +422,6 @@ namespace OpenSim.Framework.Servers.HttpServer
string requestMethod = request.HttpMethod; string requestMethod = request.HttpMethod;
string uriString = request.RawUrl; string uriString = request.RawUrl;
// string reqnum = "unknown";
int requestStartTick = Environment.TickCount; int requestStartTick = Environment.TickCount;
// Will be adjusted later on. // Will be adjusted later on.
@ -535,8 +545,8 @@ namespace OpenSim.Framework.Servers.HttpServer
if (DebugLevel >= 3) if (DebugLevel >= 3)
m_log.DebugFormat( m_log.DebugFormat(
"[BASE HTTP SERVER]: HTTP IN {0} content type handler {1} {2} from {3}", "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}",
request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); RequestNumber, Port, request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint);
buffer = HandleHTTPRequest(request, response); buffer = HandleHTTPRequest(request, response);
break; break;
@ -547,8 +557,8 @@ namespace OpenSim.Framework.Servers.HttpServer
if (DebugLevel >= 3) if (DebugLevel >= 3)
m_log.DebugFormat( m_log.DebugFormat(
"[BASE HTTP SERVER]: HTTP IN {0} content type handler {1} {2} from {3}", "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}",
request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); RequestNumber, Port, request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint);
buffer = HandleLLSDRequests(request, response); buffer = HandleLLSDRequests(request, response);
break; break;
@ -641,7 +651,8 @@ namespace OpenSim.Framework.Servers.HttpServer
if (tickdiff > 3000) if (tickdiff > 3000)
{ {
m_log.InfoFormat( m_log.InfoFormat(
"[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} from {4} took {5}ms", "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms",
RequestNumber,
requestMethod, requestMethod,
uriString, uriString,
requestHandler != null ? requestHandler.Name : "", requestHandler != null ? requestHandler.Name : "",
@ -652,12 +663,9 @@ namespace OpenSim.Framework.Servers.HttpServer
else if (DebugLevel >= 4) else if (DebugLevel >= 4)
{ {
m_log.DebugFormat( m_log.DebugFormat(
"[BASE HTTP SERVER]: HTTP IN {0} {1} {2} {3} from {4} took {5}ms", "[BASE HTTP SERVER]: HTTP IN {0} :{1} took {2}ms",
requestMethod, RequestNumber,
uriString, Port,
requestHandler != null ? requestHandler.Name : "",
requestHandler != null ? requestHandler.Description : "",
request.RemoteIPEndPoint,
tickdiff); tickdiff);
} }
} }
@ -666,8 +674,14 @@ namespace OpenSim.Framework.Servers.HttpServer
private void LogIncomingToStreamHandler(OSHttpRequest request, IRequestHandler requestHandler) private void LogIncomingToStreamHandler(OSHttpRequest request, IRequestHandler requestHandler)
{ {
m_log.DebugFormat( m_log.DebugFormat(
"[BASE HTTP SERVER]: HTTP IN stream handler {0} {1} {2} {3} from {4}", "[BASE HTTP SERVER]: HTTP IN {0} :{1} stream handler {2} {3} {4} {5} from {6}",
request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description, request.RemoteIPEndPoint); RequestNumber,
Port,
request.HttpMethod,
request.Url.PathAndQuery,
requestHandler.Name,
requestHandler.Description,
request.RemoteIPEndPoint);
if (DebugLevel >= 5) if (DebugLevel >= 5)
LogIncomingInDetail(request); LogIncomingInDetail(request);
@ -676,8 +690,13 @@ namespace OpenSim.Framework.Servers.HttpServer
private void LogIncomingToContentTypeHandler(OSHttpRequest request) private void LogIncomingToContentTypeHandler(OSHttpRequest request)
{ {
m_log.DebugFormat( m_log.DebugFormat(
"[BASE HTTP SERVER]: HTTP IN {0} content type handler {1} {2} from {3}", "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}",
request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); RequestNumber,
Port,
request.ContentType,
request.HttpMethod,
request.Url.PathAndQuery,
request.RemoteIPEndPoint);
if (DebugLevel >= 5) if (DebugLevel >= 5)
LogIncomingInDetail(request); LogIncomingInDetail(request);
@ -686,8 +705,12 @@ namespace OpenSim.Framework.Servers.HttpServer
private void LogIncomingToXmlRpcHandler(OSHttpRequest request) private void LogIncomingToXmlRpcHandler(OSHttpRequest request)
{ {
m_log.DebugFormat( m_log.DebugFormat(
"[BASE HTTP SERVER]: HTTP IN assumed generic XMLRPC request {0} {1} from {2}", "[BASE HTTP SERVER]: HTTP IN {0} :{1} assumed generic XMLRPC request {2} {3} from {4}",
request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); RequestNumber,
Port,
request.HttpMethod,
request.Url.PathAndQuery,
request.RemoteIPEndPoint);
if (DebugLevel >= 5) if (DebugLevel >= 5)
LogIncomingInDetail(request); LogIncomingInDetail(request);

View File

@ -64,7 +64,7 @@ namespace OpenSim.Framework
/// <summary> /// <summary>
/// Request number for diagnostic purposes. /// Request number for diagnostic purposes.
/// </summary> /// </summary>
public static int RequestNumber = 0; public static int RequestNumber { get; internal set; }
/// <summary> /// <summary>
/// this is the header field used to communicate the local request id /// this is the header field used to communicate the local request id