mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 08:55:56 +08:00
Make number of inbound http requests handled available as a httpserver.<port>.IncomingHTTPRequestsProcessed stat
This commit is contained in:
@@ -27,8 +27,9 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
using log4net;
|
||||
using OpenMetaverse.StructuredData;
|
||||
|
||||
namespace OpenSim.Framework.Monitoring
|
||||
@@ -38,6 +39,8 @@ namespace OpenSim.Framework.Monitoring
|
||||
/// </summary>
|
||||
public class Stat : IDisposable
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
/// <summary>
|
||||
/// Category of this stat (e.g. cache, scene, etc).
|
||||
/// </summary>
|
||||
@@ -204,6 +207,8 @@ namespace OpenSim.Framework.Monitoring
|
||||
if (m_samples.Count >= m_maxSamples)
|
||||
m_samples.Dequeue();
|
||||
|
||||
// m_log.DebugFormat("[STAT]: Recording value {0} for {1}", newValue, Name);
|
||||
|
||||
m_samples.Enqueue(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private HttpServerLogWriter httpserverlog = new HttpServerLogWriter();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This is a pending websocket request before it got an sucessful upgrade response.
|
||||
/// The consumer must call handler.HandshakeAndUpgrade() to signal to the handler to
|
||||
@@ -81,6 +80,11 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
/// </remarks>
|
||||
public int RequestNumber { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Statistic for holding number of requests processed.
|
||||
/// </summary>
|
||||
private Stat m_requestsProcessedStat;
|
||||
|
||||
private volatile int NotSocketErrors = 0;
|
||||
public volatile bool HTTPDRunning = false;
|
||||
|
||||
@@ -436,9 +440,8 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
}
|
||||
}
|
||||
|
||||
public void OnHandleRequestIOThread(IHttpClientContext context, IHttpRequest request)
|
||||
private void OnHandleRequestIOThread(IHttpClientContext context, IHttpRequest request)
|
||||
{
|
||||
|
||||
OSHttpRequest req = new OSHttpRequest(context, request);
|
||||
WebSocketRequestDelegate dWebSocketRequestDelegate = null;
|
||||
lock (m_WebSocketHandlers)
|
||||
@@ -454,8 +457,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
|
||||
OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context);
|
||||
resp.ReuseContext = true;
|
||||
HandleRequest(req, resp);
|
||||
|
||||
HandleRequest(req, resp);
|
||||
|
||||
// !!!HACK ALERT!!!
|
||||
// There seems to be a bug in the underlying http code that makes subsequent requests
|
||||
@@ -1824,6 +1826,21 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
// useful without inbound HTTP.
|
||||
throw e;
|
||||
}
|
||||
|
||||
m_requestsProcessedStat
|
||||
= new Stat(
|
||||
"IncomingHTTPRequestsProcessed",
|
||||
"Number of inbound HTTP requests processed",
|
||||
"",
|
||||
"requests",
|
||||
"httpserver",
|
||||
Port.ToString(),
|
||||
StatType.Pull,
|
||||
MeasuresOfInterest.AverageChangeOverTime,
|
||||
stat => stat.Value = RequestNumber,
|
||||
StatVerbosity.Debug);
|
||||
|
||||
StatsManager.RegisterStat(m_requestsProcessedStat);
|
||||
}
|
||||
|
||||
public void httpServerDisconnectMonitor(IHttpClientContext source, SocketError err)
|
||||
@@ -1854,6 +1871,9 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
public void Stop()
|
||||
{
|
||||
HTTPDRunning = false;
|
||||
|
||||
StatsManager.DeregisterStat(m_requestsProcessedStat);
|
||||
|
||||
try
|
||||
{
|
||||
m_PollServiceManager.Stop();
|
||||
|
||||
@@ -34,6 +34,7 @@ using System.Text;
|
||||
using System.Xml;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
using OpenSim.Framework.Servers;
|
||||
using log4net;
|
||||
using log4net.Config;
|
||||
@@ -205,6 +206,9 @@ namespace OpenSim.Server.Base
|
||||
|
||||
public virtual int Run()
|
||||
{
|
||||
Watchdog.Enabled = true;
|
||||
MemoryWatchdog.Enabled = true;
|
||||
|
||||
while (m_Running)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -745,6 +745,7 @@
|
||||
<Reference name="Mono.Addins.Setup" path="../../../bin/"/>
|
||||
<Reference name="OpenSim.Framework"/>
|
||||
<Reference name="OpenSim.Framework.Console"/>
|
||||
<Reference name="OpenSim.Framework.Monitoring"/>
|
||||
<Reference name="OpenSim.Framework.Servers"/>
|
||||
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
|
||||
<Reference name="Nini" path="../../../bin/"/>
|
||||
|
||||
Reference in New Issue
Block a user