mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 12:28:02 +02:00
Fix bytes downloaded stat tracking
This commit is contained in:
parent
3500705d0c
commit
014a7bc9b0
10 changed files with 37 additions and 21 deletions
|
@ -1628,12 +1628,14 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
properties["throttled"] = _displayPlugin ? _displayPlugin->isThrottled() : false;
|
properties["throttled"] = _displayPlugin ? _displayPlugin->isThrottled() : false;
|
||||||
|
|
||||||
QJsonObject bytesDownloaded;
|
QJsonObject bytesDownloaded;
|
||||||
bytesDownloaded["atp"] = statTracker->getStat(STAT_ATP_RESOURCE_TOTAL_BYTES).toInt();
|
auto atpBytes = statTracker->getStat(STAT_ATP_RESOURCE_TOTAL_BYTES).toLongLong();
|
||||||
bytesDownloaded["http"] = statTracker->getStat(STAT_HTTP_RESOURCE_TOTAL_BYTES).toInt();
|
auto httpBytes = statTracker->getStat(STAT_HTTP_RESOURCE_TOTAL_BYTES).toLongLong();
|
||||||
bytesDownloaded["file"] = statTracker->getStat(STAT_FILE_RESOURCE_TOTAL_BYTES).toInt();
|
auto fileBytes = statTracker->getStat(STAT_FILE_RESOURCE_TOTAL_BYTES).toLongLong();
|
||||||
bytesDownloaded["total"] = bytesDownloaded["atp"].toInt() + bytesDownloaded["http"].toInt()
|
bytesDownloaded["atp"] = atpBytes;
|
||||||
+ bytesDownloaded["file"].toInt();
|
bytesDownloaded["http"] = httpBytes;
|
||||||
properties["bytesDownloaded"] = bytesDownloaded;
|
bytesDownloaded["file"] = fileBytes;
|
||||||
|
bytesDownloaded["total"] = atpBytes + httpBytes + fileBytes;
|
||||||
|
properties["bytes_downloaded"] = bytesDownloaded;
|
||||||
|
|
||||||
auto myAvatar = getMyAvatar();
|
auto myAvatar = getMyAvatar();
|
||||||
glm::vec3 avatarPosition = myAvatar->getPosition();
|
glm::vec3 avatarPosition = myAvatar->getPosition();
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <NetworkLogging.h>
|
#include <NetworkLogging.h>
|
||||||
#include <NodeList.h>
|
#include <NodeList.h>
|
||||||
#include <OffscreenUi.h>
|
#include <OffscreenUi.h>
|
||||||
|
#include <UserActivityLogger.h>
|
||||||
|
|
||||||
static const int AUTO_REFRESH_INTERVAL = 1000;
|
static const int AUTO_REFRESH_INTERVAL = 1000;
|
||||||
|
|
||||||
|
|
|
@ -155,6 +155,7 @@ void AssetResourceRequest::requestHash(const AssetHash& hash) {
|
||||||
case AssetRequest::Error::NoError:
|
case AssetRequest::Error::NoError:
|
||||||
_data = req->getData();
|
_data = req->getData();
|
||||||
_result = Success;
|
_result = Success;
|
||||||
|
recordBytesDownloadedInStats(STAT_ATP_RESOURCE_TOTAL_BYTES, _data.size());
|
||||||
break;
|
break;
|
||||||
case AssetRequest::InvalidHash:
|
case AssetRequest::InvalidHash:
|
||||||
_result = InvalidURL;
|
_result = InvalidURL;
|
||||||
|
@ -202,9 +203,8 @@ void AssetResourceRequest::onDownloadProgress(qint64 bytesReceived, qint64 bytes
|
||||||
emit progress(bytesReceived, bytesTotal);
|
emit progress(bytesReceived, bytesTotal);
|
||||||
|
|
||||||
auto now = p_high_resolution_clock::now();
|
auto now = p_high_resolution_clock::now();
|
||||||
|
|
||||||
// Recording ATP bytes downloaded in stats
|
recordBytesDownloadedInStats(STAT_ATP_RESOURCE_TOTAL_BYTES, bytesReceived);
|
||||||
DependencyManager::get<StatTracker>()->updateStat(STAT_ATP_RESOURCE_TOTAL_BYTES, bytesReceived);
|
|
||||||
|
|
||||||
// if we haven't received the full asset check if it is time to output progress to log
|
// if we haven't received the full asset check if it is time to output progress to log
|
||||||
// we do so every X seconds to assist with ATP download tracking
|
// we do so every X seconds to assist with ATP download tracking
|
||||||
|
|
|
@ -41,6 +41,8 @@ private:
|
||||||
AssetRequest* _assetRequest { nullptr };
|
AssetRequest* _assetRequest { nullptr };
|
||||||
|
|
||||||
p_high_resolution_clock::time_point _lastProgressDebug;
|
p_high_resolution_clock::time_point _lastProgressDebug;
|
||||||
|
|
||||||
|
int64_t _lastRecordedBytesDownloaded { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -69,8 +69,7 @@ void FileResourceRequest::doSend() {
|
||||||
|
|
||||||
if (_result == ResourceRequest::Success) {
|
if (_result == ResourceRequest::Success) {
|
||||||
statTracker->incrementStat(STAT_FILE_REQUEST_SUCCESS);
|
statTracker->incrementStat(STAT_FILE_REQUEST_SUCCESS);
|
||||||
// Recording FILE bytes downloaded in stats
|
statTracker->updateStat(STAT_FILE_RESOURCE_TOTAL_BYTES, fileSize);
|
||||||
statTracker->updateStat(STAT_FILE_RESOURCE_TOTAL_BYTES,fileSize);
|
|
||||||
} else {
|
} else {
|
||||||
statTracker->incrementStat(STAT_FILE_REQUEST_FAILED);
|
statTracker->incrementStat(STAT_FILE_REQUEST_FAILED);
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,6 +141,8 @@ void HTTPResourceRequest::onRequestFinished() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recordBytesDownloadedInStats(STAT_HTTP_RESOURCE_TOTAL_BYTES, _data.size());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QNetworkReply::TimeoutError:
|
case QNetworkReply::TimeoutError:
|
||||||
|
@ -201,11 +203,8 @@ void HTTPResourceRequest::onDownloadProgress(qint64 bytesReceived, qint64 bytesT
|
||||||
_sendTimer->start();
|
_sendTimer->start();
|
||||||
|
|
||||||
emit progress(bytesReceived, bytesTotal);
|
emit progress(bytesReceived, bytesTotal);
|
||||||
|
|
||||||
// Recording HTTP bytes downloaded in stats
|
recordBytesDownloadedInStats(STAT_HTTP_RESOURCE_TOTAL_BYTES, bytesReceived);
|
||||||
DependencyManager::get<StatTracker>()->updateStat(STAT_HTTP_RESOURCE_TOTAL_BYTES, bytesReceived);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HTTPResourceRequest::onTimeout() {
|
void HTTPResourceRequest::onTimeout() {
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
|
|
||||||
#include "ResourceRequest.h"
|
#include "ResourceRequest.h"
|
||||||
|
|
||||||
|
#include <DependencyManager.h>
|
||||||
|
#include <StatTracker.h>
|
||||||
|
|
||||||
#include <QtCore/QThread>
|
#include <QtCore/QThread>
|
||||||
|
|
||||||
ResourceRequest::ResourceRequest(const QUrl& url) : _url(url) { }
|
ResourceRequest::ResourceRequest(const QUrl& url) : _url(url) { }
|
||||||
|
@ -40,3 +43,11 @@ QString ResourceRequest::getResultString() const {
|
||||||
default: return "Unspecified Error";
|
default: return "Unspecified Error";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResourceRequest::recordBytesDownloadedInStats(const QString& statName, int64_t bytesReceived) {
|
||||||
|
auto dBytes = bytesReceived - _lastRecordedBytesDownloaded;
|
||||||
|
if (dBytes > 0) {
|
||||||
|
_lastRecordedBytesDownloaded = bytesReceived;
|
||||||
|
DependencyManager::get<StatTracker>()->updateStat(statName, dBytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -85,6 +85,7 @@ signals:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void doSend() = 0;
|
virtual void doSend() = 0;
|
||||||
|
void recordBytesDownloadedInStats(const QString& statName, int64_t bytesReceived);
|
||||||
|
|
||||||
QUrl _url;
|
QUrl _url;
|
||||||
QUrl _relativePathURL;
|
QUrl _relativePathURL;
|
||||||
|
@ -97,6 +98,7 @@ protected:
|
||||||
ByteRange _byteRange;
|
ByteRange _byteRange;
|
||||||
bool _rangeRequestSuccessful { false };
|
bool _rangeRequestSuccessful { false };
|
||||||
uint64_t _totalSizeOfResource { 0 };
|
uint64_t _totalSizeOfResource { 0 };
|
||||||
|
int64_t _lastRecordedBytesDownloaded { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -17,12 +17,12 @@ QVariant StatTracker::getStat(const QString& name) {
|
||||||
return _stats[name];
|
return _stats[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatTracker::setStat(const QString& name, int value) {
|
void StatTracker::setStat(const QString& name, int64_t value) {
|
||||||
Lock lock(_statsLock);
|
Lock lock(_statsLock);
|
||||||
_stats[name] = value;
|
_stats[name] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatTracker::updateStat(const QString& name, int value) {
|
void StatTracker::updateStat(const QString& name, int64_t value) {
|
||||||
Lock lock(_statsLock);
|
Lock lock(_statsLock);
|
||||||
auto itr = _stats.find(name);
|
auto itr = _stats.find(name);
|
||||||
if (_stats.end() == itr) {
|
if (_stats.end() == itr) {
|
||||||
|
|
|
@ -24,15 +24,15 @@ class StatTracker : public Dependency {
|
||||||
public:
|
public:
|
||||||
StatTracker();
|
StatTracker();
|
||||||
QVariant getStat(const QString& name);
|
QVariant getStat(const QString& name);
|
||||||
void setStat(const QString& name, int value);
|
void setStat(const QString& name, int64_t value);
|
||||||
void updateStat(const QString& name, int mod);
|
void updateStat(const QString& name, int64_t mod);
|
||||||
void incrementStat(const QString& name);
|
void incrementStat(const QString& name);
|
||||||
void decrementStat(const QString& name);
|
void decrementStat(const QString& name);
|
||||||
private:
|
private:
|
||||||
using Mutex = std::mutex;
|
using Mutex = std::mutex;
|
||||||
using Lock = std::lock_guard<Mutex>;
|
using Lock = std::lock_guard<Mutex>;
|
||||||
Mutex _statsLock;
|
Mutex _statsLock;
|
||||||
QHash<QString, int> _stats;
|
QHash<QString, int64_t> _stats;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CounterStat {
|
class CounterStat {
|
||||||
|
|
Loading…
Reference in a new issue