mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-04 01:24:49 +02:00
add detailed download stats for file/http/atp
This commit is contained in:
parent
ac55908e42
commit
3743cd23b4
5 changed files with 90 additions and 4 deletions
|
@ -111,6 +111,7 @@
|
|||
#include <RenderDeferredTask.h>
|
||||
#include <RenderForwardTask.h>
|
||||
#include <ResourceCache.h>
|
||||
#include <ResourceRequest.h>
|
||||
#include <SandboxUtils.h>
|
||||
#include <SceneScriptingInterface.h>
|
||||
#include <ScriptEngines.h>
|
||||
|
@ -1328,8 +1329,36 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
properties["active_downloads"] = loadingRequests.size();
|
||||
properties["pending_downloads"] = ResourceCache::getPendingRequestCount();
|
||||
|
||||
properties["processing_resources"] = DependencyManager::get<StatTracker>()->getStat("Processing").toInt();
|
||||
properties["pending_processing_resources"] = DependencyManager::get<StatTracker>()->getStat("PendingProcessing").toInt();
|
||||
auto statTracker = DependencyManager::get<StatTracker>();
|
||||
|
||||
properties["processing_resources"] = statTracker->getStat("Processing").toInt();
|
||||
properties["pending_processing_resources"] = statTracker->getStat("PendingProcessing").toInt();
|
||||
|
||||
properties["started_atp_requests"] = statTracker->getStat(STAT_ATP_REQUEST_STARTED).toInt();
|
||||
properties["started_http_requests"] = statTracker->getStat(STAT_HTTP_REQUEST_STARTED).toInt();
|
||||
properties["started_file_requests"] = statTracker->getStat(STAT_FILE_REQUEST_STARTED).toInt();
|
||||
auto totalRequestsStarted = properties["started_atp_requests"].toInt()
|
||||
+ properties["started_http_requests"].toInt() + properties["started_file_requests"].toInt();
|
||||
properties["started_requests"] = totalRequestsStarted;
|
||||
|
||||
properties["successful_atp_requests"] = statTracker->getStat(STAT_ATP_REQUEST_SUCCESS).toInt();
|
||||
properties["successful_http_requests"] = statTracker->getStat(STAT_HTTP_REQUEST_SUCCESS).toInt();
|
||||
properties["successful_file_requests"] = statTracker->getStat(STAT_FILE_REQUEST_SUCCESS).toInt();
|
||||
auto totalRequestsSuccessful = properties["successful_atp_requests"].toInt()
|
||||
+ properties["successful_http_requests"].toInt() + properties["successful_file_requests"].toInt();
|
||||
properties["successful_requests"] = totalRequestsSuccessful;
|
||||
|
||||
properties["failed_atp_requests"] = statTracker->getStat(STAT_ATP_REQUEST_FAILED).toInt();
|
||||
properties["failed_http_requests"] = statTracker->getStat(STAT_HTTP_REQUEST_FAILED).toInt();
|
||||
properties["failed_file_requests"] = statTracker->getStat(STAT_FILE_REQUEST_FAILED).toInt();
|
||||
auto totalRequestsFailed = properties["failed_atp_requests"].toInt()
|
||||
+ properties["failed_http_requests"].toInt() + properties["failed_file_requests"].toInt();
|
||||
properties["failed_requests"] = totalRequestsFailed;
|
||||
|
||||
properties["cache_atp_requests"] = statTracker->getStat(STAT_ATP_REQUEST_CACHE).toInt();
|
||||
properties["cache_http_requests"] = statTracker->getStat(STAT_HTTP_REQUEST_FAILED).toInt();
|
||||
auto totalRequestsCache = properties["cache_atp_requests"].toInt() + properties["cache_http_requests"].toInt();
|
||||
properties["cache_requests"] = totalRequestsCache;
|
||||
|
||||
properties["throttled"] = _displayPlugin ? _displayPlugin->isThrottled() : false;
|
||||
|
||||
|
|
|
@ -13,12 +13,14 @@
|
|||
|
||||
#include <QtCore/QLoggingCategory>
|
||||
|
||||
#include <Trace.h>
|
||||
#include <Profile.h>
|
||||
#include <StatTracker.h>
|
||||
|
||||
#include "AssetClient.h"
|
||||
#include "AssetUtils.h"
|
||||
#include "MappingRequest.h"
|
||||
#include "NetworkLogging.h"
|
||||
#include <Trace.h>
|
||||
#include <Profile.h>
|
||||
|
||||
static const int DOWNLOAD_PROGRESS_LOG_INTERVAL_SECONDS = 5;
|
||||
|
||||
|
@ -48,6 +50,8 @@ bool AssetResourceRequest::urlIsAssetHash(const QUrl& url) {
|
|||
}
|
||||
|
||||
void AssetResourceRequest::doSend() {
|
||||
DependencyManager::get<StatTracker>()->incrementStat(STAT_ATP_REQUEST_STARTED);
|
||||
|
||||
// We'll either have a hash or an ATP path to a file (that maps to a hash)
|
||||
if (urlIsAssetHash(_url)) {
|
||||
// We've detected that this is a hash - simply use AssetClient to request that asset
|
||||
|
@ -100,6 +104,8 @@ void AssetResourceRequest::requestMappingForPath(const AssetPath& path) {
|
|||
_state = Finished;
|
||||
emit finished();
|
||||
|
||||
DependencyManager::get<StatTracker>()->incrementStat(STAT_ATP_REQUEST_FAILED);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -140,10 +146,22 @@ void AssetResourceRequest::requestHash(const AssetHash& hash) {
|
|||
_result = Error;
|
||||
break;
|
||||
}
|
||||
|
||||
auto statTracker = DependencyManager::get<StatTracker>();
|
||||
|
||||
_state = Finished;
|
||||
emit finished();
|
||||
|
||||
if (_result == Success) {
|
||||
statTracker->incrementStat(STAT_ATP_REQUEST_SUCCESS);
|
||||
|
||||
if (loadedFromCache()) {
|
||||
statTracker->incrementStat(STAT_ATP_REQUEST_CACHE);
|
||||
}
|
||||
} else {
|
||||
statTracker->incrementStat(STAT_ATP_REQUEST_FAILED);
|
||||
}
|
||||
|
||||
_assetRequest->deleteLater();
|
||||
_assetRequest = nullptr;
|
||||
});
|
||||
|
|
|
@ -15,7 +15,12 @@
|
|||
|
||||
#include <QFile>
|
||||
|
||||
#include <StatTracker.h>
|
||||
|
||||
void FileResourceRequest::doSend() {
|
||||
auto statTracker = DependencyManager::get<StatTracker>();
|
||||
statTracker->incrementStat(STAT_FILE_REQUEST_STARTED);
|
||||
|
||||
QString filename = _url.toLocalFile();
|
||||
|
||||
// sometimes on windows, we see the toLocalFile() return null,
|
||||
|
@ -60,4 +65,10 @@ void FileResourceRequest::doSend() {
|
|||
|
||||
_state = Finished;
|
||||
emit finished();
|
||||
|
||||
if (_result == ResourceRequest::Success) {
|
||||
statTracker->incrementStat(STAT_FILE_REQUEST_SUCCESS);
|
||||
} else {
|
||||
statTracker->incrementStat(STAT_FILE_REQUEST_FAILED);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <QMetaEnum>
|
||||
|
||||
#include <SharedUtil.h>
|
||||
#include <StatTracker.h>
|
||||
|
||||
#include "NetworkAccessManager.h"
|
||||
#include "NetworkLogging.h"
|
||||
|
@ -49,6 +50,8 @@ void HTTPResourceRequest::cleanupTimer() {
|
|||
}
|
||||
|
||||
void HTTPResourceRequest::doSend() {
|
||||
DependencyManager::get<StatTracker>()->incrementStat(STAT_HTTP_REQUEST_STARTED);
|
||||
|
||||
QNetworkRequest networkRequest(_url);
|
||||
networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
|
||||
networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
|
@ -178,6 +181,17 @@ void HTTPResourceRequest::onRequestFinished() {
|
|||
|
||||
_state = Finished;
|
||||
emit finished();
|
||||
|
||||
auto statTracker = DependencyManager::get<StatTracker>();
|
||||
if (_result == Success) {
|
||||
statTracker->incrementStat(STAT_HTTP_REQUEST_SUCCESS);
|
||||
|
||||
if (loadedFromCache()) {
|
||||
statTracker->incrementStat(STAT_HTTP_REQUEST_CACHE);
|
||||
}
|
||||
} else {
|
||||
statTracker->incrementStat(STAT_HTTP_REQUEST_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
void HTTPResourceRequest::onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal) {
|
||||
|
@ -202,4 +216,6 @@ void HTTPResourceRequest::onTimeout() {
|
|||
_result = Timeout;
|
||||
_state = Finished;
|
||||
emit finished();
|
||||
|
||||
DependencyManager::get<StatTracker>()->incrementStat(STAT_HTTP_REQUEST_FAILED);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,18 @@
|
|||
|
||||
#include "ByteRange.h"
|
||||
|
||||
const QString STAT_ATP_REQUEST_STARTED = "StartedATPRequest";
|
||||
const QString STAT_HTTP_REQUEST_STARTED = "StartedHTTPRequest";
|
||||
const QString STAT_FILE_REQUEST_STARTED = "StartedFileRequest";
|
||||
const QString STAT_ATP_REQUEST_SUCCESS = "SuccessfulATPRequest";
|
||||
const QString STAT_HTTP_REQUEST_SUCCESS = "SuccessfulHTTPRequest";
|
||||
const QString STAT_FILE_REQUEST_SUCCESS = "SuccessfulFileRequest";
|
||||
const QString STAT_ATP_REQUEST_FAILED = "FailedATPRequest";
|
||||
const QString STAT_HTTP_REQUEST_FAILED = "FailedHTTPRequest";
|
||||
const QString STAT_FILE_REQUEST_FAILED = "FailedFileRequest";
|
||||
const QString STAT_ATP_REQUEST_CACHE = "CacheATPRequest";
|
||||
const QString STAT_HTTP_REQUEST_CACHE = "CacheHTTPRequest";
|
||||
|
||||
class ResourceRequest : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue